当前位置: 首页>>代码示例>>Golang>>正文


Golang Service.IsBotOwner方法代码示例

本文整理汇总了Golang中github.com/iopred/bruxism.Service.IsBotOwner方法的典型用法代码示例。如果您正苦于以下问题:Golang Service.IsBotOwner方法的具体用法?Golang Service.IsBotOwner怎么用?Golang Service.IsBotOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/iopred/bruxism.Service的用法示例。


在下文中一共展示了Service.IsBotOwner方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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],
	}
}
开发者ID:iopred,项目名称:bruxism,代码行数:11,代码来源:triviaplugin.go

示例2: helpFunc

// Help returns a list of help strings that are printed when the user requests them.
func (p *playingPlugin) helpFunc(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message, detailed bool) []string {
	if detailed {
		return nil
	}

	if !service.IsBotOwner(message) {
		return nil
	}

	return bruxism.CommandHelp(service, "playing", "<game>, <url>", fmt.Sprintf("Set which game %s is playing.", service.UserName()))
}
开发者ID:iopred,项目名称:bruxism,代码行数:12,代码来源:playingplugin.go

示例3: Message

// Message handler.
func (p *YouTubeJoinPlugin) Message(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) {
	if (service.IsBotOwner(message) || service.IsChannelOwner(message)) && bruxism.MatchesCommand(service, "leave", message) {
		video, ok := p.youtube.VideoIDForChatID(message.Channel())
		if ok {
			channel, ok := p.youtube.ChannelIDForVideoID(video)
			if ok {
				p.Unmonitor(channel)
			}
		}
	}
}
开发者ID:iopred,项目名称:bruxism,代码行数:12,代码来源:youtubejoinplugin.go

示例4: messageFunc

// Message handler.
func (p *playingPlugin) messageFunc(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) {
	if !service.IsMe(message) {
		if bruxism.MatchesCommand(service, "playing", message) {
			if !service.IsBotOwner(message) {
				return
			}
			query, _ := bruxism.ParseCommand(service, message)

			split := strings.Split(query, ",")

			p.Game = strings.Trim(split[0], " ")
			if len(split) > 1 {
				p.URL = strings.Trim(split[1], " ")
				service.(*bruxism.Discord).Session.UpdateStreamingStatus(0, p.Game, p.URL)
			} else {
				service.(*bruxism.Discord).Session.UpdateStatus(0, p.Game)
			}
		}
	}
}
开发者ID:iopred,项目名称:bruxism,代码行数:21,代码来源:playingplugin.go

示例5: Message

// Message handler.
func (p *MusicPlugin) Message(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) {
	defer bruxism.MessageRecover()

	if service.IsMe(message) {
		return
	}

	if !bruxism.MatchesCommand(service, "music", message) && !bruxism.MatchesCommand(service, "mu", message) {
		return
	}

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

	if len(parts) == 0 {
		service.SendMessage(message.Channel(), strings.Join(p.Help(bot, service, message, true), "\n"))
		return
	}

	// Get the Channel (and GuildID) for this channel because it's needed in
	// a few locations below
	channel, err := p.discord.Channel(message.Channel())
	if err != nil {
		log.Println("musicplugin: fetching channel err:", err.Error())
		return
	}

	// grab pointer to this channels voice connection, if exists.
	vc, vcok := p.VoiceConnections[channel.GuildID]

	switch parts[0] {

	case "help":
		// display extended help information
		service.SendMessage(message.Channel(), strings.Join(p.Help(bot, service, message, true), "\n"))

	case "stats":
		// TODO: maybe provide plugin stats, total channels, total song queues, etc

	case "join":
		if !service.IsBotOwner(message) {
			service.SendMessage(message.Channel(), "Sorry, only bot owner can join, please ask him to run this command.")
			return
		}
		// join the voice channel of the caller or the provided channel ID

		channelID := ""
		if len(parts) > 1 {
			channelID = parts[1]
		}

		if channelID == "" {
			messageUserID := message.UserID()
			for _, g := range p.discord.Guilds() {
				for _, v := range g.VoiceStates {
					if v.UserID == messageUserID {
						channelID = v.ChannelID
					}
				}
			}

			if channelID == "" {
				service.SendMessage(message.Channel(), "I couldn't find you in any voice channels, please join one.")
				return
			}
		}

		_, err := p.join(channelID)
		if err != nil {
			service.SendMessage(message.Channel(), err.Error())
			break
		}

		service.SendMessage(message.Channel(), "Now, let's play some music!")

	case "leave":
		// leave voice channel for this Guild
		if !service.IsBotOwner(message) {
			service.SendMessage(message.Channel(), "Sorry, only bot owner can leave, please ask him to run this command.")
			return
		}

		if !vcok {
			service.SendMessage(message.Channel(), "There is no voice connection for this Guild.")
		}

		vc.conn.Close()
		delete(p.VoiceConnections, channel.GuildID)
		service.SendMessage(message.Channel(), "Closed voice connection.")

	case "debug":
		// enable or disable debug

		if !vcok {
			service.SendMessage(message.Channel(), fmt.Sprintf("There is no voice connection for this Guild."))
		}

		vc.Lock()
		vc.debug = !vc.debug
		service.SendMessage(message.Channel(), fmt.Sprintf("debug mode set to %v", vc.debug))
//.........这里部分代码省略.........
开发者ID:iopred,项目名称:bruxism,代码行数:101,代码来源:musicplugin.go

示例6: 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)
			}
		}
	}
}
开发者ID:iopred,项目名称:bruxism,代码行数:71,代码来源:triviaplugin.go


注:本文中的github.com/iopred/bruxism.Service.IsBotOwner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。