package bot import ( "time" "gopkg.in/telebot.v4" ) type Bot struct { ApiKey string instance *telebot.Bot } func (bot *Bot) Initialize() error { allowedUpdates := []string{ // "chat_member", // "message_reaction", // "message_reaction_count", "message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", } poller := telebot.LongPoller{ Timeout: 10 * time.Second, AllowedUpdates: allowedUpdates, } pref := telebot.Settings{ Token: bot.ApiKey, Poller: &poller, } tbBot, err := telebot.NewBot(pref) if err != nil { return err } bot.instance = tbBot return nil } func (bot *Bot) GetInstance() *telebot.Bot { if bot.instance == nil { panic("bot.GetInstance called before initialization!") } return bot.instance }