mirror of
https://github.com/HugeFrog24/go-telegram-bot.git
synced 2026-03-02 00:14:34 +00:00
MVP
md formatting doesnt work yet Started implementing owner feature Add .gitattributes to enforce LF line endings Temporary commit before merge Updated owner management Updated json and gitignore Proceed with role management Again, CI Fix some lint errors Implemented screening Per-bot API keys implemented Use getRoleByName func Fix unused imports Upgrade actions rm unused function Upgrade action Fix unaddressed errors
This commit is contained in:
26
main.go
Executable file → Normal file
26
main.go
Executable file → Normal file
@@ -24,9 +24,6 @@ func main() {
|
||||
log.Printf("Error loading .env file: %v", err)
|
||||
}
|
||||
|
||||
// Check for required environment variables
|
||||
checkRequiredEnvVars()
|
||||
|
||||
// Initialize database
|
||||
db, err := initDB()
|
||||
if err != nil {
|
||||
@@ -52,14 +49,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)
|
||||
@@ -79,12 +86,3 @@ func initLogger() (*os.File, error) {
|
||||
log.SetOutput(mw)
|
||||
return logFile, nil
|
||||
}
|
||||
|
||||
func checkRequiredEnvVars() {
|
||||
requiredEnvVars := []string{"ANTHROPIC_API_KEY"}
|
||||
for _, envVar := range requiredEnvVars {
|
||||
if os.Getenv(envVar) == "" {
|
||||
log.Fatalf("%s environment variable is not set", envVar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user