Prevent unneeded updates
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user