package client import ( "bytes" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" "go.uber.org/zap" "penahub.gitlab.yandexcloud.net/backend/verification/internal/models" "text/template" ) type Telegram struct { logger *zap.Logger bot *tgbotapi.BotAPI chatID int64 } func NewTelegram(logger *zap.Logger, bot *tgbotapi.BotAPI, chatID int64) *Telegram { return &Telegram{logger: logger, bot: bot, chatID: chatID} } func (t *Telegram) SendVerification(data *models.Verification, isUpdate bool) error { tplPath := "assets/new_verification.txt" if isUpdate { tplPath = "assets/updated_verification.txt" } tpl, err := template.ParseFiles(tplPath) if err != nil { return err } var text bytes.Buffer err = tpl.Execute(&text, data) if err != nil { t.logger.Error("ClientTelegram", zap.Error(err)) return err } msg := tgbotapi.NewMessage(t.chatID, text.String()) _, err = t.bot.Send(msg) if err != nil { t.logger.Error("ClientTelegram", zap.Error(err)) return err } return nil }