Example #1
0
func (p *ReminderPlugin) randomReminder(service bruxism.Service) string {
	ticks := ""
	if service.Name() == bruxism.DiscordServiceName {
		ticks = "`"
	}

	return fmt.Sprintf("%s%sreminder %s %s%s", ticks, service.CommandPrefix(), p.random(randomTimes), p.random(randomMessages), ticks)
}
Example #2
0
func (p *chartPlugin) randomChart(service bruxism.Service) string {
	ticks := ""
	if service.Name() == bruxism.DiscordServiceName {
		ticks = "`"
	}

	return fmt.Sprintf("%s%schart %s %s, %s%s", ticks, service.CommandPrefix(), p.random(randomDirection), p.random(randomY), p.random(randomX), ticks)
}
Example #3
0
// Message handler.
func (p *livePlugin) Message(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) {
	defer bruxism.MessageRecover()
	if !service.IsMe(message) {
		messageChannel := message.Channel()

		if bruxism.MatchesCommand(service, "live", message) {
			ticks := ""
			if service.Name() == bruxism.DiscordServiceName {
				ticks = "`"
			}

			_, parts := bruxism.ParseCommand(service, message)

			if len(parts) == 0 {
				service.SendMessage(messageChannel, fmt.Sprintf("Incorrect command. eg: %s%slive [add|remove|list] <%s>%s", ticks, service.CommandPrefix(), "UCGmC0A8mEAPdlELQdP9xJbw", ticks))
			}

			switch parts[0] {
			case "list":
				if !service.IsModerator(message) {
					service.SendMessage(messageChannel, "I'm sorry, you must be the channel owner to list live announcements.")
					return
				}
				list := []string{}
				p.Lock()
				for ytChannel := range p.ChannelToYouTubeChannels[messageChannel] {
					list = append(list, fmt.Sprintf("%s (%s)", p.ytLiveChannel.ChannelName(ytChannel), ytChannel))
				}
				p.Unlock()
				if len(list) == 0 {
					service.SendMessage(messageChannel, "No Channels are being announced.")
				} else {
					service.SendMessage(messageChannel, fmt.Sprintf("Currently announcing: %s", strings.Join(list, ",")))
				}
			case "add":
				if !service.IsModerator(message) {
					service.SendMessage(messageChannel, "I'm sorry, you must be the channel owner to add live announcements.")
					return
				}
				if len(parts) != 2 || len(parts[1]) != 24 {
					service.SendMessage(messageChannel, fmt.Sprintf("Incorrect Channel ID. eg: %s%slive %s %s%s", ticks, service.CommandPrefix(), parts[0], "UCGmC0A8mEAPdlELQdP9xJbw", ticks))
					return
				}
				err := p.monitor(messageChannel, parts[1])
				if err != nil {
					service.SendMessage(messageChannel, fmt.Sprintf("Could not add Channel ID. %s", err))
					return
				}
				service.SendMessage(messageChannel, fmt.Sprintf("Messages will be sent here when %s goes live.", p.ytLiveChannel.ChannelName(parts[1])))
			case "remove":
				if !service.IsModerator(message) {
					service.SendMessage(messageChannel, "I'm sorry, you must be the channel owner to remove live announcements.")
					return
				}
				if len(parts) != 2 || len(parts[1]) != 24 {
					service.SendMessage(messageChannel, fmt.Sprintf("Incorrect Channel ID. eg: %s%slive %s %s%s", ticks, service.CommandPrefix(), parts[0], "UCGmC0A8mEAPdlELQdP9xJbw", ticks))
					return
				}
				p.Lock()
				delete(p.ChannelToYouTubeChannels[messageChannel], parts[1])
				delete(p.youTubeChannelToChannels[parts[1]], messageChannel)
				p.Unlock()
				service.SendMessage(messageChannel, fmt.Sprintf("Messages will no longer be sent here when %s goes live.", p.ytLiveChannel.ChannelName(parts[1])))
			}
		}
	}
}