Skip to content

Commit b0a43b0

Browse files
committed
fix(telegram): correctly process group chat messages
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 51bb368 commit b0a43b0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

services/connectors/telegram.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,9 @@ func (t *Telegram) handleGroupMessage(ctx context.Context, b *bot.Bot, a *agent.
146146
// Cancel any active job for this chat before starting a new one
147147
t.cancelActiveJobForChat(update.Message.Chat.ID)
148148

149-
currentConv := a.SharedState().ConversationTracker.GetConversation(fmt.Sprintf("telegram:%d", update.Message.Chat.ID))
150-
151149
// Clean up the message by removing bot mentions
152150
message := strings.ReplaceAll(update.Message.Text, "@"+botInfo.Username, "")
153-
message = strings.TrimSpace(message)
151+
update.Message.Text = strings.TrimSpace(message)
154152

155153
// Send initial placeholder message
156154
msg, err := b.SendMessage(ctx, &bot.SendMessageParams{
@@ -188,6 +186,8 @@ func (t *Telegram) handleGroupMessage(ctx context.Context, b *bot.Bot, a *agent.
188186
chatMessage,
189187
)
190188

189+
currentConv := a.SharedState().ConversationTracker.GetConversation(fmt.Sprintf("telegram:%d", update.Message.Chat.ID))
190+
191191
// Create a new job with the conversation history and metadata
192192
job := types.NewJob(
193193
types.WithConversationHistory(currentConv),

0 commit comments

Comments
 (0)