package botIO

import (
	tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
	"github.com/rs/zerolog/log"
	"watn3y/bloaterbotv3/config"
)

func Authenticate() (tgbotapi.UpdatesChannel, *tgbotapi.BotAPI) {

	b, err := tgbotapi.NewBotAPI(config.BotConfig.APIToken)

	if err != nil {
		log.Panic().Err(err).Msg("Failed to authorize bot")
	}

	b.Debug = config.BotConfig.DebugMode

	u := tgbotapi.NewUpdate(0)
	u.Timeout = 60

	log.Info().Int64("ID", b.Self.ID).Str("username", b.Self.UserName).Msg("Successfully authorized bot")

	return b.GetUpdatesChan(u), b
}