From 26434280f876f608ea05d27bddfd84bd55206375 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Fri, 2 Oct 2020 18:19:18 +0530 Subject: [PATCH] this should probably fix issue #1 --- info.py | 4 ++++ one_time_index_r.py | 31 +++++++++++++++++++++++++++++++ sample_info.py | 5 ++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 one_time_index_r.py diff --git a/info.py b/info.py index 3fd69fe..2127643 100644 --- a/info.py +++ b/info.py @@ -28,3 +28,7 @@ """ SHARE_BUTTON_TEXT = 'Checkout {username} for searching files' + + +USER_SESSION = environ.get('USER_SESSION', 'User_Bot') +USER_CHANNELS = [int(channel) if re.search('^-100\d+$', channel) else channel for channel in environ['CHANNELS'].split()] diff --git a/one_time_index_r.py b/one_time_index_r.py new file mode 100644 index 0000000..4d27209 --- /dev/null +++ b/one_time_index_r.py @@ -0,0 +1,31 @@ +import asyncio +from pyrogram import Client +from info import SESSION, USER_SESSION, API_ID, API_HASH, USER_CHANNELS, BOT_TOKEN +from utils import save_file + + +async def moin(): + app = Client(USER_SESSION, API_ID, API_HASH) + await app.start() + bot = Client(SESSION, API_ID, API_HASH, bot_token=BOT_TOKEN) + await bot.start() + for channel in USER_CHANNELS: + async for user_message in app.iter_history(channel): + message = await bot.get_messages( + channel, + user_message.message_id, + replies=0 + ) + print(message) + for file_type in ("document", "video", "audio"): + media = getattr(message, file_type, None) + if media is not None: + break + else: + continue + media.file_type = file_type + media.caption = message.caption + await save_file(media) + + +asyncio.run(moin()) diff --git a/sample_info.py b/sample_info.py index 5f42acd..896a227 100644 --- a/sample_info.py +++ b/sample_info.py @@ -24,4 +24,7 @@ Here you can search files in inline mode. Just press follwing buttons and start searching. """ -SHARE_BUTTON_TEXT = 'Checkout {username} for searching files' \ No newline at end of file +SHARE_BUTTON_TEXT = 'Checkout {username} for searching files' + +USER_SESSION = 'User_Bot' +USER_CHANNELS = [-10012345678, -100987654321, 'channelusername']