You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
670 B
43 lines
670 B
package telegram
|
|
|
|
import (
|
|
"log"
|
|
|
|
// transport "git.slaventius.ru/test3k/authPostman/internal/transport"
|
|
|
|
api "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
|
)
|
|
|
|
type Message struct {
|
|
api.Message
|
|
ChatID int64
|
|
Text string
|
|
}
|
|
|
|
type Service struct {
|
|
*api.BotAPI
|
|
}
|
|
|
|
func NewService(token string) *Service {
|
|
bot, err := api.NewBotAPI(token)
|
|
if err != nil {
|
|
log.Panic(err)
|
|
}
|
|
|
|
return &Service{
|
|
bot,
|
|
}
|
|
}
|
|
|
|
func (s *Service) NewMessage(chatID int64, text string) api.MessageConfig {
|
|
return api.NewMessage(chatID, text)
|
|
}
|
|
|
|
func (s *Service) SendMessage(message api.Chattable) error {
|
|
_, err := s.Send(message)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return err
|
|
}
|
|
|