TelegramTelethonScraper: Use channel_id when channel has been previously encountered

This commit is contained in:
Logan Williams
2022-03-31 16:37:54 +02:00
parent 061af984ee
commit 94cf6c3d84
2 changed files with 10 additions and 4 deletions

View File

@@ -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}'

View File

@@ -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,