From 6c2fc1b4c2ea9b5dd60e46a55de00beff28a3c15 Mon Sep 17 00:00:00 2001 From: DreamZero <79574799+Jiang-Red@users.noreply.github.com> Date: Wed, 9 Nov 2022 13:29:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E6=B3=A8=E5=86=8C=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=20(#491)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/ai_reply/ai_tts.go | 4 ++-- plugin/ai_reply/main.go | 9 ++------- plugin/atri/atri.go | 9 ++------- plugin/bilibili/bilibilipush.go | 15 +++++++-------- plugin/epidemic/epidemic.go | 7 ++----- plugin/guessmusic/main.go | 6 ++---- plugin/jikipedia/main.go | 12 +++++------- plugin/manager/manager.go | 6 +++--- plugin/wenxinAI/wenxinAI.go | 10 ++++------ 9 files changed, 29 insertions(+), 49 deletions(-) diff --git a/plugin/ai_reply/ai_tts.go b/plugin/ai_reply/ai_tts.go index caafde89..eeb4f46e 100644 --- a/plugin/ai_reply/ai_tts.go +++ b/plugin/ai_reply/ai_tts.go @@ -152,7 +152,7 @@ func newttsmode() *ttsmode { tts := &ttsmode{} tts.Lock() defer tts.Unlock() - m, ok := control.Lookup(ttsServiceName) + m, ok := control.Lookup("tts") tts.mode = make(map[int64]int64, 2*len(soundList)) tts.mode[-2905] = 1 if ok { @@ -229,7 +229,7 @@ func (tts *ttsmode) setDefaultSoundMode(name string) error { } tts.Lock() defer tts.Unlock() - m, ok := control.Lookup(ttsServiceName) + m, ok := control.Lookup("tts") if !ok { return errors.New("[tts] service not found") } diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index 756302fc..23acf9de 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -17,15 +17,10 @@ import ( "github.com/wdvxdr1123/ZeroBot/message" ) -const ( - replyServiceName = "aireply" - ttsServiceName = "tts" -) - var replyModes = [...]string{"青云客", "小爱"} func init() { // 插件主体 - enOftts := control.Register(ttsServiceName, &ctrl.Options[*zero.Ctx]{ + enOftts := control.Register("tts", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: true, Brief: "人工智能语音回复", Help: "- @Bot 任意文本(任意一句话回复)\n" + @@ -35,7 +30,7 @@ func init() { // 插件主体 "当前适用的原神人物含有以下:\n" + list(soundList[:], 5), }) tts := newttsmode() - enOfreply := control.Register(replyServiceName, &ctrl.Options[*zero.Ctx]{ + enOfreply := control.Register("aireply", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "人工智能回复", Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]", diff --git a/plugin/atri/atri.go b/plugin/atri/atri.go index 1c7d956f..71bfafd3 100644 --- a/plugin/atri/atri.go +++ b/plugin/atri/atri.go @@ -17,15 +17,10 @@ import ( "github.com/FloatTech/zbputils/control" ) -const ( - // 服务名 - servicename = "atri" - // ATRI 表情的 codechina 镜像 - res = "https://gitcode.net/u011570312/zbpdata/-/raw/main/Atri/" -) +const res = "https://gitcode.net/u011570312/zbpdata/-/raw/main/Atri/" func init() { // 插件主体 - engine := control.Register(servicename, &ctrl.Options[*zero.Ctx]{ + engine := control.Register("atri", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "atri人格文本回复", Help: "本插件基于 ATRI ,为 Golang 移植版\n" + diff --git a/plugin/bilibili/bilibilipush.go b/plugin/bilibili/bilibilipush.go index b54a5cbb..61fd1701 100644 --- a/plugin/bilibili/bilibilipush.go +++ b/plugin/bilibili/bilibilipush.go @@ -22,10 +22,9 @@ import ( ) const ( - ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36" - referer = "https://www.bilibili.com/" - infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%v" - serviceName = "bilibilipush" + ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36" + referer = "https://www.bilibili.com/" + infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%v" ) // bdb bilibili推送数据库 @@ -38,7 +37,7 @@ var ( ) func init() { - en := control.Register(serviceName, &ctrl.Options[*zero.Ctx]{ + en := control.Register("bilibilipush", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "b站推送", Help: "- 添加b站订阅[uid|name]\n" + @@ -49,7 +48,7 @@ func init() { "Tips: 需要配合job一起使用, 全局只需要设置一个, 无视响应状态推送, 下为例子\n" + "记录在\"@every 5m\"触发的指令)\n" + "拉取b站推送", - PrivateDataFolder: serviceName, + PrivateDataFolder: "bilibilipush", }) // 加载bilibili推送数据库 @@ -276,7 +275,7 @@ func sendDynamic(ctx *zero.Ctx) error { ct := cardList[i].Get("desc.timestamp").Int() if ct > t && ct > time.Now().Unix()-600 { lastTime[buid] = ct - m, ok := control.Lookup(serviceName) + m, ok := control.Lookup("bilibilipush") if ok { groupList := bdb.getAllGroupByBuidAndDynamic(buid) dc, err := bz.LoadDynamicDetail(cardList[i].Raw) @@ -325,7 +324,7 @@ func sendLive(ctx *zero.Ctx) error { oldStatus := liveStatus[key.Int()] if newStatus != oldStatus && newStatus == 1 { liveStatus[key.Int()] = newStatus - m, ok := control.Lookup(serviceName) + m, ok := control.Lookup("bilibilipush") if ok { groupList := bdb.getAllGroupByBuidAndLive(key.Int()) roomID := value.Get("short_id").Int() diff --git a/plugin/epidemic/epidemic.go b/plugin/epidemic/epidemic.go index de89fd97..c9545fbf 100644 --- a/plugin/epidemic/epidemic.go +++ b/plugin/epidemic/epidemic.go @@ -13,10 +13,7 @@ import ( "github.com/FloatTech/zbputils/ctxext" ) -const ( - servicename = "epidemic" - txurl = "https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?modules=statisGradeCityDetail,diseaseh5Shelf" -) +const txurl = "https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?modules=statisGradeCityDetail,diseaseh5Shelf" // result 疫情查询结果 type result struct { @@ -50,7 +47,7 @@ type area struct { } func init() { - engine := control.Register(servicename, &ctrl.Options[*zero.Ctx]{ + engine := control.Register("epidemic", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "城市疫情查询", Help: "- xxx疫情\n", diff --git a/plugin/guessmusic/main.go b/plugin/guessmusic/main.go index 0878294b..d9249c98 100644 --- a/plugin/guessmusic/main.go +++ b/plugin/guessmusic/main.go @@ -32,8 +32,6 @@ import ( "github.com/FloatTech/zbputils/img/text" ) -const servicename = "guessmusic" - var ( filelist []listinfo musictypelist = "mp3;MP3;wav;WAV;amr;AMR;3gp;3GP;3gpp;3GPP;acc;ACC" @@ -42,7 +40,7 @@ var ( ) func init() { // 插件主体 - engine := control.Register(servicename, &ctrl.Options[*zero.Ctx]{ + engine := control.Register("guessmusic", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "猜歌插件", Help: "由于不可抗因素无法获取网易云歌单内容, 插件改为本地猜歌了, 但保留了下歌功能\n" + @@ -74,7 +72,7 @@ func init() { // 插件主体 ) }), )) - serviceErr := "[" + servicename + "]" + serviceErr := "[guessmusic]" // 用于存放歌曲三个片段的文件夹 cachePath := engine.DataFolder() + "cache/" err := os.MkdirAll(cachePath, 0777) diff --git a/plugin/jikipedia/main.go b/plugin/jikipedia/main.go index 88ad7d9b..b50098f5 100644 --- a/plugin/jikipedia/main.go +++ b/plugin/jikipedia/main.go @@ -32,13 +32,11 @@ type value struct { func init() { // 初始化engine - engine := control.Register( - "jikipedia", - &ctrl.Options[*zero.Ctx]{ - DisableOnDefault: false, - Brief: "小鸡词典", - Help: "- [查梗|小鸡词典][梗]", - }, + engine := control.Register("jikipedia", &ctrl.Options[*zero.Ctx]{ + DisableOnDefault: false, + Brief: "小鸡词典", + Help: "- [查梗|小鸡词典][梗]", + }, ) engine.OnPrefixGroup([]string{"小鸡词典", "查梗"}).Limit(ctxext.LimitByGroup).SetBlock(true).Handle( func(ctx *zero.Ctx) { diff --git a/plugin/manager/manager.go b/plugin/manager/manager.go index e59a65cb..b64baeef 100644 --- a/plugin/manager/manager.go +++ b/plugin/manager/manager.go @@ -52,9 +52,9 @@ const ( "- 设置告别辞 参数同设置欢迎语\n" + "- 测试告别辞\n" + "- [开启 | 关闭]入群验证\n" + - "- 对信息回复:[设置 | 取消]精华" + - "- 取消精华 [信息ID]" + - "- /精华列表" + + "- 对信息回复:[设置 | 取消]精华\n" + + "- 取消精华 [信息ID]\n" + + "- /精华列表\n" + "Tips: {at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像 {uid}是被欢迎者QQ号 {gid}是当前群群号 {groupname} 是当前群群名" ) diff --git a/plugin/wenxinAI/wenxinAI.go b/plugin/wenxinAI/wenxinAI.go index a105409f..bf62b5e4 100644 --- a/plugin/wenxinAI/wenxinAI.go +++ b/plugin/wenxinAI/wenxinAI.go @@ -26,10 +26,8 @@ import ( ) const ( - serviceName = "wenxinvilg" - serviceErr = "[" + serviceName + "]ERROR:\n" - modelName = "wenxinmodel" - modelErr = "[" + modelName + "]ERROR:\n" + serviceErr = "[wenxinvilg]ERROR:\n" + modelErr = "[wenxinmodel]ERROR:\n" ) type keydb struct { @@ -69,7 +67,7 @@ func init() { // 插件主体 defer process.GlobalInitMutex.Unlock() name = zero.BotConfig.NickName[0] }() - engine := control.Register(serviceName, &ctrl.Options[*zero.Ctx]{ + engine := control.Register("wenxinvilg", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "文心AI画图", Help: "基于百度文心的免费AI画图插件,\n因为是免费的,图片质量你懂的。\n" + @@ -261,7 +259,7 @@ func init() { // 插件主体 ctx.SendChain(message.Text("成功!")) }) /*********************************************************/ - en := control.Register(modelName, &ctrl.Options[*zero.Ctx]{ + en := control.Register("wenxinmodel", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "文心AI文本处理", Help: "基于百度文心AI的API文本处理\n" +