Fixed timer bug

This commit is contained in:
2024-10-31 22:18:21 +03:30
parent 51fc4cb3fa
commit 0830847336

View File

@@ -8,7 +8,7 @@ using Telegram.Bot.Types.Enums;
public class MastodonBot public class MastodonBot
{ {
private static Timer _timer; private static Timer _postFetchTimer, _backupTimer;
private static async Task Main() private static async Task Main()
{ {
@@ -84,9 +84,9 @@ public class MastodonBot
} }
// Set a timer to fetch and process posts every 15 minutes // Set a timer to fetch and process posts every 15 minutes
_timer = new Timer(async _ => await RunCheck.runAsync(db, bot, config.TAG, logger, config.INSTANCE), null, TimeSpan.Zero, TimeSpan.FromMinutes(15)); _postFetchTimer = new Timer(async _ => await RunCheck.runAsync(db, bot, config.TAG, logger, config.INSTANCE), null, TimeSpan.Zero, TimeSpan.FromMinutes(15));
// Another timer to automatically backup the DB every 1 hour // Another timer to automatically backup the DB every 1 hour
_timer = new Timer(async _ => await HandleDbBackup.HandleDbBackupAsync(bot, logger, config.DB_NAME, config.ADMIN_NUMID, db), null, TimeSpan.Zero, TimeSpan.FromHours(1)); _backupTimer = new Timer(async _ => await HandleDbBackup.HandleDbBackupAsync(bot, logger, config.DB_NAME, config.ADMIN_NUMID, db), null, TimeSpan.Zero, TimeSpan.FromHours(1));
// Keep the bot running // Keep the bot running
await Task.Delay(-1); await Task.Delay(-1);
} }