Skip to content

Commit

Permalink
Merge pull request #56 from IMS-Network/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
thefourcraft authored Jan 8, 2025
2 parents 91cde1c + 0426d4d commit a75cc87
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions export_idf_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
endpoint_url=R2_ENDPOINT_URL,
)

# Initialize the Telegram client
client = TelegramClient('session_name', API_ID, API_HASH)

# Ensure consistent paths for S3 and URLs
def normalize_file_key(file_path):
return posixpath.normpath(file_path).replace("\\", "/")
Expand Down Expand Up @@ -92,6 +95,18 @@ def scan_and_upload_existing():
if os.path.getsize(file_path) > FILE_SIZE_THRESHOLD_MB * 1024 * 1024:
upload_to_r2(file_path, R2_BUCKET_NAME)

# Function to load the last message ID from a state file
def load_last_message_id():
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)
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)

# Function to process messages
def process_messages():
print("Starting Telegram scraping...")
Expand Down

0 comments on commit a75cc87

Please sign in to comment.