Update bot.py
Browse files
bot.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import os, math, logging, datetime, pytz, logging.config
|
| 2 |
-
|
| 3 |
from aiohttp import web
|
| 4 |
from pyrogram import Client, types
|
| 5 |
from database.users_chats_db import db
|
|
@@ -7,6 +6,9 @@ from database.ia_filterdb import Media
|
|
| 7 |
from typing import Union, Optional, AsyncGenerator
|
| 8 |
from utils import temp, __repo__, __license__, __copyright__, __version__
|
| 9 |
from info import API_ID, API_HASH, BOT_TOKEN, LOG_CHANNEL, UPTIME, WEB_SUPPORT, LOG_MSG
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Get logging configurations
|
| 12 |
logging.config.fileConfig("logging.conf")
|
|
@@ -63,6 +65,9 @@ class Bot(Client):
|
|
| 63 |
await web.TCPSite(app, "0.0.0.0", 8080).start()
|
| 64 |
logger.info("Web Response Is Running......🕸️")
|
| 65 |
|
|
|
|
|
|
|
|
|
|
| 66 |
async def stop(self, *args):
|
| 67 |
logger.info("Stopping bot...")
|
| 68 |
await super().stop()
|
|
@@ -83,4 +88,6 @@ class Bot(Client):
|
|
| 83 |
current += 1
|
| 84 |
logger.info(f"Yielding message with ID: {message.id}")
|
| 85 |
|
| 86 |
-
|
|
|
|
|
|
|
|
|
| 1 |
import os, math, logging, datetime, pytz, logging.config
|
|
|
|
| 2 |
from aiohttp import web
|
| 3 |
from pyrogram import Client, types
|
| 4 |
from database.users_chats_db import db
|
|
|
|
| 6 |
from typing import Union, Optional, AsyncGenerator
|
| 7 |
from utils import temp, __repo__, __license__, __copyright__, __version__
|
| 8 |
from info import API_ID, API_HASH, BOT_TOKEN, LOG_CHANNEL, UPTIME, WEB_SUPPORT, LOG_MSG
|
| 9 |
+
import asyncio
|
| 10 |
+
import uvicorn
|
| 11 |
+
from fastapi_app import app as fastapi_app
|
| 12 |
|
| 13 |
# Get logging configurations
|
| 14 |
logging.config.fileConfig("logging.conf")
|
|
|
|
| 65 |
await web.TCPSite(app, "0.0.0.0", 8080).start()
|
| 66 |
logger.info("Web Response Is Running......🕸️")
|
| 67 |
|
| 68 |
+
# Run FastAPI app in a separate task
|
| 69 |
+
asyncio.create_task(uvicorn.run(fastapi_app, host="0.0.0.0", port=8000, log_level="info"))
|
| 70 |
+
|
| 71 |
async def stop(self, *args):
|
| 72 |
logger.info("Stopping bot...")
|
| 73 |
await super().stop()
|
|
|
|
| 88 |
current += 1
|
| 89 |
logger.info(f"Yielding message with ID: {message.id}")
|
| 90 |
|
| 91 |
+
if __name__ == "__main__":
|
| 92 |
+
bot = Bot()
|
| 93 |
+
asyncio.run(bot.start())
|