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


Golang Conn.GetChannel方法代碼示例

本文整理匯總了Golang中github.com/fluffle/goirc/client.Conn.GetChannel方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.GetChannel方法的具體用法?Golang Conn.GetChannel怎麽用?Golang Conn.GetChannel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/fluffle/goirc/client.Conn的用法示例。


在下文中一共展示了Conn.GetChannel方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: unban

func unban(conn *irc.Conn, nick *irc.Nick, args, target string) {
	channel, args := parseAccess(conn, nick, target, args, "oh")
	if channel == "" || args == "" {
		return
	}

	ch := conn.GetChannel(channel)
	if ch == nil {
		say(conn, target, "%s: Unable to get channel information about %s", nick.Nick, channel)
		return
	}
	bans := strings.TrimSpace(args)
	split := strings.Fields(bans)
	for i, ban := range split {
		if strings.Index(ban, "@") != -1 {
			// it's already a host, do nothing
			continue
		}
		if b, ok := ch.Bans[ban]; ok {
			// we've seen this nick banned before
			split[i] = b
		} else if n := conn.GetNick(ban); n != nil {
			// the user is in one of our channels, here's our best guess
			split[i] = "*!*@" + n.Host
		}
	}
	bans = strings.Join(split, " ")
	modestring := "-" + strings.Repeat("b", len(bans)) + " " + bans
	conn.Mode(channel, modestring)
}
開發者ID:raylu,項目名稱:rbot,代碼行數:30,代碼來源:cmd-op.go

示例2: highlightOps

func highlightOps(conn *irc.Conn, nick *irc.Nick, args, target string) {
	channel, _ := parseChannel(target, args)
	if channel == "" {
		return
	}
	c := conn.GetChannel(channel)
	if c == nil {
		say(conn, target, "Error while getting channel information for %s", channel)
		return
	}

	var highlights string
	for onick, privs := range c.Nicks {
		if privs.Op && onick.Nick != conn.Me.Nick {
			highlights += onick.Nick + ", "
		}
	}
	say(conn, channel, highlights[:len(highlights)-2]+"!")
}
開發者ID:raylu,項目名稱:rbot,代碼行數:19,代碼來源:cmd-op.go

示例3: appendtopic

func appendtopic(conn *irc.Conn, nick *irc.Nick, args, target string) {
	channel, args := parseAccess(conn, nick, target, args, "t")
	if channel == "" {
		return
	}
	c := conn.GetChannel(channel)
	if c == nil {
		say(conn, target, "Error while getting channel information for %s", channel)
		return
	}

	section := conn.Network + " " + channel
	basetopic, _ := conf.String(section, "basetopic")
	if basetopic == "" || !strings.HasPrefix(strings.TrimLeft(c.Topic, " "), basetopic) {
		basetopic = c.Topic
		say(conn, nick.Nick, "New basetopic: %s", basetopic)
		updateConf(section, "basetopic", basetopic)
	}
	conn.Topic(channel, basetopic+args)
}
開發者ID:raylu,項目名稱:rbot,代碼行數:20,代碼來源:cmd-op.go

示例4: handleJoin

func handleJoin(conn *irc.Conn, line *irc.Line) {
	// autovoice users with v flag
	if line.Nick == conn.Me.Nick {
		return
	}

	channel := conn.GetChannel(line.Args[0])
	if channel == nil || !channel.Modes.Moderated {
		return
	}

	privs := conn.Me.Channels[channel]
	if !(privs.Op || privs.Admin || privs.HalfOp || privs.Owner) {
		return
	}
	nick := conn.GetNick(line.Nick)
	if nick == nil {
		return
	}
	if hasAccess(conn, nick, line.Nick, "v") {
		conn.Mode(line.Args[0], "+v "+line.Nick)
	}
}
開發者ID:thevermi,項目名稱:rbot,代碼行數:23,代碼來源:handler.go

示例5: tempban

func tempban(conn *irc.Conn, nick *irc.Nick, args, target string) {
	channel, args := parseAccess(conn, nick, target, args, "oh")
	if channel == "" || args == "" {
		return
	}
	ch := conn.GetChannel(channel)
	if ch == nil {
		say(conn, target, "%s: Unable to get channel information about %s", nick.Nick, channel)
		return
	}
	args = strings.TrimSpace(args)
	split := strings.SplitN(args, " ", 3)
	dur, err := strconv.Atoi64(split[1])
	if dur < 5 {
		dur = 5
		split[1] = "5"
	}
	if err != nil {
		say(conn, channel, "Format: !tb <nick> <minutes> <reason>")
		return
	}
	n := conn.GetNick(split[0])
	if n == nil || (split[0] != nick.Nick &&
		(!hasAccess(conn, nick, channel, "o") && hasAccess(conn, n, channel, "oh"))) {
		return
	}
	conn.Mode(channel, "+b *!*@"+n.Host)

	reason := "(" + nick.Nick + ")"
	if len(split) == 3 {
		reason += " " + split[2]
	}
	reason += " (" + split[1] + " min.)"
	conn.Kick(channel, split[0], reason)
	expiry := time.Seconds() + dur*60
	banLogAdd("*!*@"+n.Host, split[0], reason, channel, expiry)
}
開發者ID:thevermi,項目名稱:rbot,代碼行數:37,代碼來源:cmd-op.go


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