diff options
author | terminaldweller <devi@terminaldweller.com> | 2024-06-09 14:38:00 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2024-06-09 14:38:00 +0000 |
commit | 309de82960b717f61dd90b908c2c28955955f504 (patch) | |
tree | 4a9a6997e25383e555200084e3835358edeb3701 /types.go | |
parent | updated the readme, remove girc.Client as an arg to the lua extension functio... (diff) | |
download | milla-309de82960b717f61dd90b908c2c28955955f504.tar.gz milla-309de82960b717f61dd90b908c2c28955955f504.zip |
added a load and unload command for plugins
Diffstat (limited to '')
-rw-r--r-- | types.go | 66 |
1 files changed, 48 insertions, 18 deletions
@@ -1,9 +1,11 @@ package main import ( + "context" "time" "github.com/jackc/pgx/v5/pgxpool" + lua "github.com/yuin/gopher-lua" ) type LogModel struct { @@ -20,6 +22,11 @@ type CustomCommand struct { Prompt string `toml:"prompt"` } +type LuaLstates struct { + LuaState *lua.LState + Cancel context.CancelFunc +} + type TomlConfig struct { IrcServer string `toml:"ircServer"` IrcNick string `toml:"ircNick"` @@ -49,30 +56,53 @@ type TomlConfig struct { WebIRCAddress string `toml:"webIRCAddress"` Plugins []string `toml:"plugins"` CustomCommands map[string]CustomCommand `toml:"customCommands"` - Temp float64 `toml:"temp"` - RequestTimeout int `toml:"requestTimeout"` - MillaReconnectDelay int `toml:"millaReconnectDelay"` - IrcPort int `toml:"ircPort"` - KeepAlive int `toml:"keepAlive"` - MemoryLimit int `toml:"memoryLimit"` - PingDelay int `toml:"pingDelay"` - PingTimeout int `toml:"pingTimeout"` - TopP float32 `toml:"topP"` - TopK int32 `toml:"topK"` - EnableSasl bool `toml:"enableSasl"` - SkipTLSVerify bool `toml:"skipTLSVerify"` - UseTLS bool `toml:"useTLS"` - DisableSTSFallback bool `toml:"disableSTSFallback"` - AllowFlood bool `toml:"allowFlood"` - Debug bool `toml:"debug"` - Out bool `toml:"out"` - AdminOnly bool `toml:"adminOnly"` + LuaStates map[string]LuaLstates + Temp float64 `toml:"temp"` + RequestTimeout int `toml:"requestTimeout"` + MillaReconnectDelay int `toml:"millaReconnectDelay"` + IrcPort int `toml:"ircPort"` + KeepAlive int `toml:"keepAlive"` + MemoryLimit int `toml:"memoryLimit"` + PingDelay int `toml:"pingDelay"` + PingTimeout int `toml:"pingTimeout"` + TopP float32 `toml:"topP"` + TopK int32 `toml:"topK"` + EnableSasl bool `toml:"enableSasl"` + SkipTLSVerify bool `toml:"skipTLSVerify"` + UseTLS bool `toml:"useTLS"` + DisableSTSFallback bool `toml:"disableSTSFallback"` + AllowFlood bool `toml:"allowFlood"` + Debug bool `toml:"debug"` + Out bool `toml:"out"` + AdminOnly bool `toml:"adminOnly"` pool *pgxpool.Pool Admins []string `toml:"admins"` IrcChannels []string `toml:"ircChannels"` ScrapeChannels []string `toml:"scrapeChannels"` } +func (config *TomlConfig) insertLState( + name string, + luaState *lua.LState, + cancel context.CancelFunc, +) { + if config.LuaStates == nil { + config.LuaStates = make(map[string]LuaLstates) + } + config.LuaStates[name] = LuaLstates{ + LuaState: luaState, + Cancel: cancel, + } +} + +func (config *TomlConfig) deleteLstate(name string) { + if config.LuaStates == nil { + return + } + config.LuaStates[name].Cancel() + delete(config.LuaStates, name) +} + type AppConfig struct { Ircd map[string]TomlConfig `toml:"ircd"` } |