diff --git a/README.md b/README.md index 354581f8..ef04b758 100644 --- a/README.md +++ b/README.md @@ -356,11 +356,11 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] [ 以图绘图 | 以图生图 | 以图画图 ] xxx [图片]|@xxx|[qq号] - - [ ] 设置ai绘图配置 [server] [token] + - [x] 设置ai绘图配置 [server] [token] - 例1: 设置ai绘图配置 http://91.216.169.75:5010 abc + 例: 设置ai绘图配置 http://91.216.169.75:5010 abc - 例2: 设置ai绘图配置 http://91.217.139.190:5010 abc + 参考服务器 http://91.217.139.190:5010, http://91.216.169.75:5010, http://185.80.202.180:5010 通过 http://91.217.139.190:5010/token 获取token @@ -962,6 +962,8 @@ print("run[CQ:image,file="+j["img"]+"]") `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/nihongo"` - [x] 日语语法 [xxx] (使用tag随机) + + - [x] 搜索日语语法 [xxx]
diff --git a/plugin/aipaint/aipaint.go b/plugin/aipaint/aipaint.go index 38d2445d..93839a98 100644 --- a/plugin/aipaint/aipaint.go +++ b/plugin/aipaint/aipaint.go @@ -12,6 +12,7 @@ import ( "regexp" "strconv" "strings" + "time" "github.com/FloatTech/floatbox/binary" "github.com/FloatTech/floatbox/file" @@ -54,8 +55,8 @@ func init() { // 插件主体 "- [ ai绘图 | 生成色图 | 生成涩图 | ai画图 ] xxx\n" + "- [ 以图绘图 | 以图生图 | 以图画图 ] xxx [图片]|@xxx|[qq号]\n" + "- 设置ai绘图配置 [server] [token]\n" + - "例1: 设置ai绘图配置 http://91.216.169.75:5010 abc\n" + - "例2: 设置ai绘图配置 http://91.217.139.190:5010 abc\n" + + "例: 设置ai绘图配置 http://91.217.139.190:5010 abc\n" + + "参考服务器 http://91.217.139.190:5010, http://91.216.169.75:5010, http://185.80.202.180:5010" + "通过 http://91.217.139.190:5010/token 获取token", PrivateDataFolder: "aipaint", }) @@ -161,7 +162,13 @@ func sendAiImg(ctx *zero.Ctx, data []byte) { encodeStr := base64.StdEncoding.EncodeToString(data) m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Image("base64://"+encodeStr))} m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(r.String()))) - if id := ctx.Send(m).ID(); id == 0 { + if mid := ctx.Send(m); mid.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待")) + } else { + go func(i message.MessageID) { + time.Sleep(90 * time.Second) + ctx.DeleteMessage(i) + }(mid) } + } diff --git a/plugin/nihongo/model.go b/plugin/nihongo/model.go index 5c254edb..d843ea77 100644 --- a/plugin/nihongo/model.go +++ b/plugin/nihongo/model.go @@ -25,6 +25,11 @@ func (g *grammar) string() string { var db = &sql.Sqlite{} func getRandomGrammarByTag(tag string) (g grammar) { - _ = db.Find("grammar", &g, "where tag LIKE '%"+tag+"%' ORDER BY RANDOM() limit 1") + _ = db.Find("grammar", &g, "WHERE tag LIKE '%"+tag+"%' ORDER BY RANDOM() limit 1") + return +} + +func getRandomGrammarByKeyword(keyword string) (g grammar) { + _ = db.Find("grammar", &g, "WHERE (name LIKE '%"+keyword+"%' or pronunciation LIKE '%"+keyword+"%') ORDER BY RANDOM() limit 1") return } diff --git a/plugin/nihongo/nihongo.go b/plugin/nihongo/nihongo.go index 86acd447..9620370e 100644 --- a/plugin/nihongo/nihongo.go +++ b/plugin/nihongo/nihongo.go @@ -17,7 +17,8 @@ import ( func init() { engine := control.Register("nihongo", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, - Help: "日语学习\n- 日语语法[xxx](使用tag随机)", + Help: "日语学习\n- 日语语法[xxx](使用tag随机)\n" + + "搜索日语语法[xxx]", PublicDataFolder: "Nihongo", }) @@ -47,7 +48,7 @@ func init() { return true }) - engine.OnRegex(`^日语语法\s?([0-9A-Za-zぁ-んァ-ヶ]{1,6})$`, getdb).SetBlock(true). + engine.OnRegex(`^日语语法\s?([0-9A-Za-zぁ-んァ-ヶ~]{1,6})$`, getdb).SetBlock(true). Handle(func(ctx *zero.Ctx) { g := getRandomGrammarByTag(ctx.State["regex_matched"].([]string)[1]) if g.ID == 0 { @@ -63,4 +64,20 @@ func init() { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } }) + engine.OnRegex(`^搜索日语语法\s?([0-9A-Za-zぁ-んァ-ヶ~]{1,25})$`, getdb).SetBlock(true). + Handle(func(ctx *zero.Ctx) { + g := getRandomGrammarByKeyword(ctx.State["regex_matched"].([]string)[1]) + if g.ID == 0 { + ctx.SendChain(message.Text("未能找到", ctx.State["regex_matched"].([]string)[1], "相关标签的语法")) + return + } + data, err := text.RenderToBase64(g.string(), text.FontFile, 400, 20) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 { + ctx.SendChain(message.Text("ERROR: 可能被风控了")) + } + }) } diff --git a/plugin/shadiao/shadiao.go b/plugin/shadiao/shadiao.go index 039923c4..d73d0639 100644 --- a/plugin/shadiao/shadiao.go +++ b/plugin/shadiao/shadiao.go @@ -12,15 +12,16 @@ import ( ) const ( - chpURL = "https://api.shadiao.app/chp" - duURL = "https://api.shadiao.app/du" - pyqURL = "https://api.shadiao.app/pyq" + shadiaoURL = "https://api.shadiao.pro" + chpURL = shadiaoURL + "/chp" + duURL = shadiaoURL + "/du" + pyqURL = shadiaoURL + "/pyq" yduanziURL = "http://www.yduanzi.com/duanzi/getduanzi" chayiURL = "https://api.lovelive.tools/api/SweetNothings/Web/0" ganhaiURL = "https://api.lovelive.tools/api/SweetNothings/Web/1" ergofabulousURL = "https://ergofabulous.org/luther/?" ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36" - sdReferer = "https://api.shadiao.app/" + sdReferer = shadiaoURL yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app" loveliveReferer = "https://lovelive.tools/" )