ticket-pimp/internal/services/dummy_telegram.go

45 lines
993 B
Go

package services
import (
"ticket-pimp/internal/domain"
"time"
)
type DummyTelegram struct {
*CommonClient
config domain.TelegramConfig
}
func NewDummyClient(conf domain.TelegramConfig) *DummyTelegram {
client := NewClient().
SetTimeout(5 * time.Second)
return &DummyTelegram{
CommonClient: &CommonClient{
Client: client,
},
config: conf,
}
}
type TelegramMessage struct {
ChatID string `json:"chat_id"`
Text string `json:"text"`
DisableNotification bool `json:"disable_notification"`
ParseMode string `json:"parse_mode"`
DisablePreview bool `json:"disable_web_page_preview"`
}
func (tg *DummyTelegram) DummyNotification(id string, text string) {
tg.R().
SetBody(&TelegramMessage{
ChatID: id,
Text: text,
DisableNotification: true,
ParseMode: "HTML",
DisablePreview: true,
}).
Post("https://api.telegram.org/bot" + tg.config.Token + "/sendMessage")
}