mirror of https://github.com/fluffle/goirc
voice, devoice, autovoice
This commit is contained in:
parent
b744a13cbf
commit
9d083ce6af
|
@ -26,7 +26,8 @@ The following is a description of the commands enabled by each flag:
|
||||||
|
|
||||||
- `a`: add remove
|
- `a`: add remove
|
||||||
- `o`: op halfop deop dehalfop kick|k ban|b unban|u kb
|
- `o`: op halfop deop dehalfop kick|k ban|b unban|u kb
|
||||||
- `h`: halfop|hop dehalfop|dehop kick ban unban kb (hop and dehop can only be used on yourself and you cannot kick or kb people with o or h)
|
- `h`: halfop|hop dehalfop|dehop kick|k ban|b unban|u kb (hop and dehop can only be used on yourself and you cannot kick or kb people with o or h)
|
||||||
|
- `v`: voice, devoice
|
||||||
- `t`: topic appendtopic
|
- `t`: topic appendtopic
|
||||||
- `s`: say
|
- `s`: say
|
||||||
|
|
||||||
|
@ -55,6 +56,10 @@ Op commands:
|
||||||
- `deop raylu john`: deop raylu and john
|
- `deop raylu john`: deop raylu and john
|
||||||
- `dehalfop`: dehalfop yourself
|
- `dehalfop`: dehalfop yourself
|
||||||
- `dehalfop|dehop raylu john`: dehalfop raylu and john
|
- `dehalfop|dehop raylu john`: dehalfop raylu and john
|
||||||
|
- `voice`: voice yourself
|
||||||
|
- `voice raylu john`: voice raylu and john
|
||||||
|
- `devoice`: devoice yourself
|
||||||
|
- `devoice raylu john`: devoice raylu and john
|
||||||
- `kick|k raylu`: kick raylu
|
- `kick|k raylu`: kick raylu
|
||||||
- `ban|b raylu john!*@*`: ban raylu by hostname and john by nick
|
- `ban|b raylu john!*@*`: ban raylu by hostname and john by nick
|
||||||
- `unban|u raylu john!*@*`: unban raylu by hostname and john by nick
|
- `unban|u raylu john!*@*`: unban raylu by hostname and john by nick
|
||||||
|
|
32
cmd-op.go
32
cmd-op.go
|
@ -76,6 +76,38 @@ func dehalfop(conn *irc.Conn, nick *irc.Nick, args, target string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func voice(conn *irc.Conn, nick *irc.Nick, args, target string) {
|
||||||
|
channel, args := parseAccess(conn, nick, target, args, "v")
|
||||||
|
if channel == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if args == "" {
|
||||||
|
conn.Mode(channel, "+v " + nick.Nick)
|
||||||
|
} else {
|
||||||
|
voices := strings.TrimSpace(args)
|
||||||
|
count := strings.Count(voices, " ") + 1
|
||||||
|
modestring := "+" + strings.Repeat("v", count) + " " + voices
|
||||||
|
conn.Mode(channel, modestring)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func devoice(conn *irc.Conn, nick *irc.Nick, args, target string) {
|
||||||
|
channel, args := parseAccess(conn, nick, target, args, "v")
|
||||||
|
if channel == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if args == "" {
|
||||||
|
conn.Mode(channel, "-v " + nick.Nick)
|
||||||
|
} else {
|
||||||
|
voices := strings.TrimSpace(args)
|
||||||
|
count := strings.Count(voices, " ") + 1
|
||||||
|
modestring := "-" + strings.Repeat("v", count) + " " + voices
|
||||||
|
conn.Mode(channel, modestring)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func kick(conn *irc.Conn, nick *irc.Nick, args, target string) {
|
func kick(conn *irc.Conn, nick *irc.Nick, args, target string) {
|
||||||
channel, args := parseAccess(conn, nick, target, args, "oh")
|
channel, args := parseAccess(conn, nick, target, args, "oh")
|
||||||
if channel == "" || args == "" {
|
if channel == "" || args == "" {
|
||||||
|
|
26
handler.go
26
handler.go
|
@ -23,6 +23,8 @@ var commands = map [string]func(*irc.Conn, *irc.Nick, string, string) {
|
||||||
"deop": deop,
|
"deop": deop,
|
||||||
"dehalfop": dehalfop,
|
"dehalfop": dehalfop,
|
||||||
"dehop": dehalfop,
|
"dehop": dehalfop,
|
||||||
|
"voice": voice,
|
||||||
|
"devoice": devoice,
|
||||||
"kick": kick,
|
"kick": kick,
|
||||||
"k": kick,
|
"k": kick,
|
||||||
"b": ban,
|
"b": ban,
|
||||||
|
@ -77,6 +79,30 @@ func handleMode(conn *irc.Conn, line *irc.Line) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleJoin(conn *irc.Conn, line *irc.Line) {
|
||||||
|
// autovoice users with v flag
|
||||||
|
if line.Nick == conn.Me.Nick {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
channel := conn.GetChannel(line.Text)
|
||||||
|
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.Text, "v") {
|
||||||
|
conn.Mode(line.Text, "+v " + line.Nick)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func handleInvite(conn *irc.Conn, line *irc.Line) {
|
func handleInvite(conn *irc.Conn, line *irc.Line) {
|
||||||
if line.Args[0] != conn.Me.Nick {
|
if line.Args[0] != conn.Me.Nick {
|
||||||
return
|
return
|
||||||
|
|
1
rbot.go
1
rbot.go
|
@ -53,6 +53,7 @@ func connect(network string) {
|
||||||
})
|
})
|
||||||
c.AddHandler("privmsg", handlePrivmsg)
|
c.AddHandler("privmsg", handlePrivmsg)
|
||||||
c.AddHandler("mode", handleMode)
|
c.AddHandler("mode", handleMode)
|
||||||
|
c.AddHandler("join", handleJoin)
|
||||||
c.AddHandler("invite", handleInvite)
|
c.AddHandler("invite", handleInvite)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
Loading…
Reference in New Issue