-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
51 lines (41 loc) · 858 Bytes
/
main.go
File metadata and controls
51 lines (41 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"os"
"os/signal"
"syscall"
"github.com/ExquisiteCore/LagrangeGo-Template/app"
"github.com/ExquisiteCore/LagrangeGo-Template/logic"
)
func main() {
// 使用依赖注入容器
container := app.NewContainer()
err := container.Initialize()
if err != nil {
panic(err)
}
bot := container.GetBot()
logicManager := container.GetLogicManager()
// 登录
err = bot.Login()
if err != nil {
panic(err)
}
// 监听
bot.Listen()
// 注册自定义逻辑
logic.Manager = logicManager
logic.RegisterCustomLogic()
// 设置事件监听
logicManager.SetupEventListeners()
defer bot.Client().Release()
defer bot.Dumpsig()
// setup the main stop channel
mc := make(chan os.Signal, 2)
signal.Notify(mc, os.Interrupt, syscall.SIGTERM)
for {
switch <-mc {
case os.Interrupt, syscall.SIGTERM:
return
}
}
}