From fac211d8ee3e6b145f094e20ddb0281256247dfe Mon Sep 17 00:00:00 2001 From: mudler Date: Thu, 11 Apr 2024 23:04:29 +0200 Subject: [PATCH] parallel calls for telegram --- example/webui/connector/telegram.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/example/webui/connector/telegram.go b/example/webui/connector/telegram.go index df7c349..151b9ca 100644 --- a/example/webui/connector/telegram.go +++ b/example/webui/connector/telegram.go @@ -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 + }() }), }