Spaces:
sahanind
/
No application file

File size: 982 Bytes
d846ab4
 
 
 
c3a2267
 
 
 
 
 
c6c50b1
c3a2267
 
 
 
 
 
ac06f0e
d846ab4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ac06f0e
31fbc37
ff73e42
c6c50b1
 
 
31fbc37
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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')