️wordle逻辑优化,bilibilipush、translate添加信息 (#179)

* :sparkles:添加查成分功能

* :rotating_light:修lint

* :rotating_light:减少空格

* :bug:修改网址

* :bug:修改vup数量错误问题

* :bug:图片读取不了,就不读了

* 🐛 固定头像大小,bilibilipush调公有库

* 🎨 修改json转换

*  bilibilipush添加新类型,同时修改命令正则,wordle添加时间提醒,和单词语义,translate充实信息

* ️使用公用的翻译函数

* 🚨 添加return和stop

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
This commit is contained in:
himawari
2022-04-04 22:53:37 +08:00
committed by GitHub
parent ec513e8893
commit f89b6f5feb
4 changed files with 78 additions and 41 deletions

View File

@@ -2,14 +2,11 @@
package translation
import (
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/AnimeAPI/tl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/web"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
@@ -20,13 +17,11 @@ func init() {
}).OnRegex(`^>TL\s(-.{1,10}? )?(.*)$`).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
msg := []string{ctx.State["regex_matched"].([]string)[2]}
data, err := web.GetData("https://api.cloolc.club/fanyi?data=" + msg[0])
data, err := tl.Translate(msg[0])
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("Error:", data))
return
}
info := gjson.ParseBytes(data)
repo := info.Get("data.0")
process.SleepAbout1sTo2s()
ctx.SendChain(message.Text(repo.Get("value.0")))
ctx.SendChain(message.Text(data))
})
}