karaokards/main.go

52 lines
1.5 KiB
Go
Raw Normal View History

package main
import (
"fmt"
"math/rand"
"os"
2020-02-13 15:18:44 +00:00
"time"
2020-02-13 15:18:44 +00:00
irc "git.martyn.berlin/martyn/karaokards/internal/irc"
)
func main() {
rand.Seed(time.Now().UnixNano())
for _, val := range karaokards {
2020-02-13 15:18:44 +00:00
selectablePrompts = append(selectablePrompts, val)
}
for _, val := range readBonusStrings() {
2020-02-13 15:18:44 +00:00
selectablePrompts = append(selectablePrompts, val)
}
2020-02-13 15:18:44 +00:00
fmt.Println(len(selectablePrompts), " prompts available.")
oauthPath := ""
if os.Getenv("TWITCH_OAUTH_JSON") != "" {
if _, err := os.Stat(os.Getenv("TWITCH_OAUTH_JSON")); os.IsNotExist(err) {
2020-02-13 15:18:44 +00:00
os.Exit(1)
}
oauthPath = os.Getenv("TWITCH_OAUTH_JSON")
} else {
2020-02-13 15:18:44 +00:00
if _, err := os.Stat(os.Getenv("HOME") + "/.twitch/oauth.json"); os.IsNotExist(err) {
rgb.YPrintf("[%s] Warning %s doesn't exist, trying %s next!\n", timeStamp(), os.Getenv("HOME")+"/.twitch/oauth.json", "/etc/twitch/oauth.json")
if _, err := os.Stat("/etc/twitch/oauth.json"); os.IsNotExist(err) {
2020-02-13 15:18:44 +00:00
rgb.YPrintf("[%s] Error %s doesn't exist either, bailing!\n", timeStamp(), "/etc/twitch/oauth.json")
os.Exit(1)
}
2020-02-13 15:18:44 +00:00
oauthPath = "/etc/twitch/oauth.json"
} else {
2020-02-13 15:18:44 +00:00
oauthPath = os.Getenv("HOME") + "/.twitch/oauth.json"
}
}
// Replace the channel name, bot name, and the path to the private directory with your respective
// values.
2020-02-13 15:18:44 +00:00
myBot := irc.KardBot{
Channel: "imartynontwitch",
MsgRate: time.Duration(20/30) * time.Millisecond,
Name: "Karaokards",
Port: "6667",
PrivatePath: oauthPath,
Server: "irc.chat.twitch.tv",
}
myBot.Start()
2020-02-13 15:18:44 +00:00
}