aboutsummaryrefslogtreecommitdiffstats
path: root/plugins.go
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-06-09 14:38:00 +0000
committerterminaldweller <devi@terminaldweller.com>2024-06-09 14:38:00 +0000
commit309de82960b717f61dd90b908c2c28955955f504 (patch)
tree4a9a6997e25383e555200084e3835358edeb3701 /plugins.go
parentupdated the readme, remove girc.Client as an arg to the lua extension functio... (diff)
downloadmilla-309de82960b717f61dd90b908c2c28955955f504.tar.gz
milla-309de82960b717f61dd90b908c2c28955955f504.zip
added a load and unload command for plugins
Diffstat (limited to 'plugins.go')
-rw-r--r--plugins.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins.go b/plugins.go
index 75273a6..cd99081 100644
--- a/plugins.go
+++ b/plugins.go
@@ -1,6 +1,7 @@
package main
import (
+ "context"
"log"
"net/http"
"reflect"
@@ -285,6 +286,12 @@ func RunScript(scriptPath string, client *girc.Client, appConfig *TomlConfig) {
luaState := lua.NewState()
defer luaState.Close()
+ ctx, cancel := context.WithCancel(context.Background())
+
+ luaState.SetContext(ctx)
+
+ appConfig.insertLState(scriptPath, luaState, cancel)
+
luaState.PreloadModule("milla", millaModuleLoaderClosure(luaState, client, appConfig))
gluasocket.Preload(luaState)
gluaxmlpath.Preload(luaState)