Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,17 +25,31 @@ def run():
|
|
25 |
app.run()
|
26 |
|
27 |
if __name__ == '__main__':
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
bot = Client("UploadBot",
|
30 |
api_id=API_ID,
|
31 |
api_hash=API_HASH,
|
32 |
-
bot_token=BOT_TOKEN
|
33 |
-
|
|
|
|
|
34 |
bot.set_webhook(url=f"{REPL_URL}/{BOT_TOKEN}")
|
35 |
|
36 |
-
# Start
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
# Start bot polling
|
41 |
-
bot.polling(interval=0, timeout=30)
|
|
|
25 |
app.run()
|
26 |
|
27 |
if __name__ == '__main__':
|
28 |
+
|
29 |
+
# Setting up uvloop
|
30 |
+
try:
|
31 |
+
uvloop.install()
|
32 |
+
except:
|
33 |
+
print("Could not apply uvloop on project")
|
34 |
+
|
35 |
+
# Defining path to plugins
|
36 |
+
plugins = dict(root="plugins")
|
37 |
+
|
38 |
+
# Defining the pyrogram client's instance
|
39 |
bot = Client("UploadBot",
|
40 |
api_id=API_ID,
|
41 |
api_hash=API_HASH,
|
42 |
+
bot_token=BOT_TOKEN,
|
43 |
+
plugins=plugins)
|
44 |
+
|
45 |
+
# Set webhook
|
46 |
bot.set_webhook(url=f"{REPL_URL}/{BOT_TOKEN}")
|
47 |
|
48 |
+
# Start the flask app in a separate thread
|
49 |
+
flask_thread = Thread(target=run)
|
50 |
+
flask_thread.start()
|
51 |
+
|
52 |
+
# Start the bot
|
53 |
+
bot.start()
|
54 |
+
bot.idle()
|
55 |
|
|
|
|