parallel calls for telegram

This commit is contained in:
mudler
2024-04-11 23:04:29 +02:00
parent 84a808fb7e
commit fac211d8ee

View File

@@ -43,16 +43,18 @@ func (t *Telegram) Start(a *agent.Agent) {
opts := []bot.Option{
bot.WithDefaultHandler(func(ctx context.Context, b *bot.Bot, update *models.Update) {
res := a.Ask(
agent.WithText(
update.Message.Text,
),
)
b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: update.Message.Chat.ID,
Text: res.Response,
})
t.lastChatID = update.Message.Chat.ID
go func() {
res := a.Ask(
agent.WithText(
update.Message.Text,
),
)
b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: update.Message.Chat.ID,
Text: res.Response,
})
t.lastChatID = update.Message.Chat.ID
}()
}),
}