mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
42 lines
836 B
Go
42 lines
836 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/gempir/go-twitch-irc/v2"
|
|
"github.com/lyx0/nourybot/cmd/bot"
|
|
"github.com/lyx0/nourybot/pkg/config"
|
|
"github.com/lyx0/nourybot/pkg/handlers"
|
|
)
|
|
|
|
var nb *bot.Bot
|
|
|
|
func main() {
|
|
conf := config.LoadConfig()
|
|
|
|
nb = &bot.Bot{
|
|
TwitchClient: twitch.NewClient(conf.Username, conf.Oauth),
|
|
Uptime: time.Now(),
|
|
}
|
|
|
|
nb.TwitchClient.OnPrivateMessage(func(message twitch.PrivateMessage) {
|
|
// If channelID is missing something must have gone wrong.
|
|
channelID := message.Tags["room-id"]
|
|
if channelID == "" {
|
|
fmt.Printf("Missing room-id tag in message")
|
|
return
|
|
}
|
|
|
|
// So that the bot doesn't repeat itself.
|
|
if message.Tags["user-id"] == "596581605" {
|
|
return
|
|
}
|
|
|
|
handlers.PrivateMessage(message, nb)
|
|
})
|
|
|
|
nb.TwitchClient.Join("nourybot")
|
|
nb.TwitchClient.Connect()
|
|
}
|