| from FastTelethonhelper import fast_download |
| from FastTelethonhelper import fast_upload |
| from telethon import TelegramClient, events,sync |
| import asyncio |
| import os |
|
|
| app_id = os.getenv("APP_ID") |
| api_hash = os.getenv("API_HASH") |
| btoken = os.getenv("BOT") |
| chnl = os.getenv("CHN") |
| p = os.getenv("DBS") |
|
|
| api_id = int(app_id) |
| api_hash = str(api_hash) |
| bot_token = str(btoken) |
| channel= int(chnl) |
|
|
| p = str(p) |
|
|
| async def downdb(): |
| client = TelegramClient(None, api_id, api_hash) |
| await client.start(bot_token=bot_token) |
| |
| os.remove('instance/database.db') |
| @client.on(events.NewMessage) |
| async def handler(event): |
| last_message = event.message |
| await fast_download(client,last_message) |
| await asyncio.sleep(10) |
| await client.disconnect() |
| |
|
|
| return '2' |
| print(p) |
| if p=='1': |
| print('database sync event') |
| loop = asyncio.new_event_loop() |
| asyncio.set_event_loop(loop) |
| rp = loop.run_until_complete(downdb()) |
| print('done') |
|
|