main
parent
ffc70d4648
commit
e9bf59e122
3 changed files with 58 additions and 18 deletions
@ -1,13 +1,43 @@ |
||||
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() *Service { |
||||
return &Service{} |
||||
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 |
||||
} |
||||
|
Loading…
Reference in new issue