Skip to content

Commit fe3ab54

Browse files
committed
updated
1 parent fa22f57 commit fe3ab54

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

cmd/llm/telegram.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,13 @@ func (cmd *TelegramCommand) Run(ctx *Globals) (err error) {
131131

132132
switch evt.Type {
133133
case ui.EventText:
134+
ctx.logger.Print(parent, fmt.Sprintf("Text received: conv=%s len=%d", evt.Context.ConversationID(), len(evt.Text)))
134135
sessionID, err := cmd.resolveSession(parent, ctx, client, evt.Context)
135136
if err != nil {
136137
evt.Context.SendText(parent, fmt.Sprintf("Error: %v", err))
137138
continue
138139
}
139-
if err := cmd.handleChat(parent, evt, client, sessionID); err != nil {
140+
if err := cmd.handleChat(parent, ctx, evt, client, sessionID); err != nil {
140141
evt.Context.SendText(parent, fmt.Sprintf("Error: %v", err))
141142
}
142143
case ui.EventAttachment:
@@ -163,13 +164,14 @@ func (cmd *TelegramCommand) Run(ctx *Globals) (err error) {
163164
}
164165
// If the attachment has caption text, send it as a chat message immediately.
165166
if evt.Text != "" {
166-
if err := cmd.handleChat(parent, evt, client, sessionID); err != nil {
167+
if err := cmd.handleChat(parent, ctx, evt, client, sessionID); err != nil {
167168
evt.Context.SendText(parent, fmt.Sprintf("Error: %v", err))
168169
}
169170
} else {
170171
evt.Context.SendText(parent, fmt.Sprintf("Attached %d file(s). Send a message to use them.", len(evt.Attachments)))
171172
}
172173
case ui.EventCommand:
174+
ctx.logger.Print(parent, fmt.Sprintf("Command received: /%s %v conv=%s", evt.Command, evt.Args, evt.Context.ConversationID()))
173175
sessionID, err := cmd.resolveSession(parent, ctx, client, evt.Context)
174176
if err != nil {
175177
evt.Context.SendText(parent, fmt.Sprintf("Error: %v", err))
@@ -247,6 +249,7 @@ func (cmd *TelegramCommand) handleTelegramCommand(ctx context.Context, evt ui.Ev
247249
}
248250
u := evt.Args[0]
249251
convID := evt.Context.ConversationID()
252+
globals.logger.Print(ctx, fmt.Sprintf("URL queued: url=%s conv=%s", u, convID))
250253
cmd.mu.Lock()
251254
cmd.pendingOpts[convID] = append(cmd.pendingOpts[convID], httpclient.WithChatURL(u))
252255
cmd.mu.Unlock()
@@ -263,7 +266,7 @@ func (cmd *TelegramCommand) handleTelegramCommand(ctx context.Context, evt ui.Ev
263266
}
264267
}
265268

266-
func (cmd *TelegramCommand) handleChat(ctx context.Context, evt ui.Event, client *httpclient.Client, sessionID string) error {
269+
func (cmd *TelegramCommand) handleChat(ctx context.Context, globals *Globals, evt ui.Event, client *httpclient.Client, sessionID string) error {
267270
evt.Context.SetTyping(ctx, true)
268271
evt.Context.StreamStart(ctx)
269272

@@ -275,7 +278,7 @@ func (cmd *TelegramCommand) handleChat(ctx context.Context, evt ui.Event, client
275278
cmd.mu.Unlock()
276279

277280
if len(pending) > 0 {
278-
fmt.Printf("[telegram] handleChat: consuming %d pending opts for conv=%s\n", len(pending), convID)
281+
globals.logger.Print(ctx, fmt.Sprintf("Chat: consuming %d pending opts for conv=%s", len(pending), convID))
279282
}
280283

281284
opts := append(pending, httpclient.WithChatStream(func(role, text string) {

0 commit comments

Comments
 (0)