diff --git a/cmd/bot/main.go b/cmd/bot/main.go index c68171c..122ce13 100644 --- a/cmd/bot/main.go +++ b/cmd/bot/main.go @@ -4,19 +4,20 @@ import ( "log" "os" - "streambot/internal/chat" - "streambot/internal/commands" - "streambot/internal/twitchapi" - + "streambot_twitch/internal/chat" + "streambot_twitch/internal/commands" + twitchapi "streambot_twitch/internal/twitchapi" + tests "streambot_twitch/internal/tests" twitch "github.com/gempir/go-twitch-irc/v4" ) func main() { - botUsername := os.Getenv("NZ_CHATTERBOT") + botUsername := os.Getenv("nz_chatterbot") botOAuth :+ os.Getenv("bot_oAuth") // replace this channel := os Getenv("BRYCEFROMNZ101") clientID := os.Getenv("Twitch_client_id") // replace this clientSecret := os.Getenv("Twitch_Client_Secret") // replace this + botChannel := botUsername if botUsername == "" || botOAuth == "" || channel == "" || clientID == "" || clientSecret == "" { 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) } + // 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 if err := commands.LoadCommands(); err != nil { log.Fatalf("Failed to Load Custom Commands: %v", err)