Phase 1 MVP — echo bot factory
All checks were successful
Docker Build / build-and-push-image (push) Successful in 1m8s

This commit is contained in:
2026-05-09 12:23:59 +02:00
commit ee832de089
28 changed files with 1376 additions and 0 deletions

33
handler_echo.go Normal file
View File

@@ -0,0 +1,33 @@
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
}