1
1
package main
2
2
3
3
import (
4
+ "context"
4
5
"time"
5
6
6
7
"github.com/jackc/pgx/v5/pgxpool"
8
+ lua "github.com/yuin/gopher-lua"
7
9
)
8
10
9
11
type LogModel struct {
@@ -20,6 +22,11 @@ type CustomCommand struct {
20
22
Prompt string `toml:"prompt"`
21
23
}
22
24
25
+ type LuaLstates struct {
26
+ LuaState * lua.LState
27
+ Cancel context.CancelFunc
28
+ }
29
+
23
30
type TomlConfig struct {
24
31
IrcServer string `toml:"ircServer"`
25
32
IrcNick string `toml:"ircNick"`
@@ -49,30 +56,53 @@ type TomlConfig struct {
49
56
WebIRCAddress string `toml:"webIRCAddress"`
50
57
Plugins []string `toml:"plugins"`
51
58
CustomCommands map [string ]CustomCommand `toml:"customCommands"`
52
- Temp float64 `toml:"temp"`
53
- RequestTimeout int `toml:"requestTimeout"`
54
- MillaReconnectDelay int `toml:"millaReconnectDelay"`
55
- IrcPort int `toml:"ircPort"`
56
- KeepAlive int `toml:"keepAlive"`
57
- MemoryLimit int `toml:"memoryLimit"`
58
- PingDelay int `toml:"pingDelay"`
59
- PingTimeout int `toml:"pingTimeout"`
60
- TopP float32 `toml:"topP"`
61
- TopK int32 `toml:"topK"`
62
- EnableSasl bool `toml:"enableSasl"`
63
- SkipTLSVerify bool `toml:"skipTLSVerify"`
64
- UseTLS bool `toml:"useTLS"`
65
- DisableSTSFallback bool `toml:"disableSTSFallback"`
66
- AllowFlood bool `toml:"allowFlood"`
67
- Debug bool `toml:"debug"`
68
- Out bool `toml:"out"`
69
- AdminOnly bool `toml:"adminOnly"`
59
+ LuaStates map [string ]LuaLstates
60
+ Temp float64 `toml:"temp"`
61
+ RequestTimeout int `toml:"requestTimeout"`
62
+ MillaReconnectDelay int `toml:"millaReconnectDelay"`
63
+ IrcPort int `toml:"ircPort"`
64
+ KeepAlive int `toml:"keepAlive"`
65
+ MemoryLimit int `toml:"memoryLimit"`
66
+ PingDelay int `toml:"pingDelay"`
67
+ PingTimeout int `toml:"pingTimeout"`
68
+ TopP float32 `toml:"topP"`
69
+ TopK int32 `toml:"topK"`
70
+ EnableSasl bool `toml:"enableSasl"`
71
+ SkipTLSVerify bool `toml:"skipTLSVerify"`
72
+ UseTLS bool `toml:"useTLS"`
73
+ DisableSTSFallback bool `toml:"disableSTSFallback"`
74
+ AllowFlood bool `toml:"allowFlood"`
75
+ Debug bool `toml:"debug"`
76
+ Out bool `toml:"out"`
77
+ AdminOnly bool `toml:"adminOnly"`
70
78
pool * pgxpool.Pool
71
79
Admins []string `toml:"admins"`
72
80
IrcChannels []string `toml:"ircChannels"`
73
81
ScrapeChannels []string `toml:"scrapeChannels"`
74
82
}
75
83
84
+ func (config * TomlConfig ) insertLState (
85
+ name string ,
86
+ luaState * lua.LState ,
87
+ cancel context.CancelFunc ,
88
+ ) {
89
+ if config .LuaStates == nil {
90
+ config .LuaStates = make (map [string ]LuaLstates )
91
+ }
92
+ config .LuaStates [name ] = LuaLstates {
93
+ LuaState : luaState ,
94
+ Cancel : cancel ,
95
+ }
96
+ }
97
+
98
+ func (config * TomlConfig ) deleteLstate (name string ) {
99
+ if config .LuaStates == nil {
100
+ return
101
+ }
102
+ config .LuaStates [name ].Cancel ()
103
+ delete (config .LuaStates , name )
104
+ }
105
+
76
106
type AppConfig struct {
77
107
Ircd map [string ]TomlConfig `toml:"ircd"`
78
108
}
0 commit comments