Spaces:
Sleeping
Sleeping
third
Browse filesFiles changed (4)
- main.py+42-6
- utils/__pycache__/keep_alive.cpython-311.pycDeleted
- utils/__pycache__/keep_alive.cpython-312.pycDeleted
- utils/keep_alive.pyDeleted-42
12342 unmodified lines789101112131415161718192021import asyncio# uvloop is optional, but it's recommended to install it for better performance of pyrogramtry:2 unmodified linesprint("uvloop is not installed")from pyrogram import Clientfrom config import API_ID, API_HASH, BOT_TOKENfrom utils import keep_aliveif __name__ == '__main__':# If you are deploying on Replit, you can use this code to keep your bot aliveif 'y' in input('Are you deploying on Replit? (y/n): ').lower():from config import REPL_URLkeep_alive.awake(REPL_URL, False)# Setting up uvlooptry:123456789102 unmodified lines131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import asynciofrom flask import Flaskfrom threading import Threadimport randomimport timeimport requestsimport logging# uvloop is optional, but it's recommended to install it for better performance of pyrogramtry:2 unmodified linesprint("uvloop is not installed")from pyrogram import Clientfrom config import API_ID, API_HASH, BOT_TOKEN, REPL_URLapp = 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 uvlooptry:
123456789101112131415161718192021222324252627282930313233343536373839404142from flask import Flaskfrom threading import Threadimport randomimport timeimport requestsimport logging
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()main.py+42-6
utils/__pycache__/keep_alive.cpython-311.pycDeleted
utils/__pycache__/keep_alive.cpython-312.pycDeleted
utils/keep_alive.pyDeleted-42