From 94cf6c3d84e7de0e946212edcad1dbe711527965 Mon Sep 17 00:00:00 2001 From: Logan Williams Date: Thu, 31 Mar 2022 16:37:54 +0200 Subject: [PATCH] TelegramTelethonScraper: Use channel_id when channel has been previously encountered --- cisticola/scraper/telegram_telethon.py | 6 ++++++ tests/conftest.py | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cisticola/scraper/telegram_telethon.py b/cisticola/scraper/telegram_telethon.py index fb9a58f..8f7fefa 100644 --- a/cisticola/scraper/telegram_telethon.py +++ b/cisticola/scraper/telegram_telethon.py @@ -115,6 +115,12 @@ class TelegramTelethonScraper(Scraper): phone = os.environ['TELEGRAM_PHONE'] with TelegramClient(phone, api_id, api_hash) as client: + try: + client.get_entity(channel.platform_id) + username = channel.platform_id + except: + logger.info(f"Channel {username} not encountered before") + for post in client.iter_messages(username): post_url = f'{channel.url}/{post.id}' diff --git a/tests/conftest.py b/tests/conftest.py index 684c15d..3bccf81 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -99,12 +99,12 @@ RUMBLE_CHANNEL_KWARGS = { 'notes': ''} TELEGRAM_CHANNEL_KWARGS = { - 'name': 'South West Ohio Proud Boys (test)', - 'platform_id': -1001276612436, + 'name': 'USA Freedom Convoy (test)', + 'platform_id': -1001799578085, 'category': 'test', 'platform': 'Telegram', - 'url': 'https://t.me/SouthwestOhioPB', - 'screenname': 'SouthwestOhioPB', + 'url': 'https://t.me/usafreedomconvoy2022', + 'screenname': 'usafreedomconvoy2022', 'country': 'US', 'influencer': None, 'public': True,