This repository was archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
118 lines (93 loc) · 2.87 KB
/
main.go
File metadata and controls
118 lines (93 loc) · 2.87 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/Logiase/MiraiGo-Template/bot"
"github.com/Logiase/MiraiGo-Template/config"
"github.com/Logiase/MiraiGo-Template/utils"
"github.com/eric2788/MiraiValBot/internal/eventhook"
"github.com/eric2788/MiraiValBot/internal/file"
"github.com/eric2788/MiraiValBot/internal/qq"
"github.com/eric2788/MiraiValBot/simulate"
// 所有廣播訂閱平台
_ "github.com/eric2788/MiraiValBot/hooks/sites/bilibili"
_ "github.com/eric2788/MiraiValBot/hooks/sites/twitter"
_ "github.com/eric2788/MiraiValBot/hooks/sites/valorant"
_ "github.com/eric2788/MiraiValBot/hooks/sites/youtube"
// 所有 redis 訂閱處理器
_ "github.com/eric2788/MiraiValBot/hooks/handlers"
// 所有指令
_ "github.com/eric2788/MiraiValBot/hooks/cmd"
// 所有 Discord 指令
_ "github.com/eric2788/MiraiValBot/hooks/discord_cmd"
// 所有定時器任務
_ "github.com/eric2788/MiraiValBot/hooks/timer_tasks"
// 所有游戏
_ "github.com/eric2788/MiraiValBot/hooks/games"
// 所有回应
_ "github.com/eric2788/MiraiValBot/hooks/responses"
// 註冊模組
_ "github.com/eric2788/MiraiValBot/modules/broadcaster"
_ "github.com/eric2788/MiraiValBot/modules/chat_reply"
_ "github.com/eric2788/MiraiValBot/modules/command"
_ "github.com/eric2788/MiraiValBot/modules/counting"
_ "github.com/eric2788/MiraiValBot/modules/game"
_ "github.com/eric2788/MiraiValBot/modules/privatechat"
_ "github.com/eric2788/MiraiValBot/modules/repeatchat"
_ "github.com/eric2788/MiraiValBot/modules/response"
_ "github.com/eric2788/MiraiValBot/modules/timer"
_ "github.com/eric2788/MiraiValBot/modules/urlparser"
_ "github.com/eric2788/MiraiValBot/modules/verbose"
)
func init() {
utils.WriteLogToFS()
}
var cliDebug = flag.Bool("debug", os.Getenv("DEBUG") == "true", "enable debug logging level")
func main() {
flag.Parse()
if *cliDebug {
simulate.EnableDebug()
}
go debugServe()
file.GenerateConfig()
file.GenerateDevice()
config.Init()
file.LoadApplicationYaml()
file.LoadStorage()
// 快速初始化
bot.Init()
// 初始化 Modules
bot.StartService()
// 使用协议
// 不同协议可能会有部分功能无法使用
// 在登陆前切换协议
// 若沒有指明,則默認 AndroidPad
if os.Getenv("PROTOCOL") == "AndroidPhone" {
bot.UseProtocol(bot.AndroidPhone)
} else if os.Getenv("PROTOCOL") == "IPad" {
bot.UseProtocol(bot.IPad)
} else if os.Getenv("PROTOCOL") == "AndroidWatch" {
bot.UseProtocol(bot.AndroidWatch)
} else if os.Getenv("PROTOCOL") == "MacOS" {
bot.UseProtocol(bot.MacOS)
}
// 登录
err := bot.Login()
if err != nil {
fmt.Println(err)
return
}
bot.SaveToken()
// 刷新好友列表,群列表
bot.RefreshList()
qq.InitValGroupInfo(bot.Instance)
eventhook.HookBotEvents()
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
<-ch
bot.Stop()
file.SaveStorage()
}