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


Golang Message.Channel方法代码示例

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


在下文中一共展示了Message.Channel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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


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