diff --git a/README.md b/README.md index fdf49ab1..e7586580 100644 --- a/README.md +++ b/README.md @@ -493,8 +493,6 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 教你一篇小作文[作文] - - [x] [回复]查重 -
漂流瓶 diff --git a/plugin/diana/bing.go b/plugin/diana/bing.go index 823550d7..282454a3 100644 --- a/plugin/diana/bing.go +++ b/plugin/diana/bing.go @@ -17,8 +17,7 @@ var engine = control.Register("diana", &ctrl.Options[*zero.Ctx]{ Help: "嘉然\n" + "- 小作文\n" + "- 发大病\n" + - "- 教你一篇小作文[作文]\n" + - "- [回复]查重", + "- 教你一篇小作文[作文]", PublicDataFolder: "Diana", }) diff --git a/plugin/diana/zhiwang.go b/plugin/diana/zhiwang.go deleted file mode 100644 index 088cdd34..00000000 --- a/plugin/diana/zhiwang.go +++ /dev/null @@ -1,89 +0,0 @@ -// Package diana 嘉然相关 -package diana - -import ( - "bytes" - "math" - "strings" - "time" - - "github.com/FloatTech/floatbox/binary" - "github.com/FloatTech/floatbox/web" - "github.com/FloatTech/zbputils/ctxext" - "github.com/tidwall/gjson" - "github.com/wdvxdr1123/ZeroBot/message" - - zero "github.com/wdvxdr1123/ZeroBot" -) - -// 小作文查重: 回复要查的消息 查重 -func init() { - engine.OnMessage(func(ctx *zero.Ctx) bool { - msg := ctx.Event.Message - if msg[0].Type != "reply" { - return false - } - for _, elem := range msg { - if elem.Type == "text" { - text := elem.Data["text"] - text = strings.ReplaceAll(text, " ", "") - text = strings.ReplaceAll(text, "\r", "") - text = strings.ReplaceAll(text, "\n", "") - if text == "查重" { - return true - } - } - } - return false - }).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { - msg := ctx.GetMessage(message.NewMessageIDFromString(ctx.Event.Message[0].Data["id"])).Elements[0].Data["text"] - result, err := zhiwangapi(msg) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - if result.Get("code").Int() != 0 { - ctx.SendChain(message.Text("api返回错误:", result.Get("code").Int())) - return - } - if result.Get("data.related.#").Int() == 0 { - ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("枝网没搜到,查重率为0%,鉴定为原创"))) - return - } - related := result.Get("data.related.0.reply").Map() - rate := result.Get("data.related.0.rate").Float() - relatedcontent := related["content"].String() - if len(relatedcontent) > 102 { - relatedcontent = relatedcontent[:102] + "....." - } - ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text( - "枝网文本复制检测报告(简洁)", "\n", - "查重时间: ", time.Now().Format("2006-01-02 15:04:05"), "\n", - "总文字复制比: ", math.Floor(rate*100), "%", "\n", - "相似小作文:", "\n", relatedcontent, "\n", - "获赞数:", related["like_num"].String(), "\n", - result.Get("data.related.0.reply_url").String(), "\n", - "作者: ", related["m_name"].String(), "\n", - "发表时间: ", time.Unix(int64(related["ctime"].Float()), 0).Format("2006-01-02 15:04:05"), "\n", - "查重结果仅作参考,请注意辨别是否为原创", "\n", - "数据来源: https://asoulcnki.asia/", - ))) - }) -} - -func zhiwangapi(text string) (*gjson.Result, error) { - b, cl := binary.OpenWriterF(func(w *binary.Writer) { - w.WriteString("{\n\"text\":\"") - w.WriteString(text) - w.WriteString("\"\n}") - }) - - data, err := web.PostData("https://asoulcnki.asia/v1/api/check", "application/json", bytes.NewReader(b)) - cl() - if err != nil { - return nil, err - } - - result := gjson.ParseBytes(data) - return &result, nil -} diff --git a/plugin/gif/gif.go b/plugin/gif/gif.go index 261576a3..18ffa118 100644 --- a/plugin/gif/gif.go +++ b/plugin/gif/gif.go @@ -1,13 +1,16 @@ package gif import ( + "errors" "image" "image/color" "sync" "github.com/Coloured-glaze/gg" + "github.com/FloatTech/floatbox/file" "github.com/FloatTech/floatbox/img/writer" "github.com/FloatTech/zbputils/img" + "github.com/FloatTech/zbputils/img/text" ) // mo 摸 @@ -1394,3 +1397,52 @@ func whirl(cc *context, value ...string) (string, error) { } return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, whirl)) } + +// always 一直 +func alwaysDoGif(cc *context, value ...string) (string, error) { + _ = value + var err error + var face []*image.NRGBA + name := cc.usrdir + "AlwaysDo.gif" + face, err = img.LoadAllFrames(cc.headimgsdir[0], 500, 500) + if err != nil { + // 载入失败尝试载入第一帧 + face = make([]*image.NRGBA, 0) + first, err := img.LoadFirstFrame(cc.headimgsdir[0], 500, 500) + if err != nil { + return "", err + } + face = append(face, first.Im) + } + canvas := gg.NewContext(500, 600) + canvas.SetColor(color.Black) + _, err = file.GetLazyData(text.BoldFontFile, true) + if err != nil { + return "", err + } + err = canvas.LoadFontFace(text.BoldFontFile, 40) + if err != nil { + return "", err + } + length := len(face) + if length > 50 { + length = 50 + } + arg := "要我一直" + l, _ := canvas.MeasureString(arg) + if l > 500 { + return "", errors.New("文字消息太长了") + } + turn := make([]*image.NRGBA, length) + for i, f := range face { + canvas := gg.NewContext(500, 600) + canvas.DrawImage(f, 0, 0) + canvas.SetColor(color.Black) + _ = canvas.LoadFontFace(text.BoldFontFile, 40) + canvas.DrawString(arg, 280-l, 560) + canvas.DrawImage(img.Size(f, 90, 90).Im, 280, 505) + canvas.DrawString("吗", 370, 560) + turn[i] = img.Size(canvas.Image(), 0, 0).Im + } + return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, turn)) +} diff --git a/plugin/gif/run.go b/plugin/gif/run.go index c463a450..b92f372a 100644 --- a/plugin/gif/run.go +++ b/plugin/gif/run.go @@ -118,6 +118,7 @@ var ( "我老婆": nowife, "远离": yuanli, "抬棺": taiguan, + "一直": alwaysDoGif, } ) @@ -140,7 +141,7 @@ func init() { // 插件主体 "- 抬棺|- 远离|- 我老婆|- 小天使XXX|- 你的XXX|- 不要看\n" + "- 玩一下XXX|- 给我变|- 揍|- 吞|- 膜拜|- 诶嘿|- 2蹭|- 你犯法了\n" + "- 砰|- 注意力涣散|- 蒙蔽|- 踩|- 好玩|- 2转|- 踢球|- 2舔|\n" + - "- 可莉吃|- 胡桃啃|- 怀", + "- 可莉吃|- 胡桃啃|- 怀|- 一直(支持动图)", PrivateDataFolder: "gif", }).ApplySingle(ctxext.DefaultSingle) datapath = file.BOTPATH + "/" + en.DataFolder() diff --git a/plugin/tarot/tarot.go b/plugin/tarot/tarot.go index ef7f8be4..fab90556 100644 --- a/plugin/tarot/tarot.go +++ b/plugin/tarot/tarot.go @@ -3,7 +3,6 @@ package tarot import ( "encoding/json" - "fmt" "math/rand" "strconv" "strings" @@ -71,7 +70,6 @@ func init() { infoMap[card.Name] = card.cardInfo } for i := 0; i < 22; i++ { - // 噢天哪,我应该把json里面序号设成int majorArcanaName = append(majorArcanaName, cardMap[strconv.Itoa(i)].Name) } logrus.Infof("[tarot]读取%d张塔罗牌", len(cardMap)) @@ -95,9 +93,9 @@ func init() { match := ctx.State["regex_matched"].([]string)[1] cardType := ctx.State["regex_matched"].([]string)[2] n := 1 - reasons := [...]string{"您抽到的是~\n『", "锵锵锵,塔罗牌的预言是~\n『", "诶,让我看看您抽到了~\n『"} - position := [...]string{"正位", "逆位"} - reverse := [...]string{"", "Reverse"} + reasons := [...]string{"您抽到的是~\n", "锵锵锵,塔罗牌的预言是~\n", "诶,让我看看您抽到了~\n"} + position := [...]string{"『正位』", "『逆位』"} + reverse := [...]string{"", "Reverse/"} start := 0 length := 22 if match != "" { @@ -129,9 +127,14 @@ func init() { p := rand.Intn(2) card := cardMap[strconv.Itoa(i)] name := card.Name + description := card.Description + if p == 1 { + description = card.ReverseDescription + } if id := ctx.SendChain( - message.Text(reasons[rand.Intn(len(reasons))], position[p], "』的『", name, "』\n"), - message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))); id.ID() == 0 { + message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n"), + message.Image(bed+reverse[p]+card.ImgURL), + message.Text("\n其释义为: ", description)); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } return @@ -149,9 +152,14 @@ func init() { p := rand.Intn(2) card := cardMap[strconv.Itoa(j+start)] name := card.Name + description := card.Description + if p == 1 { + description = card.ReverseDescription + } tarotMsg := []message.MessageSegment{ - message.Text(reasons[rand.Intn(len(reasons))], position[p], "』的『", name, "』\n"), - message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))} + message.Text(position[p], "的『", name, "』\n"), + message.Image(bed + reverse[p] + card.ImgURL), + message.Text("\n其释义为: ", description)} msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotMsg...) } ctx.SendGroupForwardMessage(ctx.Event.GroupID, msg) @@ -164,8 +172,8 @@ func init() { ctx.SendChain( message.Image(bed+info.ImgURL), message.Text("\n", match, "的含义是~"), - message.Text("\n正位:", info.Description), - message.Text("\n逆位:", info.ReverseDescription)) + message.Text("\n『正位』:", info.Description), + message.Text("\n『逆位』:", info.ReverseDescription)) } else { var build strings.Builder build.WriteString("塔罗牌列表\n大阿尔卡纳:\n") @@ -188,8 +196,8 @@ func init() { cardType := ctx.State["regex_matched"].([]string)[1] match := ctx.State["regex_matched"].([]string)[5] info, ok := formationMap[match] - position := [...]string{"正位", "逆位"} - reverse := [...]string{"", "Reverse"} + position := [...]string{"『正位』", "『逆位』"} + reverse := [...]string{"", "Reverse/"} start, length := 0, 22 if strings.Contains(cardType, "小") { start = 22 @@ -222,11 +230,11 @@ func init() { if p == 1 { description = card.ReverseDescription } - tarotMsg := []message.MessageSegment{message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))} + tarotMsg := []message.MessageSegment{message.Image(bed + reverse[p] + card.ImgURL)} build.WriteString(info.Represent[0][i]) - build.WriteString(":『") + build.WriteString(":") build.WriteString(position[p]) - build.WriteString("』的『") + build.WriteString("的『") build.WriteString(name) build.WriteString("』\n其释义为: \n") build.WriteString(description)