first commit

This commit is contained in:
Kevin Thompson
2025-06-13 19:43:16 -05:00
commit c7b9e661f5
5 changed files with 307 additions and 0 deletions

41
cmd/main.go Normal file
View File

@ -0,0 +1,41 @@
package main
import (
"log"
"os"
"os/signal"
"syscall"
"twitch-fish-bot/internal/clients"
"twitch-fish-bot/internal/config"
)
func main() {
// Load configuration
cfg := config.Load()
// Create and start the bot
bot := clients.NewTwitchBot(cfg.Username, cfg.OAuth, cfg.ClientID, cfg.Channel)
// Connect to Twitch
if err := bot.Connect(); err != nil {
log.Fatalf("Failed to connect: %v", err)
}
defer bot.Close()
// Start message handler in goroutine
go bot.HandleMessages()
// Start the fish timer in goroutine
go bot.StartFishTimer()
log.Printf("Bot started successfully! Sending !fish every 5 minutes to #%s", cfg.Channel)
log.Println("Press Ctrl+C to stop the bot")
// Wait for interrupt signal to gracefully shutdown
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c
log.Println("Shutting down bot...")
}