From 8e5687292bc6ac7c67922cab22793cb73c289a44 Mon Sep 17 00:00:00 2001 From: lyx0 Date: Wed, 13 Oct 2021 23:29:29 +0200 Subject: [PATCH] join say connect works --- bot/bot.go | 12 +++++++++--- cmd/main.go | 11 +++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bot/bot.go b/bot/bot.go index 55fd0e2..d53648e 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -9,20 +9,21 @@ import ( type Bot struct { twitchClient *twitch.Client cfg *cfg.Config - log *log.Logger } -func NewBot(cfg *cfg.Config, log *log.Logger) *Bot { +func NewBot(cfg *cfg.Config) *Bot { + log.Info("fn Newbot") twitchClient := twitch.NewClient(cfg.Username, cfg.Oauth) + return &Bot{ cfg: cfg, twitchClient: twitchClient, - log: log, } } func (b *Bot) Connect() error { + log.Info("fn Connect") err := b.twitchClient.Connect() if err != nil { log.Error("Error Connecting from Twitch: ", err) @@ -47,3 +48,8 @@ func (b *Bot) Say(channel string, message string) { func (b *Bot) OnPrivateMessage(callback func(message *twitch.PrivateMessage)) { log.Info(callback) } + +func (b *Bot) Join(channel string) { + log.Info("fn Join") + b.twitchClient.Join(channel) +} diff --git a/cmd/main.go b/cmd/main.go index da29a2c..b8856ef 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,4 +1,15 @@ package main +import ( + "github.com/lyx0/nourybot/bot" + "github.com/lyx0/nourybot/config" +) + func main() { + cfg := config.LoadConfig() + nb := bot.NewBot(cfg) + + nb.Join("nourybot") + nb.Say("nourybot", "test") + nb.Connect() }