feat: use pure-go exif injector in sticker command
This commit is contained in:
+23
-6
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
hc "neo/context"
|
hc "neo/context"
|
||||||
"neo/core"
|
"neo/core"
|
||||||
@@ -20,12 +21,28 @@ var Sticker = &core.Command{
|
|||||||
Run: func(ctx *hc.Ctx) {
|
Run: func(ctx *hc.Ctx) {
|
||||||
// go ctx.React("👌")
|
// go ctx.React("👌")
|
||||||
|
|
||||||
exifPath, cleanupExif := helper.ResolveExif(ctx.Arguments())
|
var packName, publisher string
|
||||||
defer func() {
|
args := ctx.Arguments()
|
||||||
if cleanupExif {
|
|
||||||
os.Remove(exifPath)
|
packName = os.Getenv("STICKER_NAME")
|
||||||
|
if packName == "" {
|
||||||
|
packName = "Bot"
|
||||||
|
}
|
||||||
|
publisher = os.Getenv("STICKER_PUBLISHER")
|
||||||
|
if publisher == "" {
|
||||||
|
publisher = "Bot"
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) > 0 {
|
||||||
|
argsStr := strings.Join(args, " ")
|
||||||
|
parts := strings.Split(argsStr, "|")
|
||||||
|
packName = strings.TrimSpace(parts[0])
|
||||||
|
if len(parts) > 1 {
|
||||||
|
publisher = strings.TrimSpace(parts[1])
|
||||||
|
} else {
|
||||||
|
publisher = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
|
|
||||||
msg := ctx.Message()
|
msg := ctx.Message()
|
||||||
quoted := hc.GetQuotedMessage(msg)
|
quoted := hc.GetQuotedMessage(msg)
|
||||||
@@ -66,7 +83,7 @@ var Sticker = &core.Command{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
finalSticker, err := helper.InjectExif(rawWebp, exifPath)
|
finalSticker, err := helper.InjectExif(rawWebp, packName, publisher)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Reply(fmt.Sprintf("error injecting EXIF: %v", err))
|
ctx.Reply(fmt.Sprintf("error injecting EXIF: %v", err))
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user