Files
streambot_twitch/cmd/bot/main.go
bryce 74905368df files Completed & new dir & file created
Main.go, Client.go, [DIR] /internal/storage [file] games.json
2025-07-05 20:45:10 +12:00

51 lines
1.3 KiB
Go

package main
import (
"log"
"os"
"streambot/internal/chat"
"streambot/internal/commands"
"streambot/internal/twitchapi"
twitch "github.com/gempir/go-twitch-irc/v4"
)
func main() {
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
if botUsername == "" || botOAuth == "" || channel == "" || clientID == "" || clientSecret == "" {
log.Fatal("Please set Bot_Username, Bot_OAuth, Channel, Twitch_Client_ID, and Twitch_Client_Secret env vars")
}
// init Twitch API client
apiClient, err := twitchapi.NewClient(clientID, clientSecret)
if err != nil {
log.Fatalf("Failed to create Twitch API client: %v", err)
}
// load custom commands
if err := commands.LoadCommands(); err != nil {
log.Fatalf("Failed to Load Custom Commands: %v", err)
}
// Create Twitch IRC client
client := twitch.NewClient(botUsername, botOAuth)
client.Join(channel)
// Setup Chat handler
client.OnPrivateMessage(func(message twitch.PrivateMessage) {
chat.HandleMessage(client, apiClient, message)
})
if err := client.Connect(); err != nil {
log.Fatalf("Error connecting to Twitch Chat: %v", err)
}
}