aboutsummaryrefslogtreecommitdiff
path: root/plugin_chatcmd.go
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2021-09-10 12:47:19 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2021-09-10 12:47:19 +0200
commit7e72caa092194306ba6b5c6b58e6262fdd1fd72c (patch)
treea708f77cc188fb49b72dae608e100bb8ac0b4420 /plugin_chatcmd.go
parent04d33fd100b67da504b16d9f98baa255d5060028 (diff)
Document exported code (#49)
Diffstat (limited to 'plugin_chatcmd.go')
-rw-r--r--plugin_chatcmd.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugin_chatcmd.go b/plugin_chatcmd.go
index 7df2365..85f2e11 100644
--- a/plugin_chatcmd.go
+++ b/plugin_chatcmd.go
@@ -2,6 +2,7 @@ package proxy
import "sync"
+// A ChatCmd holds information on how to handle a chat command.
type ChatCmd struct {
Name string
Perm string
@@ -14,6 +15,7 @@ var chatCmds map[string]ChatCmd
var chatCmdsMu sync.RWMutex
var chatCmdsOnce sync.Once
+// ChatCmds returns a map of all ChatCmds indexed by their names.
func ChatCmds() map[string]ChatCmd {
initChatCmds()
@@ -28,12 +30,14 @@ func ChatCmds() map[string]ChatCmd {
return cmds
}
+// ChatCmdExists reports if a ChatCmd exists.
func ChatCmdExists(name string) bool {
- cmds := ChatCmds()
- _, ok := cmds[name]
+ _, ok := ChatCmds()[name]
return ok
}
+// RegisterChatCmd adds a new ChatCmd. It returns true on success
+// and false if a command with the same name already exists.
func RegisterChatCmd(cmd ChatCmd) bool {
initChatCmds()