25 lines
598 B
Go
25 lines
598 B
Go
package botIO
|
|
|
|
import (
|
|
"watn3y/bloaterbot/config"
|
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func Authenticate() (tgbotapi.UpdatesChannel, *tgbotapi.BotAPI) {
|
|
|
|
bot, err := tgbotapi.NewBotAPI(config.BotConfig.APIToken)
|
|
|
|
if err != nil {
|
|
log.Panic().Err(err).Msg("Failed to authorize bot")
|
|
}
|
|
|
|
bot.Debug = config.BotConfig.DebugMode
|
|
|
|
updates := tgbotapi.NewUpdate(0)
|
|
updates.Timeout = 60
|
|
|
|
log.Info().Int64("ID", bot.Self.ID).Str("username", bot.Self.UserName).Msg("Successfully authorized bot")
|
|
|
|
return bot.GetUpdatesChan(updates), bot
|
|
}
|