File size: 1,655 Bytes
9ff40ac
d30be39
 
 
 
 
 
9ff40ac
 
 
 
 
 
 
 
d30be39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ff40ac
 
 
d30be39
 
 
9ff40ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import asyncio
from flask import Flask
from threading import Thread
import random
import time
import requests
import logging

# uvloop is optional, but it's recommended to install it for better performance of pyrogram
try:
  import uvloop
except:
  print("uvloop is not installed")

from pyrogram import Client
from config import API_ID, API_HASH, BOT_TOKEN, REPL_URL

app = Flask("")

@app.route("/")
def home():
    return "You have found the home of a Python program!"

def run():
    app.run()

# def ping(target, debug):
#     while True:
#         r = requests.get(target)
#         if debug == True:
#             print("Status Code: " + str(r.status_code))
#         time.sleep(random.randint(
#             180, 300))  # alternate ping time between 3 and 5 minutes

# def awake(target, debug=False):
#     log = logging.getLogger("werkzeug")
#     log.disabled = True
#     app.logger.disabled = True
#     t = Thread(target=run)
#     r = Thread(
#         target=ping,
#         args=(
#             target,
#             debug,
#         ),
#     )
#     t.start()
#     r.start()

if __name__ == '__main__':

  # # If you are deploying on Replit, you can use this code to keep your bot alive
  # if 'y' in input('Are you deploying on Replit? (y/n): ').lower():
  #   awake(REPL_URL, False)

  # Setting up uvloop
  try:
    uvloop.install()
  except:
    print("Could not apply uvloop on project")

  # Defining path to plugins
  plugins = dict(root="plugins")

  # Defining the pyrogram client's instance
  Client("UploadBot",
         api_id=API_ID,
         api_hash=API_HASH,
         bot_token=BOT_TOKEN,
         plugins=plugins).run()