當前位置: 首頁>>代碼示例>>Golang>>正文


Golang irc.Message類代碼示例

本文整理匯總了Golang中github.com/justinkim/yullibot/irc.Message的典型用法代碼示例。如果您正苦於以下問題:Golang Message類的具體用法?Golang Message怎麽用?Golang Message使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Message類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Process

func (avalon *AvalonCommand) Process(bot *models.Bot, msg *irc.Message) {
	if !models.CommandTriggered(avalon, msg) {
		return
	}

	subcommand := msg.Subcommand()
	switch subcommand {
	case "disable":
		avalon.DoDisable(bot, msg)
	case "enable":
		avalon.DoEnable(bot, msg)
	case "help", "":
		avalon.DoHelp(bot, msg)
	case "implode":
		avalon.DoImplode(bot, msg)
	case "info":
		avalon.DoInfo(bot, msg)
	case "init":
		avalon.DoInit(bot, msg)
	case "join":
		avalon.DoJoin(bot, msg)
	case "start":
		avalon.DoStart(bot, msg)
	case "status":
		avalon.DoStatus(bot, msg)
	}
}
開發者ID:justinkim,項目名稱:avalon,代碼行數:27,代碼來源:avalon.go

示例2: DoStart

func (avalon *AvalonCommand) DoStart(bot *models.Bot, msg *irc.Message) {
	err := avalon.IssuedByLobbyLeaderInGameChannel(msg)
	if err != nil {
		bot.Connection.RespondTo(msg, err.Error())
		return
	}

	if avalon.game.GamePhase == cmodels.PhaseWaitingForPlayers {
		err := avalon.game.StartConfig()
		if err != nil {
			bot.Connection.RespondTo(msg, err.Error())
			return
		}

		resp := fmt.Sprintf(closingLobbyFormatString, avalon.game.NumPlayers())
		bot.Connection.RespondTo(msg, resp)

		bot.Connection.RespondTo(msg, configurationHelpString)
	} else if avalon.game.GamePhase == cmodels.PhaseConfiguration {
		resp := fmt.Sprintf(startingGameFormatString, avalon.game.ListPlayers(), avalon.game.ConfigStatus())
		bot.Connection.Say(msg.Channel(), resp)

		avalon.game.AssignPlayers()
		avalon.Reveal(bot, msg)
		avalon.StartFirstQuest()
	}
}
開發者ID:justinkim,項目名稱:avalon,代碼行數:27,代碼來源:avalon.go

示例3: CommandTriggered

func CommandTriggered(command Command, msg *irc.Message) bool {
	userCommand := strings.ToLower(strings.TrimPrefix(msg.Command(), "!"))
	triggers := command.TriggerStrings()
	for _, trigger := range triggers {
		if userCommand == trigger {
			return true
		}
	}
	return false
}
開發者ID:justinkim,項目名稱:yullibot,代碼行數:10,代碼來源:command.go

示例4: DoImplode

func (avalon *AvalonCommand) DoImplode(bot *models.Bot, msg *irc.Message) {
	err := avalon.IssuedByLobbyLeaderInGameChannel(msg)
	if err != nil {
		bot.Connection.RespondTo(msg, err.Error())
		return
	}

	resp := fmt.Sprintf("%s: %s", avalon.game.ListPlayers(), gameImplodedString)
	bot.Connection.Say(msg.Channel(), resp)

	avalon.channel = ""
	avalon.game = nil
}
開發者ID:justinkim,項目名稱:avalon,代碼行數:13,代碼來源:avalon.go

示例5: DoDisable

func (avalon *AvalonCommand) DoDisable(bot *models.Bot, msg *irc.Message) {
	err := avalon.IssuedByLobbyLeaderInGameChannel(msg)
	if err != nil {
		bot.Connection.RespondTo(msg, err.Error())
		return
	}

	option := msg.Subsubcommand()
	if option == "" {
		bot.Connection.RespondTo(msg, availableOptionsString)
		return
	}

	err = avalon.game.DisableOption(option)
	if err != nil {
		bot.Connection.RespondTo(msg, err.Error())
	}

	resp := fmt.Sprintf(configOptionsEnabledFormatString, avalon.game.ConfigStatus())
	bot.Connection.RespondTo(msg, resp)
}
開發者ID:justinkim,項目名稱:avalon,代碼行數:21,代碼來源:avalon.go

示例6: DoInfo

func (avalon *AvalonCommand) DoInfo(bot *models.Bot, msg *irc.Message) {
	if avalon.game == nil {
		bot.Connection.RespondTo(msg, noActiveGameString)
		return
	}

	subsub := msg.Subsubcommand()
	switch subsub {
	case "":
		bot.Connection.RespondTo(msg, infoHelpString)
	case "game":
		resp := fmt.Sprintf(infoGameFormatString, avalon.lobbyLeader, avalon.channel)
		bot.Connection.RespondTo(msg, resp)
	case "players":
		plural := ""
		if avalon.game.NumPlayers() > 1 {
			plural = "s"
		}

		resp := fmt.Sprintf(infoPlayersFormatString, avalon.game.NumPlayers(), plural, avalon.game.ListPlayers())
		bot.Connection.RespondTo(msg, resp)
	}
}
開發者ID:justinkim,項目名稱:avalon,代碼行數:23,代碼來源:avalon.go

示例7: DoJoin

func (avalon *AvalonCommand) DoJoin(bot *models.Bot, msg *irc.Message) {
	if msg.IsDirectMessage() {
		bot.Connection.RespondTo(msg, noDMCommandString)
		return
	}

	if avalon.game == nil {
		bot.Connection.RespondTo(msg, noActiveGameString)
		return
	}

	if avalon.game.GamePhase != cmodels.PhaseWaitingForPlayers {
		bot.Connection.RespondTo(msg, lobbyClosedString)
		return
	}

	if avalon.channel == msg.Channel() {
		err := avalon.game.AddPlayer(msg.SenderNick())
		if err != nil {
			if err == cmodels.ErrPlayerExists {
				bot.Connection.RespondTo(msg, alreadyJoinedString)
			} else if err == cmodels.ErrTooManyPlayers {
				bot.Connection.RespondTo(msg, tooManyPlayersString)
			}
			return
		}
		bot.Connection.RespondTo(msg, playerAddedString)

		joinProgress := fmt.Sprintf(joinProgressFormatString, avalon.game.NumPlayers())
		bot.Connection.Say(msg.Channel(), joinProgress)

		if avalon.game.CanStartConfig() {
			resp := fmt.Sprintf(readyToConfigFormatString, avalon.lobbyLeader)
			bot.Connection.Say(msg.Channel(), resp)
		}
	}
}
開發者ID:justinkim,項目名稱:avalon,代碼行數:37,代碼來源:avalon.go

示例8: DoInit

func (avalon *AvalonCommand) DoInit(bot *models.Bot, msg *irc.Message) {
	if msg.IsDirectMessage() {
		bot.Connection.RespondTo(msg, noDMCommandString)
		return
	}

	if avalon.game != nil {
		bot.Connection.RespondTo(msg, gameInProgressString)
		return
	}

	avalon.channel = msg.Channel()
	avalon.lobbyLeader = msg.SenderNick()

	avalon.game = cmodels.NewAvalonGame()
	avalon.game.AddPlayer(avalon.lobbyLeader)

	bot.Connection.RespondTo(msg, newGameString)
}
開發者ID:justinkim,項目名稱:avalon,代碼行數:19,代碼來源:avalon.go

示例9: IssuedByLobbyLeaderInGameChannel

func (avalon *AvalonCommand) IssuedByLobbyLeaderInGameChannel(msg *irc.Message) error {
	if msg.IsDirectMessage() {
		return errors.New(noDMCommandString)
	}

	if avalon.game == nil {
		return errors.New(noActiveGameString)
	}

	if avalon.lobbyLeader != msg.SenderNick() {
		return errors.New(onlyLobbyLeaderCanDoThatString)
	}

	if avalon.channel != msg.Channel() {
		resp := fmt.Sprintf(correctChannelFormatString, avalon.channel)
		return errors.New(resp)
	}

	return nil
}
開發者ID:justinkim,項目名稱:avalon,代碼行數:20,代碼來源:avalon.go


注:本文中的github.com/justinkim/yullibot/irc.Message類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。