package main import ( "context" "fmt" "strings" ) type EchoHandler struct { tg *TelegramClient } func (e *EchoHandler) Handle(ctx context.Context, update Update, bot Bot) error { chatID, ok := update.ChatID() if !ok { return nil } text := strings.TrimSpace(update.Text()) if text == "" { return nil } reply := text if strings.HasPrefix(text, "/echo") { reply = strings.TrimSpace(strings.TrimPrefix(text, "/echo")) if reply == "" { reply = "echo bot online — send me anything" } } if err := e.tg.SendMessage(ctx, bot.Token, SendMessageParams{ChatID: chatID, Text: reply}); err != nil { return fmt.Errorf("sendMessage: %w", err) } return nil }