aboutsummaryrefslogtreecommitdiff
path: root/chatcommands.go
diff options
context:
space:
mode:
authorMinetest-j45 <55553015+Minetest-j45@users.noreply.github.com>2022-04-15 18:00:17 +0100
committerMinetest-j45 <55553015+Minetest-j45@users.noreply.github.com>2022-04-15 18:00:17 +0100
commitf8be69143c29606e189337be00594db59d9699ba (patch)
tree36f3bdd176fdf24c0f7254a93b8e70d9d3b3dacf /chatcommands.go
parent34b5af89bb55b7ed188bb936b022bd8da3aff051 (diff)
Fix gperms inconsistency (#2)
Diffstat (limited to 'chatcommands.go')
-rw-r--r--chatcommands.go30
1 files changed, 22 insertions, 8 deletions
diff --git a/chatcommands.go b/chatcommands.go
index ec62923..0519b89 100644
--- a/chatcommands.go
+++ b/chatcommands.go
@@ -278,20 +278,34 @@ func init() {
},
})
proxy.RegisterChatCmd(proxy.ChatCmd{
- Name: "gperms",
- Perm: "cmd_gperms",
- Help: "Show the permissions of a group.",
- Usage: "gperms <group>",
+ Name: "gperms",
+ Perm: "cmd_gperms",
+ Help: "Show the permissions of a group.",
+ Usage: "gperms [group]",
+ TelnetUsage: "gperms <group>",
Handler: func(cc *proxy.ClientConn, w io.Writer, args ...string) string {
- if len(args) != 1 {
- return "Usage: gperms <group>"
+ if len(args) > 0 {
+ if len(args) != 1 {
+ return "Usage: gperms [group]"
+ }
+
+ perms, ok := proxy.Conf().Groups[args[0]]
+ if !ok {
+ return "Group does not exist."
+ }
+ return "Group permissions: " + strings.Join(perms, ", ")
+ }
+
+ if cc == nil {
+ return "Telnet usage: gperms <group>"
}
- perms, ok := proxy.Conf().Groups[args[0]]
+ grp, ok := proxy.Conf().UserGroups[cc.Name()]
if !ok {
- return "Group does not exist."
+ grp = "default"
}
+ perms, _ := proxy.Conf().Groups[grp]
return "Group permissions: " + strings.Join(perms, ", ")
},
})