small fixups

This commit is contained in:
Ettore Di Giacinto
2024-04-08 23:25:17 +02:00
parent f11c8f3f57
commit 80361a6400
4 changed files with 35 additions and 11 deletions

View File

@@ -12,8 +12,8 @@ import (
)
type Telegram struct {
Token string
Conttext context.Context
Token string
lastChatID int64
}
// Send any text message to the bot after the bot has been started
@@ -45,6 +45,7 @@ func (t *Telegram) Start(a *agent.Agent) {
ChatID: update.Message.Chat.ID,
Text: res.Response,
})
t.lastChatID = update.Message.Chat.ID
}),
}
@@ -53,6 +54,18 @@ func (t *Telegram) Start(a *agent.Agent) {
panic(err)
}
go func() {
for m := range a.ConversationChannel() {
if t.lastChatID == 0 {
continue
}
b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: t.lastChatID,
Text: m.Content,
})
}
}()
b.Start(ctx)
}