mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
join say connect works
This commit is contained in:
parent
64b449252f
commit
8e5687292b
12
bot/bot.go
12
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)
|
||||
}
|
||||
|
|
11
cmd/main.go
11
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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue