EDIT singleflight to work with messages if AI is taking long
This commit is contained in:
parent
0f2762d53c
commit
01585ea59b
@ -39,6 +39,17 @@ func SingleFlight(next bot.HandlerFunc) bot.HandlerFunc {
|
|||||||
}
|
}
|
||||||
defer sf.Delete(key)
|
defer sf.Delete(key)
|
||||||
next(ctx, b, update)
|
next(ctx, b, update)
|
||||||
|
}else if update.Message != nil {
|
||||||
|
key := update.Message.From.ID
|
||||||
|
if _, loaded := sf.LoadOrStore(key, struct{}{}); loaded{
|
||||||
|
log.Debug("key alredy loaded", "key", key)
|
||||||
|
b.SendMessage(ctx, &bot.SendMessageParams{ChatID: update.Message.From.ID, Text: "IA esta aun procesando su respuesta, por favor espere!!!"})
|
||||||
|
return
|
||||||
|
}else{
|
||||||
|
log.Debug("key not loaded", "key", key)
|
||||||
|
}
|
||||||
|
defer sf.Delete(key)
|
||||||
|
next(ctx, b, update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user