diff --git a/plugin_ai_reply/main.go b/plugin_ai_reply/main.go index d6a979d3..7e05b5de 100644 --- a/plugin_ai_reply/main.go +++ b/plugin_ai_reply/main.go @@ -1,3 +1,4 @@ +// Package aireply AI 回复 package aireply import ( diff --git a/plugin_danbooru/main.go b/plugin_danbooru/main.go index 22c2b74c..7dd07c86 100644 --- a/plugin_danbooru/main.go +++ b/plugin_danbooru/main.go @@ -49,7 +49,7 @@ func init() { // 插件主体 digest := md5.Sum(helper.StringToBytes(url)) f := cachefile + hex.EncodeToString(digest[:]) if file.IsNotExist(f) { - t.Canvas.SavePNG(f) + _ = t.Canvas.SavePNG(f) } ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + f)) } diff --git a/plugin_gif/context.go b/plugin_gif/context.go index e6697466..52b91e56 100644 --- a/plugin_gif/context.go +++ b/plugin_gif/context.go @@ -1,4 +1,4 @@ -package plugin_gif +package gif import ( "os" @@ -33,11 +33,11 @@ func dlblock(name string) string { return target } -func dlrange(prefix string, suffix string, end int) *[]chan *string { +func dlrange(prefix string, end int) *[]chan *string { c := make([]chan *string, end) for i := range c { c[i] = make(chan *string) - go dlchan(prefix+strconv.Itoa(i)+suffix, &c[i]) + go dlchan(prefix+"/"+strconv.Itoa(i)+".png", &c[i]) } return &c } diff --git a/plugin_gif/gif.go b/plugin_gif/gif.go index 027daee6..a95fde8a 100644 --- a/plugin_gif/gif.go +++ b/plugin_gif/gif.go @@ -1,4 +1,4 @@ -package plugin_gif +package gif import ( "image" @@ -8,8 +8,8 @@ import ( // 摸 func (cc *context) mo() string { - name := cc.usrdir + `摸.gif` - c := dlrange(`mo/`, `.png`, 5) + name := cc.usrdir + "摸.gif" + c := dlrange("mo", 5) tou := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0).Circle(0).Im mo := []*image.NRGBA{ img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertBottom(tou, 80, 80, 32, 32).Im, @@ -24,8 +24,8 @@ func (cc *context) mo() string { // 搓 func (cc *context) cuo() string { - name := cc.usrdir + `搓.gif` - c := dlrange(`cuo/`, `.png`, 5) + name := cc.usrdir + "搓.gif" + c := dlrange("cuo", 5) tou := img.LoadFirstFrame(cc.headimgsdir[0], 110, 110).Circle(0).Im m1 := img.Rotate(tou, 72, 0, 0) m2 := img.Rotate(tou, 144, 0, 0) @@ -44,8 +44,8 @@ func (cc *context) cuo() string { // 敲 func (cc *context) qiao() string { - name := cc.usrdir + `敲.gif` - c := dlrange(`qiao/`, `.png`, 2) + name := cc.usrdir + "敲.gif" + c := dlrange("qiao", 2) tou := img.LoadFirstFrame(cc.headimgsdir[0], 40, 40).Circle(0).Im qiao := []*image.NRGBA{ img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 40, 33, 57, 52).Im, @@ -57,8 +57,8 @@ func (cc *context) qiao() string { // 吃 func (cc *context) chi() string { - name := cc.usrdir + `吃.gif` - c := dlrange(`chi/`, `.png`, 3) + name := cc.usrdir + "吃.gif" + c := dlrange("chi", 3) tou := img.LoadFirstFrame(cc.headimgsdir[0], 32, 32).Im chi := []*image.NRGBA{ img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertBottom(tou, 0, 0, 1, 38).Im, @@ -71,8 +71,8 @@ func (cc *context) chi() string { // 蹭 func (cc *context) ceng() string { - name := cc.usrdir + `蹭.gif` - c := dlrange(`ceng/`, `.png`, 6) + name := cc.usrdir + "蹭.gif" + c := dlrange("ceng", 6) tou := img.LoadFirstFrame(cc.headimgsdir[0], 100, 100).Circle(0).Im tou2 := img.LoadFirstFrame(cc.headimgsdir[1], 100, 100).Circle(0).Im ceng := []*image.NRGBA{ @@ -89,8 +89,8 @@ func (cc *context) ceng() string { // 啃 func (cc *context) ken() string { - name := cc.usrdir + `啃.gif` - c := dlrange(`ken/`, `.png`, 16) + name := cc.usrdir + "啃.gif" + c := dlrange("ken", 16) tou := img.LoadFirstFrame(cc.headimgsdir[0], 100, 100).Im ken := []*image.NRGBA{ img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertBottom(tou, 90, 90, 105, 150).Im, @@ -116,8 +116,8 @@ func (cc *context) ken() string { // 拍 func (cc *context) pai() string { - name := cc.usrdir + `拍.gif` - c := dlrange(`pai/`, `.png`, 2) + name := cc.usrdir + "拍.gif" + c := dlrange("pai", 2) tou := img.LoadFirstFrame(cc.headimgsdir[0], 30, 30).Circle(0).Im pai := []*image.NRGBA{ img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 0, 0, 1, 47).Im, @@ -129,8 +129,8 @@ func (cc *context) pai() string { // 冲 func (cc *context) chong() string { - name := cc.usrdir + `冲.gif` - c := dlrange(`xqe/`, `.png`, 2) + name := cc.usrdir + "冲.gif" + c := dlrange("xqe", 2) tou := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0).Circle(0).Im chong := []*image.NRGBA{ img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 30, 30, 15, 53).Im, @@ -142,8 +142,8 @@ func (cc *context) chong() string { // 丢 func (cc *context) diu() string { - name := cc.usrdir + `丢.gif` - c := dlrange(`diu/`, `.png`, 8) + name := cc.usrdir + "丢.gif" + c := dlrange("diu", 8) tou := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0).Circle(0).Im diu := []*image.NRGBA{ img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 32, 32, 108, 36).Im, diff --git a/plugin_gif/logo.go b/plugin_gif/logo.go index b76be4b4..7a4a73b0 100644 --- a/plugin_gif/logo.go +++ b/plugin_gif/logo.go @@ -1,4 +1,4 @@ -package plugin_gif +package gif import ( "strconv" @@ -11,9 +11,9 @@ func (c *context) prepareLogos(s ...string) { for i, v := range s { _, err := strconv.Atoi(v) if err != nil { - file.DownloadTo("https://gchat.qpic.cn/gchatpic_new//--"+strings.ToUpper(v)+"/0", c.usrdir+strconv.Itoa(i)+".gif", true) + _ = file.DownloadTo("https://gchat.qpic.cn/gchatpic_new//--"+strings.ToUpper(v)+"/0", c.usrdir+strconv.Itoa(i)+".gif", true) } else { - file.DownloadTo("http://q4.qlogo.cn/g?b=qq&nk="+v+"&s=640", c.usrdir+strconv.Itoa(i)+".gif", true) + _ = file.DownloadTo("http://q4.qlogo.cn/g?b=qq&nk="+v+"&s=640", c.usrdir+strconv.Itoa(i)+".gif", true) } } } diff --git a/plugin_gif/png.go b/plugin_gif/png.go index b10a690a..52dcc1de 100644 --- a/plugin_gif/png.go +++ b/plugin_gif/png.go @@ -1,4 +1,4 @@ -package plugin_gif +package gif import ( "image" @@ -39,28 +39,31 @@ func (cc *context) other(value ...string) string { // 加载图片 im := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0) var a *image.NRGBA - if value[0] == "上翻" || value[0] == "下翻" { + + switch value[0] { + case "上翻", "下翻": a = im.FlipV().Im - } else if value[0] == "左翻" || value[0] == "右翻" { + case "左翻", "右翻": a = im.FlipH().Im - } else if value[0] == "反色" { + case "反色": a = im.Invert().Im - } else if value[0] == "灰度" { + case "灰度": a = im.Grayscale().Im - } else if value[0] == "负片" { + case "负片": a = im.Invert().Grayscale().Im - } else if value[0] == "浮雕" { + case "浮雕": a = im.Convolve3x3().Im - } else if value[0] == "打码" { + case "打码": a = im.Blur(10).Im - } else if value[0] == "旋转" { + case "旋转": r, _ := strconv.ParseFloat(value[1], 64) a = img.Rotate(im.Im, r, 0, 0).Im - } else if value[0] == "变形" { + case "变形": w, _ := strconv.Atoi(value[1]) h, _ := strconv.Atoi(value[2]) a = img.Size(im.Im, w, h).Im } + _ = img.SavePng(a, name) return "file:///" + name } diff --git a/plugin_gif/run.go b/plugin_gif/run.go index 7668da2b..27b8dac1 100644 --- a/plugin_gif/run.go +++ b/plugin_gif/run.go @@ -1,5 +1,5 @@ -// Package plugin_gif 制图 -package plugin_gif +// Package gif 制图 +package gif import ( "math/rand"