Initial commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package statg
|
||||
|
||||
import (
|
||||
"stat/common/tgbot"
|
||||
"stat/common/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
Bot *tgbot.TgBot
|
||||
RchssendBot *tgbot.TgBot
|
||||
)
|
||||
|
||||
type BotTokens struct {
|
||||
Madou string `json:"madou"`
|
||||
Zhihu string `json:"zhihu"`
|
||||
Bili string `json:"bili"`
|
||||
Xcb string `json:"xcb"`
|
||||
Dev string `json:"dev"`
|
||||
Rchssend string `json:"rchssend"`
|
||||
}
|
||||
|
||||
type BotChats struct {
|
||||
Broadcast []int64 `json:"broadcast"` // 广播群
|
||||
Command []int64 `json:"command"` // 命令群
|
||||
Monitor []int64 `json:"monitor"` // 监控群
|
||||
Download []int64 `json:"download"` // 下载监控
|
||||
Domain []int64 `json:"domain"` // 域名监控群
|
||||
Develop []int64 `json:"develop"` // 开发调试群
|
||||
Private []int64 `json:"private"` // 私聊用户列表
|
||||
BlocStat []int64 `json:"blocStat"` // 集团统计群
|
||||
Advertise []int64 `json:"advertise"` // 广告监控群
|
||||
ChannelApk []int64 `json:"channelApk"` // 渠道包生成群
|
||||
Project []int64 `json:"project"` // 来自项目的消息
|
||||
AdvsSend []int64 `json:"advssend"` //广告群
|
||||
Rchssend []int64 `json:"rchssend"` //广告群
|
||||
}
|
||||
|
||||
type BotConfig struct {
|
||||
Tokens BotTokens `json:"tokens"`
|
||||
Chats BotChats `json:"chats"`
|
||||
Allow map[int64][]string `json:"allow"` // 原本不允许使用命令的群,额外允许使用指定命令
|
||||
}
|
||||
|
||||
// 数据库初始化好以后调用
|
||||
func InitBot() {
|
||||
|
||||
defer func() {
|
||||
utils.RecoverError(nil)
|
||||
}()
|
||||
|
||||
chats := &tgbot.TgChats{
|
||||
BroadcastChats: Conf.BotConfig.Chats.Broadcast,
|
||||
CommandChats: Conf.BotConfig.Chats.Command,
|
||||
MonitorChats: Conf.BotConfig.Chats.Monitor,
|
||||
DownloadChats: Conf.BotConfig.Chats.Download,
|
||||
DomainChats: Conf.BotConfig.Chats.Domain,
|
||||
DevelopChats: Conf.BotConfig.Chats.Develop,
|
||||
PrivateUsers: Conf.BotConfig.Chats.Private,
|
||||
BlocStats: Conf.BotConfig.Chats.BlocStat,
|
||||
Advertise: Conf.BotConfig.Chats.Advertise,
|
||||
ChannelApk: Conf.BotConfig.Chats.ChannelApk,
|
||||
Project: Conf.BotConfig.Chats.Project,
|
||||
AdvsSend: Conf.BotConfig.Chats.AdvsSend,
|
||||
//Rchssend: Conf.BotConfig.Chats.Rchssend,
|
||||
}
|
||||
|
||||
chat0s := &tgbot.TgChats{
|
||||
Rchssend: Conf.BotConfig.Chats.Rchssend,
|
||||
}
|
||||
|
||||
if Conf.ServerIndex.IsBili() {
|
||||
Bot, _ = tgbot.NewTgBot(Conf.BotConfig.Tokens.Bili, chats, Conf.BotConfig.Allow)
|
||||
RchssendBot, _ = tgbot.NewTgBot(Conf.BotConfig.Tokens.Rchssend, chat0s, Conf.BotConfig.Allow)
|
||||
} else if Conf.ServerIndex.IsMadou() {
|
||||
Bot, _ = tgbot.NewTgBot(Conf.BotConfig.Tokens.Madou, chats, Conf.BotConfig.Allow)
|
||||
} else if Conf.ServerIndex.IsZhihu() {
|
||||
Bot, _ = tgbot.NewTgBot(Conf.BotConfig.Tokens.Zhihu, chats, Conf.BotConfig.Allow)
|
||||
} else if Conf.ServerIndex.IsXcb() {
|
||||
Bot, _ = tgbot.NewTgBot(Conf.BotConfig.Tokens.Xcb, chats, Conf.BotConfig.Allow)
|
||||
} else {
|
||||
Bot, _ = tgbot.NewTgBot(Conf.BotConfig.Tokens.Dev, chats, Conf.BotConfig.Allow)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user