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


Golang Conn.Part方法代碼示例

本文整理匯總了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, "")
	}
}
開發者ID:raylu,項目名稱:rbot,代碼行數:10,代碼來源:cmd-op.go

示例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
		}
	})

}
開發者ID:RJ,項目名稱:gocat,代碼行數:43,代碼來源:gocat.go


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