42 lines
876 B
Go
42 lines
876 B
Go
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...")
|
|
}
|