本文整理汇总了Golang中github.com/iopred/bruxism.Service.IsModerator方法的典型用法代码示例。如果您正苦于以下问题:Golang Service.IsModerator方法的具体用法?Golang Service.IsModerator怎么用?Golang Service.IsModerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/iopred/bruxism.Service
的用法示例。
在下文中一共展示了Service.IsModerator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Help
// Help returns a list of help strings that are printed when the user requests them.
func (p *triviaPlugin) Help(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message, detailed bool) []string {
if service.IsPrivate(message) || !(service.IsModerator(message) || service.IsBotOwner(message)) {
return nil
}
return []string{
bruxism.CommandHelp(service, "trivia", "<start|stop> [theme]", "Starts or stops trivia with an optional theme.")[0],
bruxism.CommandHelp(service, "trivia", "<score>", "Returns your current trivia score.")[0],
}
}
示例2: 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])))
}
}
}
}
示例3: Message
// Message handler.
func (p *triviaPlugin) Message(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) {
defer bruxism.MessageRecover()
if !service.IsMe(message) && !service.IsPrivate(message) {
messageChannel := message.Channel()
isCommand := bruxism.MatchesCommand(service, "trivia", message)
if isCommand && (service.IsModerator(message) || service.IsBotOwner(message)) {
p.Lock()
tc := p.Channels[messageChannel]
if tc == nil {
tc = &triviaChannel{
Channel: messageChannel,
Scores: map[string]*triviaScore{},
}
p.Channels[messageChannel] = tc
}
p.Unlock()
_, parts := bruxism.ParseCommand(service, message)
if len(parts) == 0 {
return
}
switch parts[0] {
case "start":
theme := ""
if len(parts) >= 2 {
theme = parts[1]
}
tc.Start(bot, service, theme)
case "stop":
tc.Stop(bot, service)
}
} else {
if isCommand {
_, parts := bruxism.ParseCommand(service, message)
if len(parts) == 0 {
return
}
if parts[0] == "score" {
p.RLock()
tc := p.Channels[messageChannel]
if tc != nil {
ts := tc.Scores[message.UserID()]
if ts != nil {
service.SendMessage(message.Channel(), fmt.Sprintf("%s's score is %d.", message.UserName(), ts.Score))
} else {
service.SendMessage(message.Channel(), fmt.Sprintf("%s's score is 0.", message.UserName()))
}
}
p.RUnlock()
}
return
}
p.RLock()
tc := p.Channels[messageChannel]
p.RUnlock()
if tc != nil {
tc.Message(bot, service, message)
}
}
}
}