Skip to content

Commit

Permalink
this should probably fix issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Oct 2, 2020
1 parent 1d1190f commit 2643428
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
31 changes: 31 additions & 0 deletions one_time_index_r.py
Original file line number Diff line number Diff line change
@@ -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())
5 changes: 4 additions & 1 deletion sample_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
SHARE_BUTTON_TEXT = 'Checkout {username} for searching files'

USER_SESSION = 'User_Bot'
USER_CHANNELS = [-10012345678, -100987654321, 'channelusername']

0 comments on commit 2643428

Please sign in to comment.