1
0
mirror of https://github.com/fumiama/ReiBot.git synced 2026-06-10 13:00:40 +08:00
This commit is contained in:
源文雨
2022-06-02 14:36:43 +08:00
parent 7c90c8b7d3
commit 8b6817acea
13 changed files with 802 additions and 17 deletions

View File

@@ -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
}
}