Proceed with role management

This commit is contained in:
HugeFrog24
2024-10-22 15:50:51 +02:00
parent acaf5d01ab
commit ce59b5f5f1
6 changed files with 172 additions and 73 deletions

14
main.go
View File

@@ -52,14 +52,24 @@ func main() {
go func(cfg BotConfig) {
defer wg.Done()
// Create Bot instance with RealClock
// Create Bot instance without TelegramClient initially
realClock := RealClock{}
bot, err := NewBot(db, cfg, realClock)
bot, err := NewBot(db, cfg, realClock, nil)
if err != nil {
log.Printf("Error creating bot %s: %v", cfg.ID, err)
return
}
// Initialize TelegramClient with the bot's handleUpdate method
tgClient, err := initTelegramBot(cfg.TelegramToken, bot.handleUpdate)
if err != nil {
log.Printf("Error initializing Telegram client for bot %s: %v", cfg.ID, err)
return
}
// Assign the TelegramClient to the bot
bot.tgBot = tgClient
// Start the bot
log.Printf("Starting bot %s...", cfg.ID)
bot.Start(ctx)