aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-07-21 03:43:36 +0000
committerterminaldweller <devi@terminaldweller.com>2024-07-21 03:43:36 +0000
commit7a3795e44bf030fc0e27c49aea8c32a4457a59f5 (patch)
tree37d8ce89ad9a63688be5ee9bfa6632bde9a418ca /main.go
parentWIP (diff)
downloadmilla-7a3795e44bf030fc0e27c49aea8c32a4457a59f5.tar.gz
milla-7a3795e44bf030fc0e27c49aea8c32a4457a59f5.zip
we can now add new commands from lua plugins
Diffstat (limited to '')
-rw-r--r--main.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/main.go b/main.go
index 3962a9b..619ea63 100644
--- a/main.go
+++ b/main.go
@@ -220,6 +220,8 @@ func getHelpString() string {
helpString += "cmd - run a custom command defined in the customcommands file\n"
helpString += "getall - returns all config options with their value\n"
helpString += "memstats - returns the memory status currently being used\n"
+ helpString += "load - loads a lua script\n"
+ helpString += "unload - unloads a lua script\n"
return helpString
}
@@ -535,9 +537,25 @@ func runCommand(
break
}
+ for key, value := range appConfig.LuaCommands {
+ if value.Path == args[1] {
+ appConfig.deleteLuaCommand(key)
+
+ break
+ }
+ }
+
appConfig.deleteLstate(args[1])
default:
- client.Cmd.Reply(event, errUnknCmd.Error())
+ _, ok := appConfig.LuaCommands[args[0]]
+ if !ok {
+ client.Cmd.Reply(event, errUnknCmd.Error())
+
+ break
+ }
+
+ result := RunLuaFunc(args[0], args[1], client, appConfig)
+ client.Cmd.Reply(event, result)
}
}