2020-02-12 15:50:45 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"math/rand"
|
|
|
|
"os"
|
2020-02-13 15:18:44 +00:00
|
|
|
"time"
|
2020-02-12 15:50:45 +00:00
|
|
|
|
2020-02-13 15:18:44 +00:00
|
|
|
irc "git.martyn.berlin/martyn/karaokards/internal/irc"
|
2020-02-12 15:50:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
for _, val := range karaokards {
|
2020-02-13 15:18:44 +00:00
|
|
|
selectablePrompts = append(selectablePrompts, val)
|
2020-02-12 15:50:45 +00:00
|
|
|
}
|
|
|
|
for _, val := range readBonusStrings() {
|
2020-02-13 15:18:44 +00:00
|
|
|
selectablePrompts = append(selectablePrompts, val)
|
2020-02-12 15:50:45 +00:00
|
|
|
}
|
2020-02-13 15:18:44 +00:00
|
|
|
fmt.Println(len(selectablePrompts), " prompts available.")
|
|
|
|
oauthPath := ""
|
|
|
|
if os.Getenv("TWITCH_OAUTH_JSON") != "" {
|
2020-02-12 15:50:45 +00:00
|
|
|
if _, err := os.Stat(os.Getenv("TWITCH_OAUTH_JSON")); os.IsNotExist(err) {
|
2020-02-13 15:18:44 +00:00
|
|
|
os.Exit(1)
|
2020-02-12 15:50:45 +00:00
|
|
|
}
|
|
|
|
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")
|
2020-02-12 15:50:45 +00:00
|
|
|
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-12 15:50:45 +00:00
|
|
|
}
|
2020-02-13 15:18:44 +00:00
|
|
|
oauthPath = "/etc/twitch/oauth.json"
|
2020-02-12 15:50:45 +00:00
|
|
|
} else {
|
2020-02-13 15:18:44 +00:00
|
|
|
oauthPath = os.Getenv("HOME") + "/.twitch/oauth.json"
|
2020-02-12 15:50:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// 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{
|
2020-02-12 15:50:45 +00:00
|
|
|
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
|
|
|
}
|