Exemplo n.º 1
0
Arquivo: cmd-op.go Projeto: raylu/rbot
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)
}
Exemplo n.º 2
0
Arquivo: cmd-op.go Projeto: raylu/rbot
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]+"!")
}
Exemplo n.º 3
0
Arquivo: cmd-op.go Projeto: raylu/rbot
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)
}
Exemplo n.º 4
0
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)
	}
}
Exemplo n.º 5
0
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)
}