Spaces:
Sleeping
Sleeping
File size: 1,192 Bytes
9ff40ac f289e03 d30be39 f289e03 9ff40ac 8a15f00 d30be39 9ff40ac 5f5d900 f289e03 5f5d900 eb736da f289e03 5f5d900 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 |
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()
if __name__ == '__main__':
# 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
bot = Client("UploadBot",
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
plugins=plugins)
# Set webhook
bot.set_webhook(url=f"https://manishx-genatoz.hf.space/{BOT_TOKEN}")
# Start the flask app in a separate thread
flask_thread = Thread(target=run)
flask_thread.start()
# Start the bot
bot.start()
bot.idle()
|