Skip to content

Commit

Permalink
Update bot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
VJBots authored Sep 30, 2023
1 parent fca6a52 commit 01325f8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
logging.config.fileConfig('logging.conf')
logging.getLogger().setLevel(logging.INFO)
logging.getLogger("pyrogram").setLevel(logging.ERROR)
logging.getLogger("imdbpy").setLevel(logging.ERROR)
logging.getLogger("cinemagoer").setLevel(logging.ERROR)

from pyrogram import Client, __version__
from pyrogram.raw.all import layer
from database.ia_filterdb import Media
from aiohttp import web
from database.users_chats_db import db
from info import SESSION, API_ID, API_HASH, BOT_TOKEN, LOG_STR
from plugins import web_server
from info import SESSION, LOG_CHANNEL, API_ID, API_HASH, BOT_TOKEN, LOG_STR, PORT
from utils import temp
from typing import Union, Optional, AsyncGenerator
from pyrogram import types
Expand All @@ -24,7 +26,7 @@ def __init__(self):
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
workers=500,
workers=50,
plugins={"root": "plugins"},
sleep_threshold=5,
)
Expand All @@ -40,12 +42,22 @@ async def start(self):
temp.U_NAME = me.username
temp.B_NAME = me.first_name
self.username = '@' + me.username
app = web.AppRunner(await web_server())
await app.setup()
await web.TCPSite(app, "0.0.0.0", PORT).start()
logging.info(f"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.")
logging.info(LOG_STR)
await self.send_message(chat_id=LOG_CHANNEL, text=f"<b>{me.mention} Restarted! 🤖</b>")
chats = await db.get_all_chats()
async for chat in chats:
try:
await self.send_message(chat_id=chat['id'], text="Bot Restarted! 🤖")
except:
pass

async def stop(self, *args):
await super().stop()
logging.info("Bot stopped. Bye.")
logging.info("Bot stopped! Bye...")

async def iter_messages(
self,
Expand Down

0 comments on commit 01325f8

Please sign in to comment.