Impliment startup tests
IRC & Channel Connections
This commit is contained in:
@@ -4,19 +4,20 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"streambot/internal/chat"
|
"streambot_twitch/internal/chat"
|
||||||
"streambot/internal/commands"
|
"streambot_twitch/internal/commands"
|
||||||
"streambot/internal/twitchapi"
|
twitchapi "streambot_twitch/internal/twitchapi"
|
||||||
|
tests "streambot_twitch/internal/tests"
|
||||||
twitch "github.com/gempir/go-twitch-irc/v4"
|
twitch "github.com/gempir/go-twitch-irc/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
botUsername := os.Getenv("NZ_CHATTERBOT")
|
botUsername := os.Getenv("nz_chatterbot")
|
||||||
botOAuth :+ os.Getenv("bot_oAuth") // replace this
|
botOAuth :+ os.Getenv("bot_oAuth") // replace this
|
||||||
channel := os Getenv("BRYCEFROMNZ101")
|
channel := os Getenv("BRYCEFROMNZ101")
|
||||||
clientID := os.Getenv("Twitch_client_id") // replace this
|
clientID := os.Getenv("Twitch_client_id") // replace this
|
||||||
clientSecret := os.Getenv("Twitch_Client_Secret") // replace this
|
clientSecret := os.Getenv("Twitch_Client_Secret") // replace this
|
||||||
|
botChannel := botUsername
|
||||||
|
|
||||||
if botUsername == "" || botOAuth == "" || channel == "" || clientID == "" || clientSecret == "" {
|
if botUsername == "" || botOAuth == "" || channel == "" || clientID == "" || clientSecret == "" {
|
||||||
log.Fatal("Please set Bot_Username, Bot_OAuth, Channel, Twitch_Client_ID, and Twitch_Client_Secret env vars")
|
log.Fatal("Please set Bot_Username, Bot_OAuth, Channel, Twitch_Client_ID, and Twitch_Client_Secret env vars")
|
||||||
@@ -28,6 +29,20 @@ func main() {
|
|||||||
log.Fatalf("Failed to create Twitch API client: %v", err)
|
log.Fatalf("Failed to create Twitch API client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// run Tests
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Startup Test failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
botClient := twitch.NewClient(botUsername, botOAuth)
|
||||||
|
|
||||||
|
if err := tests.TestIRCConnection(botClient, []string{botChannel, streamerChannel}); err != nil {
|
||||||
|
log.Fatalf("Startup test failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("All startup tests passed. Starting bot. . .")
|
||||||
|
// END of TESTS
|
||||||
|
|
||||||
// load custom commands
|
// load custom commands
|
||||||
if err := commands.LoadCommands(); err != nil {
|
if err := commands.LoadCommands(); err != nil {
|
||||||
log.Fatalf("Failed to Load Custom Commands: %v", err)
|
log.Fatalf("Failed to Load Custom Commands: %v", err)
|
||||||
|
Reference in New Issue
Block a user