GenAtoZ / main.py
Manishx's picture
third
d30be39
raw
history blame
1.66 kB
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()