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


Golang Client.Join方法代码示例

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


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

示例1: onJoinChannels

// onJoinChannels is used to complete the login procedure.
// We have just received the server's MOTD and now is a good time to
// start joining channels.
func onJoinChannels(c *proto.Client, m *proto.Message) {
	c.Join(config.Channels...)
}
开发者ID:ChimeraCoder,项目名称:gopherbot,代码行数:6,代码来源:proto.go

示例2: Load

func (p *Plugin) Load(c *proto.Client) (err error) {
	err = p.Base.Load(c)
	if err != nil {
		return
	}

	comm := new(cmd.Command)
	comm.Name = "quit"
	comm.Description = "Unconditionally quit the bot program"
	comm.Restricted = true
	comm.Execute = func(cmd *cmd.Command, c *proto.Client, m *proto.Message) {
		c.Quit("")
	}
	cmd.Register(comm)

	comm = new(cmd.Command)
	comm.Name = "join"
	comm.Description = "Join the given channel"
	comm.Restricted = true
	comm.Params = []cmd.Param{
		{Name: "channel", Optional: false, Pattern: cmd.RegChannel},
		{Name: "key", Optional: true, Pattern: cmd.RegAny},
		{Name: "chanservpass", Optional: true, Pattern: cmd.RegAny},
	}
	comm.Execute = func(cmd *cmd.Command, c *proto.Client, m *proto.Message) {
		var ch irc.Channel
		ch.Name = cmd.Params[0].Value

		if len(cmd.Params) > 1 {
			ch.Key = cmd.Params[1].Value
		}

		if len(cmd.Params) > 2 {
			ch.ChanservPassword = cmd.Params[2].Value
		}

		c.Join(&ch)
	}
	cmd.Register(comm)

	comm = new(cmd.Command)
	comm.Name = "leave"
	comm.Description = "Leave the given channel"
	comm.Restricted = true
	comm.Params = []cmd.Param{
		{Name: "channel", Optional: true, Pattern: cmd.RegChannel},
	}
	comm.Execute = func(cmd *cmd.Command, c *proto.Client, m *proto.Message) {
		var ch irc.Channel

		if len(cmd.Params) > 0 {
			ch.Name = cmd.Params[0].Value
		} else {
			if !m.FromChannel() {
				return
			}
			ch.Name = m.Receiver
		}

		c.Part(&ch)
	}
	cmd.Register(comm)

	return
}
开发者ID:ChimeraCoder,项目名称:gopherbot,代码行数:65,代码来源:admin.go


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