This commit is contained in:
lyx0 2021-10-13 23:24:02 +02:00
parent 325b244f92
commit 64b449252f
3 changed files with 8 additions and 15 deletions

View file

@ -12,7 +12,9 @@ type Bot struct {
log *log.Logger log *log.Logger
} }
func NewBot(cfg *cfg.Config, log *log.Logger, twitchClient *twitch.Client) *Bot { func NewBot(cfg *cfg.Config, log *log.Logger) *Bot {
twitchClient := twitch.NewClient(cfg.Username, cfg.Oauth)
return &Bot{ return &Bot{
cfg: cfg, cfg: cfg,
twitchClient: twitchClient, twitchClient: twitchClient,
@ -20,11 +22,6 @@ func NewBot(cfg *cfg.Config, log *log.Logger, twitchClient *twitch.Client) *Bot
} }
} }
func (b *Bot) newTwitchClient() *twitch.Client {
twitchClient := twitch.NewClient(b.cfg.Username, b.cfg.Oauth)
return twitchClient
}
func (b *Bot) Connect() error { func (b *Bot) Connect() error {
err := b.twitchClient.Connect() err := b.twitchClient.Connect()
if err != nil { if err != nil {
@ -44,8 +41,7 @@ func (b *Bot) Disconnect() error {
} }
func (b *Bot) Say(channel string, message string) { func (b *Bot) Say(channel string, message string) {
tc := b.newTwitchClient() b.twitchClient.Say(channel, message)
tc.Say(channel, message)
} }
func (b *Bot) OnPrivateMessage(callback func(message *twitch.PrivateMessage)) { func (b *Bot) OnPrivateMessage(callback func(message *twitch.PrivateMessage)) {

4
cmd/main.go Normal file
View file

@ -0,0 +1,4 @@
package main
func main() {
}

View file

@ -1,7 +0,0 @@
package main
import "fmt"
func main() {
fmt.Println("hello")
}