From 66eeeee7dcfa452570fd857a2f17a77e71cf06cb Mon Sep 17 00:00:00 2001 From: lyx0 Date: Wed, 13 Oct 2021 21:39:34 +0200 Subject: [PATCH] Connect Disconnect --- bot/bot.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/bot/bot.go b/bot/bot.go index 5a608bd..edca0f7 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -12,11 +12,6 @@ type Bot struct { log *log.Logger } -func (b *Bot) newTwitchClient() *twitch.Client { - twitchClient := twitch.NewClient(b.cfg.Username, b.cfg.Oauth) - return twitchClient -} - func NewBot(cfg *cfg.Config, log *log.Logger, twitchClient *twitch.Client) *Bot { return &Bot{ cfg: cfg, @@ -24,3 +19,26 @@ func NewBot(cfg *cfg.Config, log *log.Logger, twitchClient *twitch.Client) *Bot log: log, } } + +func (b *Bot) newTwitchClient() *twitch.Client { + twitchClient := twitch.NewClient(b.cfg.Username, b.cfg.Oauth) + return twitchClient +} + +func (b *Bot) Connect() error { + err := b.twitchClient.Connect() + if err != nil { + log.Error("Error Connecting from Twitch: ", err) + } + + return err +} + +func (b *Bot) Disconnect() error { + err := b.twitchClient.Disconnect() + if err != nil { + log.Error("Error Disconnecting from Twitch: ", err) + } + + return err +}