Skip to content

Commit

Permalink
Add logging for loading and saving last message ID in export_idf_tele…
Browse files Browse the repository at this point in the history
…gram.py
  • Loading branch information
thefourcraft committed Jan 28, 2025
1 parent c116034 commit 2c94217
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion code/telegram/export_idf_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,20 @@ def scan_and_upload_existing():

# Function to load the last message ID from a state file
def load_last_message_id():
print(f"Loading last message ID from {STATE_FILE}")
if os.path.exists(STATE_FILE):
with open(STATE_FILE, "r", encoding="utf-8") as f:
return json.load(f).get("last_message_id", 0)
last_message_id = json.load(f).get("last_message_id", 0)
print(f"Loaded last message ID: {last_message_id}")
return last_message_id
print("State file not found, starting from message ID 0")
return 0

# Function to save the last message ID to a state file
def save_last_message_id(last_message_id):
with open(STATE_FILE, "w", encoding="utf-8") as f:
json.dump({"last_message_id": last_message_id}, f)
print(f"Saved last message ID: {last_message_id}")

# Function to process messages
def process_messages():
Expand Down

0 comments on commit 2c94217

Please sign in to comment.