本文整理匯總了Golang中github.com/chimeracoder/gopherbot/proto.Client.Quit方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Quit方法的具體用法?Golang Client.Quit怎麽用?Golang Client.Quit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/chimeracoder/gopherbot/proto.Client
的用法示例。
在下文中一共展示了Client.Quit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: shutdown
// shutdown cleans up our mess.
func shutdown(conn *net.Conn, client *proto.Client) {
plugin.Unload(client)
log.Printf("Shutting down.")
client.Quit(config.QuitMessage)
client.Close()
conn.Close()
}
示例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
}