join say connect works

This commit is contained in:
lyx0 2021-10-13 23:29:29 +02:00
parent 64b449252f
commit 8e5687292b
2 changed files with 20 additions and 3 deletions

View file

@ -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)
}

View file

@ -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()
}