mirror of https://github.com/fluffle/goirc
Added listaccess command
This commit is contained in:
parent
8ce6c4e32e
commit
9723754282
|
@ -31,7 +31,7 @@ The following is a description of the commands enabled by each flag:
|
||||||
- `t`: topic appendtopic
|
- `t`: topic appendtopic
|
||||||
- `s`: say
|
- `s`: say
|
||||||
|
|
||||||
In addition, a user must have at least one flag to use `flags` (so users without access can't spam the bot).
|
In addition, a user must have at least one flag to use `flags` and `list` (so users without access can't spam the bot).
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ Access related commands:
|
||||||
- `remove raylu t`: removes the t flag from raylu
|
- `remove raylu t`: removes the t flag from raylu
|
||||||
- `remove raylu`: removes all of raylu's flags
|
- `remove raylu`: removes all of raylu's flags
|
||||||
- `say text`: says text to the channel
|
- `say text`: says text to the channel
|
||||||
|
- `list`: lists all users and their access
|
||||||
|
|
||||||
Op commands:
|
Op commands:
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,31 @@ func flags(conn *irc.Conn, nick *irc.Nick, args, target string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func accesslist(conn *irc.Conn, nick *irc.Nick, args, target string) {
|
||||||
|
channel, args := parseAccess(conn, nick, target, args, "")
|
||||||
|
if channel == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
owner, err := auth.String(conn.Network, "owner")
|
||||||
|
if err != nil {
|
||||||
|
say(conn, nick.Nick, "%s is the owner", owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
section := conn.Network + " " + channel
|
||||||
|
users, err := auth.Options(section)
|
||||||
|
if err != nil {
|
||||||
|
say(conn, nick.Nick, "%s: Error while getting users")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, u := range users {
|
||||||
|
flags, err := auth.String(section, u)
|
||||||
|
if err == nil {
|
||||||
|
say(conn, nick.Nick, "%s: %s", u, flags)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func csay(conn *irc.Conn, nick *irc.Nick, args, target string) {
|
func csay(conn *irc.Conn, nick *irc.Nick, args, target string) {
|
||||||
channel, args := parseAccess(conn, nick, target, args, "s")
|
channel, args := parseAccess(conn, nick, target, args, "s")
|
||||||
if channel != "" {
|
if channel != "" {
|
||||||
|
|
|
@ -14,6 +14,7 @@ var commands = map [string]func(*irc.Conn, *irc.Nick, string, string) {
|
||||||
"flags": flags,
|
"flags": flags,
|
||||||
"add": add,
|
"add": add,
|
||||||
"remove": remove,
|
"remove": remove,
|
||||||
|
"list": accesslist,
|
||||||
"say": csay,
|
"say": csay,
|
||||||
|
|
||||||
// op
|
// op
|
||||||
|
|
Loading…
Reference in New Issue