本文整理汇总了Golang中github.com/iopred/bruxism.Service.CommandPrefix方法的典型用法代码示例。如果您正苦于以下问题:Golang Service.CommandPrefix方法的具体用法?Golang Service.CommandPrefix怎么用?Golang Service.CommandPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/iopred/bruxism.Service
的用法示例。
在下文中一共展示了Service.CommandPrefix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: randomReminder
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)
}
示例2: randomChart
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)
}
示例3: Message
// 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])))
}
}
}
}