-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
35 lines (32 loc) · 1.08 KB
/
main.go
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
package main
import (
"github.com/amtoaer/bing-bong/client"
"github.com/amtoaer/bing-bong/internal"
"github.com/amtoaer/bing-bong/message"
"github.com/amtoaer/bing-bong/model"
"github.com/amtoaer/bing-bong/utils"
"github.com/spf13/viper"
)
type robot interface {
Init()
SendMessage(int64, string, bool)
HandleEvent(*message.Manager)
}
func main() {
var (
bot robot //机器人实例
mm = message.DefaultManager() //消息队列
botConf map[string]interface{} //机器人配置
)
switch viper.GetString("botType") { // 根据机器人类型决定实例化内容
case "qq":
botConf = viper.GetStringMap("qq")
bot = &client.QQ{Conf: botConf}
}
utils.InitLog() // 重定向日志到文件
bot.Init() // 登录机器人
model.InitDB() // 初始化数据库链接
mm.Init(bot) // 从数据库读取订阅信息初始化消息队列,同时启动消息监听
go internal.CheckMessage(mm) // 开始检测rss更新
bot.HandleEvent(mm) // 启动机器人外部事件监听
}