2021-10-13 23:24:02 +02:00
|
|
|
package main
|
|
|
|
|
2021-10-13 23:29:29 +02:00
|
|
|
import (
|
2021-10-19 22:25:47 +02:00
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/gempir/go-twitch-irc/v2"
|
2021-10-13 23:37:46 +02:00
|
|
|
"github.com/lyx0/nourybot/cmd/bot"
|
2021-10-14 00:19:35 +02:00
|
|
|
"github.com/lyx0/nourybot/pkg/config"
|
2021-10-19 22:25:47 +02:00
|
|
|
"github.com/lyx0/nourybot/pkg/handlers"
|
2021-10-13 23:29:29 +02:00
|
|
|
)
|
|
|
|
|
2021-10-19 22:25:47 +02:00
|
|
|
var nb *bot.Bot
|
|
|
|
|
2021-10-13 23:24:02 +02:00
|
|
|
func main() {
|
2021-10-19 22:25:47 +02:00
|
|
|
conf := config.LoadConfig()
|
|
|
|
|
|
|
|
nb = &bot.Bot{
|
|
|
|
TwitchClient: twitch.NewClient(conf.Username, conf.Oauth),
|
|
|
|
Uptime: time.Now(),
|
|
|
|
}
|
2021-10-13 23:29:29 +02:00
|
|
|
|
2021-10-19 22:25:47 +02:00
|
|
|
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
|
|
|
|
}
|
2021-10-13 23:37:46 +02:00
|
|
|
|
2021-10-19 22:25:47 +02:00
|
|
|
// So that the bot doesn't repeat itself.
|
|
|
|
if message.Tags["user-id"] == "596581605" {
|
|
|
|
return
|
|
|
|
}
|
2021-10-13 23:37:46 +02:00
|
|
|
|
2021-10-19 22:25:47 +02:00
|
|
|
handlers.PrivateMessage(message, nb)
|
|
|
|
})
|
2021-10-19 22:33:08 +02:00
|
|
|
|
2021-10-19 23:27:55 +02:00
|
|
|
nb.TwitchClient.Join("nouryqt", "nourybot")
|
|
|
|
nb.Send("nourybot", "HeyGuys")
|
2021-10-19 22:33:08 +02:00
|
|
|
nb.TwitchClient.Connect()
|
2021-10-13 23:24:02 +02:00
|
|
|
}
|