Storing /summarize replies in history too (#32).
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Alexey Skobkin 2024-11-04 01:24:40 +03:00
parent a783a84faa
commit 541c1d3bbf
Signed by: skobkin
GPG key ID: 4389E670595BF8A8
2 changed files with 11 additions and 7 deletions

View file

@ -233,9 +233,11 @@ func (b *Bot) summarizeHandler(bot *telego.Bot, update telego.Update) {
slog.Debug("Got completion. Going to send.", "llm-completion", llmReply) slog.Debug("Got completion. Going to send.", "llm-completion", llmReply)
replyMarkdown := b.escapeMarkdownV1Symbols(llmReply)
message := tu.Message( message := tu.Message(
chatID, chatID,
b.escapeMarkdownV1Symbols(llmReply), replyMarkdown,
).WithParseMode("Markdown") ).WithParseMode("Markdown")
_, err = bot.SendMessage(b.reply(update.Message, message)) _, err = bot.SendMessage(b.reply(update.Message, message))
@ -245,6 +247,8 @@ func (b *Bot) summarizeHandler(bot *telego.Bot, update telego.Update) {
b.trySendReplyError(update.Message) b.trySendReplyError(update.Message)
} }
b.saveBotReplyToHistory(update.Message, replyMarkdown)
} }
func (b *Bot) helpHandler(bot *telego.Bot, update telego.Update) { func (b *Bot) helpHandler(bot *telego.Bot, update telego.Update) {

View file

@ -61,14 +61,14 @@ func (b *Bot) saveChatMessageToHistory(message *telego.Message) {
b.history[chatId].Push(msgData) b.history[chatId].Push(msgData)
} }
func (b *Bot) saveBotReplyToHistory(message *telego.Message, text string) { func (b *Bot) saveBotReplyToHistory(replyTo *telego.Message, text string) {
chatId := message.Chat.ID chatId := replyTo.Chat.ID
slog.Info( slog.Info(
"history-reply-save", "history-reply-save",
"chat", chatId, "chat", chatId,
"to_id", message.From.ID, "to_id", replyTo.From.ID,
"to_name", message.From.FirstName, "to_name", replyTo.From.FirstName,
"text", text, "text", text,
) )
@ -84,8 +84,8 @@ func (b *Bot) saveBotReplyToHistory(message *telego.Message, text string) {
IsMe: true, IsMe: true,
} }
if message.ReplyToMessage != nil { if replyTo.ReplyToMessage != nil {
replyMessage := message.ReplyToMessage replyMessage := replyTo.ReplyToMessage
msgData.ReplyTo = &MessageData{ msgData.ReplyTo = &MessageData{
Name: replyMessage.From.FirstName, Name: replyMessage.From.FirstName,