Update bot.py
Browse files
bot.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
-
# bot.py
|
2 |
-
|
3 |
import os, math, logging, datetime, pytz, logging.config
|
|
|
4 |
from pyrogram import Client, types
|
5 |
from database.users_chats_db import db
|
6 |
from database.ia_filterdb import Media
|
@@ -8,6 +7,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 |
import asyncio
|
|
|
11 |
|
12 |
# Get logging configurations
|
13 |
logging.config.fileConfig("logging.conf")
|
@@ -64,6 +64,9 @@ class Bot(Client):
|
|
64 |
await web.TCPSite(app, "0.0.0.0", 8080).start()
|
65 |
logger.info("Web Response Is Running......🕸️")
|
66 |
|
|
|
|
|
|
|
67 |
async def stop(self, *args):
|
68 |
logger.info("Stopping bot...")
|
69 |
await super().stop()
|
@@ -86,11 +89,4 @@ class Bot(Client):
|
|
86 |
|
87 |
if __name__ == "__main__":
|
88 |
bot = Bot()
|
89 |
-
|
90 |
-
try:
|
91 |
-
loop.run_until_complete(bot.start())
|
92 |
-
loop.run_forever()
|
93 |
-
except KeyboardInterrupt:
|
94 |
-
loop.run_until_complete(bot.stop())
|
95 |
-
finally:
|
96 |
-
loop.close()
|
|
|
|
|
|
|
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
|
5 |
from database.ia_filterdb import Media
|
|
|
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 |
|
12 |
# Get logging configurations
|
13 |
logging.config.fileConfig("logging.conf")
|
|
|
64 |
await web.TCPSite(app, "0.0.0.0", 8080).start()
|
65 |
logger.info("Web Response Is Running......🕸️")
|
66 |
|
67 |
+
# Run FastAPI app in a separate task
|
68 |
+
asyncio.create_task(uvicorn.run(fastapi_app, host="0.0.0.0", port=8000, log_level="info"))
|
69 |
+
|
70 |
async def stop(self, *args):
|
71 |
logger.info("Stopping bot...")
|
72 |
await super().stop()
|
|
|
89 |
|
90 |
if __name__ == "__main__":
|
91 |
bot = Bot()
|
92 |
+
asyncio.run(bot.start())
|
|
|
|
|
|
|
|
|
|
|
|
|
|