1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-11 05:30:24 +08:00

fix(rule): adapt qq id

This commit is contained in:
源文雨
2023-11-16 23:35:34 +09:00
parent a0b3a038e2
commit c50e8e3f11
3 changed files with 45 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"reflect"
"strconv"
"strings"
"sync"
)
@@ -283,3 +284,24 @@ func (ctx *Ctx) Block() {
func (ctx *Ctx) Break() {
ctx.ma.Break = true
}
// SenderID 唯一的发送者 ID
func (ctx *Ctx) SenderID() uint64 {
grp := uint64(0)
if ctx.IsQQ {
if OnlyQQGroup(ctx) {
grp = DigestID(ctx.Message.ChannelID)
} else if OnlyQQPrivate(ctx) {
grp = DigestID(ctx.Message.Author.ID)
} else {
return 0
}
} else {
var err error
grp, err = strconv.ParseUint(ctx.Message.ChannelID, 10, 64)
if err != nil {
return 0
}
}
return grp
}