Prevent unneeded updates

This commit is contained in:
Alexander Dörflinger
2025-12-12 09:49:56 +01:00
parent 725579cc7d
commit 399dba03ec

View File

@@ -14,6 +14,7 @@ import config
# ==============================================================================
class DatabaseManager:
def __init__(self, db_name="christmas_event.db"):
self.conn = sqlite3.connect(db_name, check_same_thread=False)
self.cursor = self.conn.cursor()
@@ -164,6 +165,10 @@ class SafetyFilter:
# ==============================================================================
class ChristmasBot:
# Store the last updated data to prevent unneeded updates.
last_updated_data = None
def __init__(self):
print("🎄 Initializing Christmas Helper...")
self.reddit = praw.Reddit(
@@ -211,6 +216,11 @@ class ChristmasBot:
print("📝 Updating Forest Dashboard...")
data = self.db.get_forest_data()
if self.last_updated_data and self.last_updated_data == data:
# Nothing changed.
print(f"No change in dashboard, last checked {now}...", end="\r")
return
body = "# 🎄 The Christmas Forest 🎄\n\n"
body += "### How to Participate:\n"
body += "1. Send a DM to u/{}\n".format(config.username)