mirror of
https://github.com/fumiama/ReiBot.git
synced 2026-06-10 13:00:40 +08:00
add more
This commit is contained in:
14
context.go
14
context.go
@@ -1,8 +1,22 @@
|
||||
package rei
|
||||
|
||||
import tgba "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
|
||||
type Ctx struct {
|
||||
Event
|
||||
State
|
||||
Caller *TelegramClient
|
||||
ma *Matcher
|
||||
}
|
||||
|
||||
// CheckSession 判断会话连续性
|
||||
func (ctx *Ctx) CheckSession() Rule {
|
||||
msg := ctx.Value.(*tgba.Message)
|
||||
return func(ctx2 *Ctx) bool {
|
||||
msg2, ok := ctx.Value.(*tgba.Message)
|
||||
if !ok || msg.From == nil || msg.Chat == nil || msg2.From == nil || msg2.Chat == nil { // 确保无空
|
||||
return false
|
||||
}
|
||||
return msg.From.ID == msg2.From.ID && msg.Chat.ID == msg2.Chat.ID
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user