mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
fix: reply face
This commit is contained in:
parent
79f1beac53
commit
ec00251972
@ -4,6 +4,7 @@ package manager
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -403,6 +404,7 @@ func init() { // 插件主体
|
|||||||
ctx.SendLike(ctx.Event.UserID, 10)
|
ctx.SendLike(ctx.Event.UserID, 10)
|
||||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("给你赞了10下哦,记得回我~"))
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("给你赞了10下哦,记得回我~"))
|
||||||
})
|
})
|
||||||
|
facere := regexp.MustCompile(`\[CQ:face,id=(\d+)\]`)
|
||||||
// 给消息回应表情
|
// 给消息回应表情
|
||||||
engine.OnRegex(`^\[CQ:reply,id=(-?\d+)\].*回应表情\s*(.+)\s*$`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).
|
engine.OnRegex(`^\[CQ:reply,id=(-?\d+)\].*回应表情\s*(.+)\s*$`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
@ -412,12 +414,24 @@ func init() { // 插件主体
|
|||||||
ctx.SendChain(message.Text("ERROR: 表情长度为 0"))
|
ctx.SendChain(message.Text("ERROR: 表情长度为 0"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ids := facere.FindStringSubmatch(face)[1]
|
||||||
|
id := rune(0)
|
||||||
|
if len(ids) > 0 {
|
||||||
|
idi, err := strconv.Atoi(ids)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
id = rune(idi)
|
||||||
|
} else {
|
||||||
x := []rune(face)
|
x := []rune(face)
|
||||||
if len(x) == 0 {
|
if len(x) == 0 {
|
||||||
ctx.SendChain(message.Text("ERROR: 解析后表情长度为 0"))
|
ctx.SendChain(message.Text("ERROR: 解析后表情长度为 0"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := ctx.SetMessageEmojiLike(msgid, x[0])
|
id = x[0]
|
||||||
|
}
|
||||||
|
err := ctx.SetMessageEmojiLike(msgid, rune(id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user