From 7a3795e44bf030fc0e27c49aea8c32a4457a59f5 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Sat, 20 Jul 2024 23:43:36 -0400 Subject: we can now add new commands from lua plugins --- main.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'main.go') 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) } } -- cgit v1.2.3