diff --git a/go.mod b/go.mod index e318aa3a..9cd2399f 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module github.com/FloatTech/ZeroBot-Plugin go 1.17 require ( - github.com/FloatTech/AnimeAPI v1.2.5-beta14 - github.com/FloatTech/zbputils v1.2.5-beta12 + github.com/FloatTech/AnimeAPI v1.2.5 + github.com/FloatTech/sqlite v0.1.0 + github.com/FloatTech/zbputils v1.2.5 github.com/antchfx/htmlquery v1.2.4 github.com/corona10/goimagehash v1.0.3 github.com/fogleman/gg v1.3.0 @@ -46,7 +47,7 @@ require ( github.com/yusufpapurcu/wmi v1.2.2 // indirect golang.org/x/mod v0.5.1 // indirect golang.org/x/net v0.0.0-20220111093109-d55c255bac03 // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect + golang.org/x/sys v0.0.0-20220207234003-57398862261d // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/tools v0.1.9 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect @@ -57,7 +58,7 @@ require ( modernc.org/mathutil v1.4.1 // indirect modernc.org/memory v1.0.5 // indirect modernc.org/opt v0.1.1 // indirect - modernc.org/sqlite v1.14.5 // indirect + modernc.org/sqlite v1.14.6 // indirect modernc.org/strutil v1.1.1 // indirect modernc.org/token v1.0.0 // indirect ) diff --git a/go.sum b/go.sum index 523f8f45..01426809 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,10 @@ -github.com/FloatTech/AnimeAPI v1.2.5-beta14 h1:CyP0YTrSkXgOAmunr9s5TpVoZxhc5Nrz6tkKv+avUNk= -github.com/FloatTech/AnimeAPI v1.2.5-beta14/go.mod h1:jsUR1c9voZPgBZybMEZl+LpnOtKZFhN9NZKMvHjbT6M= +github.com/FloatTech/AnimeAPI v1.2.5 h1:X0NLJSl9o63vRwGRPn/XiojOOBqZRbY94TxPEvhiVRo= +github.com/FloatTech/AnimeAPI v1.2.5/go.mod h1:nJpebBjTNUpr4cV0bR0Xu54/SP78+iN7hJ2EfQWbM7M= github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ= -github.com/FloatTech/zbputils v1.2.5-beta12 h1:+MtcwLP5/IaLAX3dMOzHFbv5cNBLlb5BRk2LNFAfEF0= -github.com/FloatTech/zbputils v1.2.5-beta12/go.mod h1:1j71Sna0RnprP3ywDNTblRzITNYCb2FGN2yxl1G4zg0= +github.com/FloatTech/sqlite v0.1.0 h1:Geh6Z+DWZXmyXVOhM0U2oXT7b1Ob6sQtuyjInk+MCUk= +github.com/FloatTech/sqlite v0.1.0/go.mod h1:XS0oeSqtH6lFzpPRiDE9fV6+zMcuUF5/6o+tQVO1QZE= +github.com/FloatTech/zbputils v1.2.5 h1:/JyN6ear5PPpBjrjQEQT0/8mPBMJYBswLiNIzfmGYU8= +github.com/FloatTech/zbputils v1.2.5/go.mod h1:e9e8998yQkzS24IqZ8jLUssTk607hD/Tj3zGyBikIIc= github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb h1:Rkj28fqIwGx/EgBzRYtpmJRfH6wqVn7cNdc7aJ0QE4M= github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= @@ -225,8 +227,8 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220207234003-57398862261d h1:Bm7BNOQt2Qv7ZqysjeLjgCBanX+88Z/OtdvsrEv1Djc= +golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -318,7 +320,6 @@ modernc.org/ccgo/v3 v3.12.86/go.mod h1:dN7S26DLTgVSni1PVA3KxxHTcykyDurf3OgUzNqTS modernc.org/ccgo/v3 v3.12.90/go.mod h1:obhSc3CdivCRpYZmrvO88TXlW0NvoSVvdh/ccRjJYko= modernc.org/ccgo/v3 v3.12.92/go.mod h1:5yDdN7ti9KWPi5bRVWPl8UNhpEAtCjuEE7ayQnzzqHA= modernc.org/ccgo/v3 v3.13.1/go.mod h1:aBYVOUfIlcSnrsRVU8VRS35y2DIfpgkmVkYZ0tpIXi4= -modernc.org/ccgo/v3 v3.14.0/go.mod h1:hBrkiBlUwvr5vV/ZH9YzXIp982jKE8Ek8tR1ytoAL6Q= modernc.org/ccgo/v3 v3.15.1/go.mod h1:md59wBwDT2LznX/OTCPoVS6KIsdRgY8xqQwBV+hkTH0= modernc.org/ccgo/v3 v3.15.9/go.mod h1:md59wBwDT2LznX/OTCPoVS6KIsdRgY8xqQwBV+hkTH0= modernc.org/ccgo/v3 v3.15.10/go.mod h1:wQKxoFn0ynxMuCLfFD09c8XPUCc8obfchoVR9Cn0fI8= @@ -368,8 +369,6 @@ modernc.org/libc v1.11.88/go.mod h1:h3oIVe8dxmTcchcFuCcJ4nAWaoiwzKCdv82MM0oiIdQ= modernc.org/libc v1.11.98/go.mod h1:ynK5sbjsU77AP+nn61+k+wxUGRx9rOFcIqWYYMaDZ4c= modernc.org/libc v1.11.101/go.mod h1:wLLYgEiY2D17NbBOEp+mIJJJBGSiy7fLL4ZrGGZ+8jI= modernc.org/libc v1.12.0/go.mod h1:2MH3DaF/gCU8i/UBiVE1VFRos4o523M7zipmwH8SIgQ= -modernc.org/libc v1.13.1/go.mod h1:npFeGWjmZTjFeWALQLrvklVmAxv4m80jnG3+xI8FdJk= -modernc.org/libc v1.13.2/go.mod h1:npFeGWjmZTjFeWALQLrvklVmAxv4m80jnG3+xI8FdJk= modernc.org/libc v1.14.1/go.mod h1:npFeGWjmZTjFeWALQLrvklVmAxv4m80jnG3+xI8FdJk= modernc.org/libc v1.14.2/go.mod h1:MX1GBLnRLNdvmK9azU9LCxZ5lMyhrbEMK8rG3X/Fe34= modernc.org/libc v1.14.3/go.mod h1:GPIvQVOVPizzlqyRX3l756/3ppsAgg1QgPxjr5Q4agQ= @@ -385,12 +384,11 @@ modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14= modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM= modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.14.5 h1:bYrrjwH9Y7QUGk1MbchZDhRfmpGuEAs/D45sVjNbfvs= -modernc.org/sqlite v1.14.5/go.mod h1:YyX5Rx0WbXokitdWl2GJIDy4BrPxBP0PwwhpXOHCDLE= +modernc.org/sqlite v1.14.6 h1:Jt5P3k80EtDBWaq1beAxnWW+5MdHXbZITujnRS7+zWg= +modernc.org/sqlite v1.14.6/go.mod h1:yiCvMv3HblGmzENNIaNtFhfaNIwcla4u2JQEwJPzfEc= modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs= modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= -modernc.org/tcl v1.10.0/go.mod h1:WzWapmP/7dHVhFoyPpEaNSVTL8xtewhouN/cqSJ5A2s= +modernc.org/tcl v1.11.0/go.mod h1:zsTUpbQ+NxQEjOjCUlImDLPv1sG8Ww0qp66ZvyOxCgw= modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= -modernc.org/z v1.2.21/go.mod h1:uXrObx4pGqXWIMliC5MiKuwAyMrltzwpteOFUP1PWCc= modernc.org/z v1.3.0/go.mod h1:+mvgLH814oDjtATDdT3rs84JnUIpkvAF5B8AVkNlE2g= diff --git a/plugin_bilibili_push/bilibili_push.go b/plugin_bilibili_push/bilibili_push.go index b985cdae..87248f5e 100644 --- a/plugin_bilibili_push/bilibili_push.go +++ b/plugin_bilibili_push/bilibili_push.go @@ -12,7 +12,7 @@ import ( "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" - "github.com/FloatTech/zbputils/txt2img" + "github.com/FloatTech/zbputils/img/text" "github.com/FloatTech/zbputils/web" log "github.com/sirupsen/logrus" "github.com/tidwall/gjson" @@ -198,7 +198,7 @@ func init() { } msg += " up主:" + upMap[v.BilibiliUID] } - data, err := txt2img.RenderToBase64(msg, txt2img.FontFile, 600, 20) + data, err := text.RenderToBase64(msg, text.FontFile, 600, 20) if err != nil { log.Errorln("[bilibilipush]:", err) } diff --git a/plugin_book_review/book_review.go b/plugin_book_review/book_review.go index 3a55426f..381c2a6a 100644 --- a/plugin_book_review/book_review.go +++ b/plugin_book_review/book_review.go @@ -8,7 +8,7 @@ import ( "github.com/wdvxdr1123/ZeroBot/utils/helper" "github.com/FloatTech/zbputils/control" - "github.com/FloatTech/zbputils/txt2img" + "github.com/FloatTech/zbputils/img/text" "github.com/FloatTech/ZeroBot-Plugin/order" ) @@ -23,7 +23,7 @@ func init() { engine.OnRegex("^书评([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true). Handle(func(ctx *zero.Ctx) { b := getBookReviewByKeyword(ctx.State["regex_matched"].([]string)[1]) - data, err := txt2img.RenderToBase64(b.BookReview, txt2img.FontFile, 400, 20) + data, err := text.RenderToBase64(b.BookReview, text.FontFile, 400, 20) if err != nil { log.Println("err:", err) } @@ -35,7 +35,7 @@ func init() { engine.OnFullMatch("随机书评").SetBlock(true). Handle(func(ctx *zero.Ctx) { br := getRandomBookReview() - data, err := txt2img.RenderToBase64(br.BookReview, txt2img.FontFile, 400, 20) + data, err := text.RenderToBase64(br.BookReview, text.FontFile, 400, 20) if err != nil { log.Println("err:", err) } diff --git a/plugin_book_review/data.go b/plugin_book_review/data.go index 44254784..8c91d2fd 100644 --- a/plugin_book_review/data.go +++ b/plugin_book_review/data.go @@ -5,9 +5,9 @@ import ( log "github.com/sirupsen/logrus" + sql "github.com/FloatTech/sqlite" "github.com/FloatTech/zbputils/file" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/sql" "github.com/FloatTech/ZeroBot-Plugin/order" ) diff --git a/plugin_chouxianghua/data.go b/plugin_chouxianghua/data.go index e8d77758..e959d407 100644 --- a/plugin_chouxianghua/data.go +++ b/plugin_chouxianghua/data.go @@ -5,9 +5,9 @@ import ( log "github.com/sirupsen/logrus" + sql "github.com/FloatTech/sqlite" "github.com/FloatTech/zbputils/file" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/sql" "github.com/FloatTech/ZeroBot-Plugin/order" ) diff --git a/plugin_cpstory/data.go b/plugin_cpstory/data.go index 105d4298..59ec5479 100644 --- a/plugin_cpstory/data.go +++ b/plugin_cpstory/data.go @@ -5,9 +5,9 @@ import ( log "github.com/sirupsen/logrus" + sql "github.com/FloatTech/sqlite" "github.com/FloatTech/zbputils/file" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/sql" "github.com/FloatTech/ZeroBot-Plugin/order" ) diff --git a/plugin_curse/data.go b/plugin_curse/data.go index 4fe1d028..ddeb10bd 100644 --- a/plugin_curse/data.go +++ b/plugin_curse/data.go @@ -5,9 +5,9 @@ import ( "github.com/sirupsen/logrus" + sql "github.com/FloatTech/sqlite" "github.com/FloatTech/zbputils/file" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/sql" "github.com/FloatTech/ZeroBot-Plugin/order" ) diff --git a/plugin_danbooru/main.go b/plugin_danbooru/main.go index 1d2c8cf2..abc0dc15 100644 --- a/plugin_danbooru/main.go +++ b/plugin_danbooru/main.go @@ -11,6 +11,7 @@ import ( "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" "github.com/FloatTech/zbputils/file" + "github.com/FloatTech/zbputils/img/writer" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" "github.com/wdvxdr1123/ZeroBot/utils/helper" @@ -51,7 +52,7 @@ func init() { // 插件主体 digest := md5.Sum(helper.StringToBytes(url)) f := cachefile + hex.EncodeToString(digest[:]) if file.IsNotExist(f) { - _ = t.Canvas.SavePNG(f) + _ = writer.SavePNG2Path(f, t) } ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + f)) } diff --git a/plugin_diana/data/text.go b/plugin_diana/data/text.go index bc01dced..3eb60644 100644 --- a/plugin_diana/data/text.go +++ b/plugin_diana/data/text.go @@ -9,9 +9,9 @@ import ( log "github.com/sirupsen/logrus" "github.com/wdvxdr1123/ZeroBot/utils/helper" + sql "github.com/FloatTech/sqlite" "github.com/FloatTech/zbputils/file" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/sql" "github.com/FloatTech/ZeroBot-Plugin/order" ) diff --git a/plugin_fortune/fortune.go b/plugin_fortune/fortune.go index dd10efd6..91f86d59 100644 --- a/plugin_fortune/fortune.go +++ b/plugin_fortune/fortune.go @@ -22,9 +22,9 @@ import ( control "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" "github.com/FloatTech/zbputils/file" + "github.com/FloatTech/zbputils/img/writer" "github.com/FloatTech/zbputils/imgpool" "github.com/FloatTech/zbputils/math" - "github.com/FloatTech/zbputils/txt2img" "github.com/FloatTech/ZeroBot-Plugin/order" ) @@ -218,7 +218,7 @@ func randtext(seed int64) (string, string) { // @param title 签名 // @param text 签文 // @return 错误信息 -func draw(back image.Image, title, text string, f io.Writer) (int64, error) { +func draw(back image.Image, title, txt string, f io.Writer) (int64, error) { canvas := gg.NewContext(back.Bounds().Size().Y, back.Bounds().Size().X) canvas.DrawImage(back, 0, 0) // 写标题 @@ -235,7 +235,7 @@ func draw(back image.Image, title, text string, f io.Writer) (int64, error) { } tw, th := canvas.MeasureString("测") tw, th = tw+10, th+10 - r := []rune(text) + r := []rune(txt) xsum := rowsnum(len(r), 9) switch xsum { default: @@ -259,7 +259,7 @@ func draw(back image.Image, title, text string, f io.Writer) (int64, error) { } } } - return txt2img.TxtCanvas{Canvas: canvas}.WriteTo(f) + return writer.WriteTo(canvas.Image(), f) } func offest(total, now int, distance float64) float64 { diff --git a/plugin_funny/data_test.go b/plugin_funny/data_test.go index 1a121f14..75fa7172 100644 --- a/plugin_funny/data_test.go +++ b/plugin_funny/data_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/FloatTech/zbputils/sql" + sql "github.com/FloatTech/sqlite" "github.com/wdvxdr1123/ZeroBot/utils/helper" ) diff --git a/plugin_funny/laugh.go b/plugin_funny/laugh.go index 636ac222..1c125bc7 100644 --- a/plugin_funny/laugh.go +++ b/plugin_funny/laugh.go @@ -7,9 +7,9 @@ import ( zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" + sql "github.com/FloatTech/sqlite" control "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" - "github.com/FloatTech/zbputils/sql" "github.com/FloatTech/ZeroBot-Plugin/order" ) diff --git a/plugin_gif/gif.go b/plugin_gif/gif.go index a95fde8a..64a6e27d 100644 --- a/plugin_gif/gif.go +++ b/plugin_gif/gif.go @@ -4,6 +4,7 @@ import ( "image" "github.com/FloatTech/zbputils/img" + "github.com/FloatTech/zbputils/img/writer" ) // 摸 @@ -18,7 +19,7 @@ func (cc *context) mo() string { img.LoadFirstFrame(*<-(*c)[3], 0, 0).InsertBottom(tou, 85, 75, 27, 37).Im, img.LoadFirstFrame(*<-(*c)[4], 0, 0).InsertBottom(tou, 90, 70, 22, 42).Im, } - _ = img.SaveGif(img.MergeGif(1, mo), name) + _ = writer.SaveGIF2Path(name, img.MergeGif(1, mo)) return "file:///" + name } @@ -38,7 +39,7 @@ func (cc *context) cuo() string { img.LoadFirstFrame(*<-(*c)[3], 0, 0).InsertBottomC(m3.Im, 0, 0, 75, 130).Im, img.LoadFirstFrame(*<-(*c)[4], 0, 0).InsertBottomC(m4.Im, 0, 0, 75, 130).Im, } - _ = img.SaveGif(img.MergeGif(5, cuo), name) + _ = writer.SaveGIF2Path(name, img.MergeGif(5, cuo)) return "file:///" + name } @@ -51,7 +52,7 @@ func (cc *context) qiao() string { img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 40, 33, 57, 52).Im, img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertUp(tou, 38, 36, 58, 50).Im, } - _ = img.SaveGif(img.MergeGif(1, qiao), name) + _ = writer.SaveGIF2Path(name, img.MergeGif(1, qiao)) return "file:///" + name } @@ -65,7 +66,7 @@ func (cc *context) chi() string { img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertBottom(tou, 0, 0, 1, 38).Im, img.LoadFirstFrame(*<-(*c)[2], 0, 0).InsertBottom(tou, 0, 0, 1, 38).Im, } - _ = img.SaveGif(img.MergeGif(1, chi), name) + _ = writer.SaveGIF2Path(name, img.MergeGif(1, chi)) return "file:///" + name } @@ -83,7 +84,7 @@ func (cc *context) ceng() string { img.LoadFirstFrame(*<-(*c)[4], 0, 0).InsertUp(tou, 75, 77, 56, 110).InsertUp(img.Rotate(tou2, -66, 132, 80).Im, 0, 0, 78, 40).Im, img.LoadFirstFrame(*<-(*c)[5], 0, 0).InsertUp(tou, 75, 77, 62, 102).InsertUp(tou2, 71, 100, 110, 94).Im, } - _ = img.SaveGif(img.MergeGif(8, ceng), name) + _ = writer.SaveGIF2Path(name, img.MergeGif(8, ceng)) return "file:///" + name } @@ -110,7 +111,7 @@ func (cc *context) ken() string { img.LoadFirstFrame(*<-(*c)[14], 0, 0).Im, img.LoadFirstFrame(*<-(*c)[15], 0, 0).Im, } - _ = img.SaveGif(img.MergeGif(7, ken), name) + _ = writer.SaveGIF2Path(name, img.MergeGif(7, ken)) return "file:///" + name } @@ -123,7 +124,7 @@ func (cc *context) pai() string { img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 0, 0, 1, 47).Im, img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertUp(tou, 0, 0, 1, 67).Im, } - _ = img.SaveGif(img.MergeGif(1, pai), name) + _ = writer.SaveGIF2Path(name, img.MergeGif(1, pai)) return "file:///" + name } @@ -136,7 +137,7 @@ func (cc *context) chong() string { img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 30, 30, 15, 53).Im, img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertUp(tou, 30, 30, 40, 53).Im, } - _ = img.SaveGif(img.MergeGif(1, chong), name) + _ = writer.SaveGIF2Path(name, img.MergeGif(1, chong)) return "file:///" + name } @@ -155,6 +156,6 @@ func (cc *context) diu() string { img.LoadFirstFrame(*<-(*c)[6], 0, 0).InsertUp(tou, 35, 35, 259, 31).Im, img.LoadFirstFrame(*<-(*c)[7], 0, 0).InsertUp(tou, 175, 175, -50, 220).Im, } - _ = img.SaveGif(img.MergeGif(7, diu), name) + _ = writer.SaveGIF2Path(name, img.MergeGif(7, diu)) return "file:///" + name } diff --git a/plugin_gif/png.go b/plugin_gif/png.go index 52dcc1de..198dd554 100644 --- a/plugin_gif/png.go +++ b/plugin_gif/png.go @@ -6,6 +6,7 @@ import ( "strconv" "github.com/FloatTech/zbputils/img" + "github.com/FloatTech/zbputils/img/writer" ) // 爬 @@ -16,7 +17,7 @@ func (cc *context) pa() string { rand := rand.Intn(60) + 1 dc := img.LoadFirstFrame(dlblock(`pa/`+strconv.Itoa(rand)+`.png`), 0, 0). InsertBottom(tou, 100, 100, 0, 400).Im - _ = img.SavePng(dc, name) + _ = writer.SavePNG2Path(name, dc) return "file:///" + name } @@ -29,7 +30,7 @@ func (cc *context) si() string { dc := img.LoadFirstFrame(dlblock(`si/0.png`), 0, 0). InsertBottom(im1.Im, im1.W, im1.H, -3, 370). InsertBottom(im2.Im, im2.W, im2.H, 653, 310).Im - _ = img.SavePng(dc, name) + _ = writer.SavePNG2Path(name, dc) return "file:///" + name } @@ -64,6 +65,6 @@ func (cc *context) other(value ...string) string { a = img.Size(im.Im, w, h).Im } - _ = img.SavePng(a, name) + _ = writer.SavePNG2Path(name, a) return "file:///" + name } diff --git a/plugin_jandan/data.go b/plugin_jandan/data.go index ec29b142..cacbf3dd 100644 --- a/plugin_jandan/data.go +++ b/plugin_jandan/data.go @@ -4,9 +4,9 @@ import ( "os" "sync" + sql "github.com/FloatTech/sqlite" "github.com/FloatTech/zbputils/file" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/sql" log "github.com/sirupsen/logrus" "github.com/FloatTech/ZeroBot-Plugin/order" diff --git a/plugin_manager/manager.go b/plugin_manager/manager.go index 238a80ed..a17ea05e 100644 --- a/plugin_manager/manager.go +++ b/plugin_manager/manager.go @@ -14,11 +14,11 @@ import ( zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" + sql "github.com/FloatTech/sqlite" control "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" "github.com/FloatTech/zbputils/math" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/sql" "github.com/FloatTech/ZeroBot-Plugin/order" "github.com/FloatTech/ZeroBot-Plugin/plugin_manager/timer" diff --git a/plugin_manager/timer/timer.db.go b/plugin_manager/timer/timer.db.go index 3ce1e30a..86305325 100644 --- a/plugin_manager/timer/timer.db.go +++ b/plugin_manager/timer/timer.db.go @@ -1,7 +1,7 @@ package timer import ( - "github.com/FloatTech/zbputils/sql" + sql "github.com/FloatTech/sqlite" ) // Timer 计时器 diff --git a/plugin_manager/timer/timer.go b/plugin_manager/timer/timer.go index d9abf0ea..1f2833ef 100644 --- a/plugin_manager/timer/timer.go +++ b/plugin_manager/timer/timer.go @@ -7,12 +7,11 @@ import ( "sync" "time" + sql "github.com/FloatTech/sqlite" "github.com/fumiama/cron" "github.com/sirupsen/logrus" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" - - "github.com/FloatTech/zbputils/sql" ) // Clock 时钟 diff --git a/plugin_manager/timer/timer_test.go b/plugin_manager/timer/timer_test.go index 896ec847..fabfad5c 100644 --- a/plugin_manager/timer/timer_test.go +++ b/plugin_manager/timer/timer_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/FloatTech/zbputils/sql" + sql "github.com/FloatTech/sqlite" "github.com/sirupsen/logrus" ) diff --git a/plugin_nativesetu/data.go b/plugin_nativesetu/data.go index 95f9ae85..467c1905 100644 --- a/plugin_nativesetu/data.go +++ b/plugin_nativesetu/data.go @@ -13,9 +13,9 @@ import ( "github.com/wdvxdr1123/ZeroBot/utils/helper" _ "golang.org/x/image/webp" // import webp decoding + sql "github.com/FloatTech/sqlite" "github.com/FloatTech/zbputils/file" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/sql" "github.com/FloatTech/ZeroBot-Plugin/order" ) diff --git a/plugin_novel/qianbi.go b/plugin_novel/qianbi.go index b09f20a6..b4ae0178 100644 --- a/plugin_novel/qianbi.go +++ b/plugin_novel/qianbi.go @@ -19,7 +19,7 @@ import ( ub "github.com/FloatTech/zbputils/binary" control "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" - "github.com/FloatTech/zbputils/txt2img" + "github.com/FloatTech/zbputils/img/text" "github.com/FloatTech/ZeroBot-Plugin/order" ) @@ -64,7 +64,7 @@ func init() { log.Errorln("[novel]", err) } if len(list) != 0 { - text := "" + txt := "" for _, v := range list { bookName := htmlquery.InnerText(htmlquery.FindOne(v, "/dd[1]/h3/a[1]")) category := htmlquery.InnerText(htmlquery.FindOne(v, "/dt/span[1]")) @@ -80,9 +80,9 @@ func init() { webpageURL := websiteURL + "/book/" + id + "/" downloadURL := websiteURL + "/modules/article/txtarticle.php?id=" + id - text += fmt.Sprintf("书名:%s\n类型:%s\n作者:%s\n状态:%s\n字数:%s\n简介:%s\n更新时间:%s\n最新章节:%s\n网页链接:%s\n下载地址:%s\n\n", bookName, category, author, status, wordNumbers, description, updateTime, latestChapter, webpageURL, downloadURL) + txt += fmt.Sprintf("书名:%s\n类型:%s\n作者:%s\n状态:%s\n字数:%s\n简介:%s\n更新时间:%s\n最新章节:%s\n网页链接:%s\n下载地址:%s\n\n", bookName, category, author, status, wordNumbers, description, updateTime, latestChapter, webpageURL, downloadURL) } - data, err := txt2img.RenderToBase64(text, txt2img.FontFile, 400, 20) + data, err := text.RenderToBase64(txt, text.FontFile, 400, 20) if err != nil { log.Println("err:", err) } diff --git a/plugin_omikuji/data.go b/plugin_omikuji/data.go index 0460809c..bbfc2617 100644 --- a/plugin_omikuji/data.go +++ b/plugin_omikuji/data.go @@ -5,9 +5,9 @@ import ( log "github.com/sirupsen/logrus" + sql "github.com/FloatTech/sqlite" "github.com/FloatTech/zbputils/file" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/sql" "github.com/FloatTech/ZeroBot-Plugin/order" ) diff --git a/plugin_omikuji/sensou.go b/plugin_omikuji/sensou.go index 8ca6e41b..f80ffeb9 100644 --- a/plugin_omikuji/sensou.go +++ b/plugin_omikuji/sensou.go @@ -14,7 +14,7 @@ import ( control "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" - "github.com/FloatTech/zbputils/txt2img" + "github.com/FloatTech/zbputils/img/text" "github.com/FloatTech/ZeroBot-Plugin/order" ) @@ -43,7 +43,7 @@ func init() { // 插件主体 }) engine.OnFullMatchGroup([]string{"解签"}).SetBlock(true). Handle(func(ctx *zero.Ctx) { - kujiBytes, err := txt2img.RenderToBase64(getKujiByBango(bangoToday(ctx.Event.UserID)), txt2img.FontFile, 400, 20) + kujiBytes, err := text.RenderToBase64(getKujiByBango(bangoToday(ctx.Event.UserID)), text.FontFile, 400, 20) if err != nil { log.Errorln("[omikuji]:", err) } diff --git a/plugin_score/data.go b/plugin_score/data.go index 2b4d456d..334ceefb 100644 --- a/plugin_score/data.go +++ b/plugin_score/data.go @@ -6,8 +6,8 @@ import ( log "github.com/sirupsen/logrus" "github.com/FloatTech/zbputils/file" + "github.com/FloatTech/zbputils/img/text" "github.com/FloatTech/zbputils/process" - "github.com/FloatTech/zbputils/txt2img" "github.com/FloatTech/ZeroBot-Plugin/order" ) @@ -26,11 +26,11 @@ func init() { go func() { defer order.DoneOnExit()() process.SleepAbout1sTo2s() - _, err := file.GetLazyData(txt2img.BoldFontFile, false, true) + _, err := file.GetLazyData(text.BoldFontFile, false, true) if err != nil { panic(err) } - _, err = file.GetLazyData(txt2img.FontFile, false, true) + _, err = file.GetLazyData(text.FontFile, false, true) if err != nil { panic(err) } diff --git a/plugin_score/sign_in.go b/plugin_score/sign_in.go index a6649bd6..650770a2 100644 --- a/plugin_score/sign_in.go +++ b/plugin_score/sign_in.go @@ -17,7 +17,8 @@ import ( control "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" "github.com/FloatTech/zbputils/file" - "github.com/FloatTech/zbputils/txt2img" + "github.com/FloatTech/zbputils/img/text" + "github.com/FloatTech/zbputils/img/writer" "github.com/FloatTech/zbputils/web" "github.com/FloatTech/ZeroBot-Plugin/order" @@ -78,7 +79,7 @@ func init() { monthWord := now.Format("01/02") hourWord := getHourWord(now) - if err = canvas.LoadFontFace(txt2img.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil { + if err = canvas.LoadFontFace(text.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil { ctx.SendChain(message.Text("ERROR:", err)) return } @@ -86,7 +87,7 @@ func init() { canvas.DrawString(hourWord, float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.2) canvas.DrawString(monthWord, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*1.2) nickName := ctxext.CardOrNickName(ctx, uid) - if err = canvas.LoadFontFace(txt2img.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil { + if err = canvas.LoadFontFace(text.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil { ctx.SendChain(message.Text("ERROR:", err)) return } @@ -118,10 +119,9 @@ func init() { canvas.DrawString(fmt.Sprintf("%d/%d", score, nextLevelScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62) f, err := os.Create(drawedFile) - txtc := txt2img.TxtCanvas{Canvas: canvas} if err != nil { log.Errorln("[score]", err) - canvasBase64, err := txtc.ToBase64() + canvasBase64, err := writer.ToBase64(canvas.Image()) if err != nil { ctx.SendChain(message.Text("ERROR:", err)) return @@ -129,7 +129,7 @@ func init() { ctx.SendChain(message.Image("base64://" + helper.BytesToString(canvasBase64))) return } - _, err = txtc.WriteTo(f) + _, err = writer.WriteTo(canvas.Image(), f) _ = f.Close() if err != nil { ctx.SendChain(message.Text("ERROR:", err)) diff --git a/plugin_setutime/setu_geter.go b/plugin_setutime/setu_geter.go index 1495bf4e..b97da305 100644 --- a/plugin_setutime/setu_geter.go +++ b/plugin_setutime/setu_geter.go @@ -11,6 +11,7 @@ import ( "time" "github.com/FloatTech/AnimeAPI/pixiv" + sql "github.com/FloatTech/sqlite" control "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" fileutil "github.com/FloatTech/zbputils/file" @@ -18,7 +19,6 @@ import ( "github.com/FloatTech/zbputils/math" "github.com/FloatTech/zbputils/process" "github.com/FloatTech/zbputils/rule" - "github.com/FloatTech/zbputils/sql" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" diff --git a/plugin_shindan/shindan.go b/plugin_shindan/shindan.go index b0712c1b..77ca13a8 100644 --- a/plugin_shindan/shindan.go +++ b/plugin_shindan/shindan.go @@ -12,7 +12,7 @@ import ( control "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" - "github.com/FloatTech/zbputils/txt2img" + "github.com/FloatTech/zbputils/img/text" ) func init() { @@ -35,14 +35,14 @@ func handle(ctx *zero.Ctx) { // 获取名字 name := ctxext.NickName(ctx) // 调用接口 - text, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name) + txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) } // TODO: 可注入 switch ctx.State["id"].(int64) { case 587874, 162207: - data, err := txt2img.RenderToBase64(text, txt2img.FontFile, 400, 20) + data, err := text.RenderToBase64(txt, text.FontFile, 400, 20) if err != nil { log.Errorln("[shindan]:", err) } @@ -50,7 +50,7 @@ func handle(ctx *zero.Ctx) { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } default: - ctx.Send(text) + ctx.Send(txt) } } diff --git a/plugin_vtb_quotation/vtb_quotation.go b/plugin_vtb_quotation/vtb_quotation.go index 52b437c4..0a804b67 100644 --- a/plugin_vtb_quotation/vtb_quotation.go +++ b/plugin_vtb_quotation/vtb_quotation.go @@ -15,7 +15,7 @@ import ( "github.com/wdvxdr1123/ZeroBot/utils/helper" control "github.com/FloatTech/zbputils/control" - "github.com/FloatTech/zbputils/txt2img" + "github.com/FloatTech/zbputils/img/text" "github.com/FloatTech/ZeroBot-Plugin/order" "github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation/model" @@ -48,7 +48,7 @@ func init() { } defer db.Close() defer cancel() - firstStepImageBytes, err := txt2img.RenderToBase64(db.GetAllFirstCategoryMessage(), txt2img.FontFile, 400, 20) + firstStepImageBytes, err := text.RenderToBase64(db.GetAllFirstCategoryMessage(), text.FontFile, 400, 20) if err != nil { log.Errorln("[vtb]:", err) } @@ -80,7 +80,7 @@ func init() { // log.Println(secondStepMessage) if secondStepMessage == "" { ctx.SendChain(message.Reply(e.MessageID), message.Text("你选择的序号没有内容,请重新选择,三次输入错误,指令可退出重输")) - firstStepImageBytes, err := txt2img.RenderToBase64(db.GetAllFirstCategoryMessage(), txt2img.FontFile, 400, 20) + firstStepImageBytes, err := text.RenderToBase64(db.GetAllFirstCategoryMessage(), text.FontFile, 400, 20) if err != nil { log.Errorln("[vtb]:", err) } @@ -89,7 +89,7 @@ func init() { } errorCount++ } else { - secondStepMessageBytes, err := txt2img.RenderToBase64(secondStepMessage, txt2img.FontFile, 400, 20) + secondStepMessageBytes, err := text.RenderToBase64(secondStepMessage, text.FontFile, 400, 20) if err != nil { log.Errorln("[vtb]:", err) } @@ -111,7 +111,7 @@ func init() { // log.Println(thirdStepMessage) if thirdStepMessage == "" { ctx.SendChain(message.Reply(e.MessageID), message.Text("你选择的序号没有内容,请重新选择,三次输入错误,指令可退出重输")) - secondStepMessageBytes, err := txt2img.RenderToBase64(db.GetAllSecondCategoryMessageByFirstIndex(firstIndex), txt2img.FontFile, 400, 20) + secondStepMessageBytes, err := text.RenderToBase64(db.GetAllSecondCategoryMessageByFirstIndex(firstIndex), text.FontFile, 400, 20) if err != nil { log.Errorln("[vtb]:", err) } @@ -120,7 +120,7 @@ func init() { } errorCount++ } else { - thirdStepMessageBytes, err := txt2img.RenderToBase64(thirdStepMessage, txt2img.FontFile, 400, 20) + thirdStepMessageBytes, err := text.RenderToBase64(thirdStepMessage, text.FontFile, 400, 20) if err != nil { log.Errorln("[vtb]:", err) } @@ -143,7 +143,7 @@ func init() { recURL := tc.ThirdCategoryPath if recURL == "" { ctx.SendChain(message.Reply(e.MessageID), message.Text("没有内容请重新选择,三次输入错误,指令可退出重输")) - firstStepImageBytes, err := txt2img.RenderToBase64(db.GetAllFirstCategoryMessage(), txt2img.FontFile, 400, 20) + firstStepImageBytes, err := text.RenderToBase64(db.GetAllFirstCategoryMessage(), text.FontFile, 400, 20) if err != nil { log.Errorln("[vtb]:", err) }