mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
* ✨添加查成分功能 * 🚨修lint * 🚨减少空格 * 🐛修改网址 * 🐛修改vup数量错误问题 * 🐛图片读取不了,就不读了 * 🐛 固定头像大小,bilibilipush调公有库 * 🎨 修改json转换 * ✨ bilibilipush添加新类型,同时修改命令正则,wordle添加时间提醒,和单词语义,translate充实信息 * ⚡️使用公用的翻译函数 * 🚨 添加return和stop Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
28 lines
735 B
Go
28 lines
735 B
Go
// Package translation 翻译
|
|
package translation
|
|
|
|
import (
|
|
"github.com/FloatTech/AnimeAPI/tl"
|
|
control "github.com/FloatTech/zbputils/control"
|
|
"github.com/FloatTech/zbputils/ctxext"
|
|
zero "github.com/wdvxdr1123/ZeroBot"
|
|
"github.com/wdvxdr1123/ZeroBot/message"
|
|
)
|
|
|
|
func init() {
|
|
control.Register("translation", &control.Options{
|
|
DisableOnDefault: false,
|
|
Help: "翻译\n" +
|
|
">TL 你好",
|
|
}).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 := tl.Translate(msg[0])
|
|
if err != nil {
|
|
ctx.SendChain(message.Text("Error:", data))
|
|
return
|
|
}
|
|
ctx.SendChain(message.Text(data))
|
|
})
|
|
}
|