本文整理匯總了Golang中github.com/fluffle/goirc/client.Conn.Part方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.Part方法的具體用法?Golang Conn.Part怎麽用?Golang Conn.Part使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fluffle/goirc/client.Conn
的用法示例。
在下文中一共展示了Conn.Part方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: part
func part(conn *irc.Conn, nick *irc.Nick, args, target string) {
channel, _ := parseChannel(target, args)
if channel == "" {
return
}
user := user(nick)
if owner, _ := auth.String(conn.Network, "owner"); owner == user {
conn.Part(channel, "")
}
}
示例2: setupClient
func setupClient(c *irc.Conn, chConnected chan bool) {
c.AddHandler(irc.CONNECTED, func(conn *irc.Conn, line *irc.Line) {
chConnected <- true
})
c.AddHandler(irc.DISCONNECTED, func(conn *irc.Conn, line *irc.Line) {
chConnected <- false
})
c.AddHandler("PRIVMSG", func(conn *irc.Conn, line *irc.Line) {
if len(line.Args) < 2 || !strings.HasPrefix(line.Args[1], "!") {
return
}
to := line.Args[0]
sender := to
if to == c.Me.Nick {
// TODO: check if sender is in main chan, else return
log.Println("Got ! via PM from " + line.Src)
sender = line.Src // replies go via PM too.
} else {
log.Println("Got ! via chan: " + line.Args[0] + " from " + line.Src)
}
log.Println(line.Args)
switch line.Args[0] {
case "!join":
if len(line.Args) == 2 {
c.Join(line.Args[1])
} else if len(line.Args) == 3 {
c.Join(line.Args[1] + " " + line.Args[2])
} else {
c.Privmsg(sender, "Usage: !join #chan or !join #chan key")
}
case "!part":
if len(line.Args) == 2 {
c.Part(line.Args[1])
} else {
c.Privmsg(sender, "Usage: !part #chan")
}
default:
c.Privmsg(sender, "Invalid command: "+strings.Join(line.Args[1:], " "))
return
}
})
}