示例#1
0
文件: cmd-op.go 项目: raylu/rbot
func kick(conn *irc.Conn, nick *irc.Nick, args, target string) {
	channel, args := parseAccess(conn, nick, target, args, "oh")
	if channel == "" || args == "" {
		return
	}

	split := strings.SplitN(args, " ", 2)
	if n := conn.GetNick(split[0]); n == nil || (split[0] != nick.Nick &&
		(!hasAccess(conn, nick, channel, "o") && hasAccess(conn, n, channel, "oh"))) {
		// if we only have h, we can't kick people with o or h
		return
	}

	reason := "(" + nick.Nick + ")"
	if len(split) == 2 {
		reason += " " + split[1]
	}
	conn.Kick(channel, split[0], reason)
}
示例#2
0
文件: cmd-op.go 项目: raylu/rbot
func kickban(conn *irc.Conn, nick *irc.Nick, args, target string) {
	channel, args := parseAccess(conn, nick, target, args, "oh")
	if channel == "" || args == "" {
		return
	}

	split := strings.SplitN(args, " ", 2)

	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) == 2 {
		reason += " " + split[1]
	}
	conn.Kick(channel, split[0], reason)
}
示例#3
0
文件: cmd-op.go 项目: thevermi/rbot
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)
}