This commit is contained in:
cdle
2021-10-07 15:41:26 +08:00
parent 51d06203fd
commit f0b4dc0fe4
3 changed files with 14 additions and 14 deletions
+1
View File
@@ -25,6 +25,7 @@ require (
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
github.com/tidwall/gjson v1.9.1 // indirect
github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
+1
View File
@@ -286,6 +286,7 @@ golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWP
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+12 -14
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"image/png"
"log"
"os"
"regexp"
"strings"
@@ -116,29 +115,28 @@ func init() {
}
})
b.Handle(tb.OnSticker, func(m *tb.Message) {
buf := new(bytes.Buffer)
buf.ReadFrom(m.Sticker.FileReader)
img, err := webp.Decode(buf)
if err != nil {
log.Printf("error while decoding sticker: %v\n", err)
return
}
buf.Reset()
imgBuf := buf
err = png.Encode(imgBuf, img)
if err == nil {
filename := fmt.Sprint(time.Now().UnixNano()) + ".image"
filepath := core.ExecPath + "/data/images/" + filename
f, err := os.Create(filepath)
if err == nil {
f.Write(imgBuf.Bytes())
f.Close()
m.Text = fmt.Sprintf(`[TG:image,file=%s]`, filename) + m.Caption
Handler(m)
}
if err != nil {
return
}
filename := fmt.Sprint(time.Now().UnixNano()) + ".image"
filepath := core.ExecPath + "/data/images/" + filename
f, err := os.Create(filepath)
if err != nil {
return
}
f.Write(imgBuf.Bytes())
f.Close()
m.Text = fmt.Sprintf(`[TG:image,file=%s]`, filename) + m.Caption
Handler(m)
})
b.Handle(tb.OnText, Handler)
logs.Info("监听telegram机器人")