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:
22
context.go
22
context.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user