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

fix MustProvidePhoto

This commit is contained in:
源文雨
2022-10-04 18:26:47 +08:00
parent 63a0752c61
commit 6bc5f89ed3

View File

@@ -367,7 +367,8 @@ func IsPhoto(ctx *Ctx) bool {
} }
// MustProvidePhoto 消息不存在图片阻塞120秒至有图片超时返回 false // MustProvidePhoto 消息不存在图片阻塞120秒至有图片超时返回 false
func MustProvidePhoto(ctx *Ctx, needphohint, failhint string) bool { func MustProvidePhoto(ctx *Ctx, needphohint, failhint string) Rule {
return func(ctx *Ctx) bool {
msg, ok := ctx.Value.(*tgba.Message) msg, ok := ctx.Value.(*tgba.Message)
if ok && len(msg.Photo) > 0 { // 确保无空 if ok && len(msg.Photo) > 0 { // 确保无空
ctx.State["photos"] = msg.Photo ctx.State["photos"] = msg.Photo
@@ -380,7 +381,7 @@ func MustProvidePhoto(ctx *Ctx, needphohint, failhint string) bool {
return false return false
} }
} }
next := NewFutureEvent("message", 999, false, ctx.CheckSession(), IsPhoto).Next() next := NewFutureEvent("Message", 999, false, ctx.CheckSession(), IsPhoto).Next()
select { select {
case <-time.After(time.Second * 120): case <-time.After(time.Second * 120):
if failhint != "" { if failhint != "" {
@@ -393,3 +394,4 @@ func MustProvidePhoto(ctx *Ctx, needphohint, failhint string) bool {
return true return true
} }
} }
}