Manishx commited on
Commit
5f5d900
1 Parent(s): f289e03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -25,17 +25,31 @@ def run():
25
  app.run()
26
 
27
  if __name__ == '__main__':
28
- # Set webhook for bot
 
 
 
 
 
 
 
 
 
 
29
  bot = Client("UploadBot",
30
  api_id=API_ID,
31
  api_hash=API_HASH,
32
- bot_token=BOT_TOKEN)
33
- bot.start()
 
 
34
  bot.set_webhook(url=f"{REPL_URL}/{BOT_TOKEN}")
35
 
36
- # Start Flask app in a separate thread
37
- t = Thread(target=run)
38
- t.start()
 
 
 
 
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