Skip to content

Commit

Permalink
Update bot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Mishel-07 authored May 15, 2024
1 parent a0cf8a8 commit 5e1ae54
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
import logging
import logging.config

# Get logging configurations
logging.config.fileConfig('logging.conf')
logging.getLogger().setLevel(logging.INFO)
logging.getLogger("pyrogram").setLevel(logging.ERROR)
logging.getLogger("imdbpy").setLevel(logging.ERROR)
from pyrogram import Client, version


from pyrogram import Client, __version__, filters
from pyrogram.raw.all import layer
from database.ia_filterdb import Media
from Script import script
from database.users_chats_db import db
from info import SESSION, API_ID, API_HASH, BOT_TOKEN, LOG_STR, PORT, LOG_CHANNEL
from info import SESSION, API_ID, API_HASH, BOT_TOKEN, LOG_STR, LOG_CHANNEL, PORT
from utils import temp
from typing import Union, Optional, AsyncGenerator
from pyrogram import types
from Script import script
from datetime import date, datetime
import pytz
from aiohttp import web
from plugins import web_server
import pytz
from datetime import date, datetime

class Bot(Client):

def init(self):
super().init(
def __init__(self):
super().__init__(
name=SESSION,
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
workers=50,
workers=150,
plugins={"root": "plugins"},
sleep_threshold=5,
)

async def start(self):
b_users, b_chats = await db.get_banned()
temp.BANNED_USERS = b_users
Expand All @@ -42,8 +46,8 @@ async def start(self):
temp.U_NAME = me.username
temp.B_NAME = me.first_name
self.username = '@' + me.username
logging.info(f"{me.first_name} with for Pyrogram v{version} (Layer {layer}) started on {me.username}.")
logging.info(LOG_STR)
logging.info(f"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.")
logging.info(LOG_STR)
tz = pytz.timezone('Asia/Kolkata')
today = date.today()
now = datetime.now(tz)
Expand All @@ -53,7 +57,7 @@ async def start(self):
await app.setup()
bind_address = "0.0.0.0"
await web.TCPSite(app, bind_address, PORT).start()

async def stop(self, *args):
await super().stop()
logging.info("Bot stopped. Bye.")
Expand All @@ -65,7 +69,7 @@ async def iter_messages(
offset: int = 0,
) -> Optional[AsyncGenerator["types.Message", None]]:
"""Iterate through a chat sequentially.
This convenience method does the same as repeatedly calling :meth:~pyrogram.Client.get_messages in a loop, thus saving
This convenience method does the same as repeatedly calling :meth:`~pyrogram.Client.get_messages` in a loop, thus saving
you from the hassle of setting up boilerplate code. It is useful for getting the whole chat messages with a
single call.
Parameters:
Expand All @@ -81,7 +85,7 @@ async def iter_messages(
Identifier of the first message to be returned.
Defaults to 0.
Returns:
``Generator``: A generator yielding :obj:~pyrogram.types.Message objects.
``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects.
Example:
.. code-block:: python
for message in app.iter_messages("pyrogram", 1, 15000):
Expand All @@ -96,5 +100,9 @@ async def iter_messages(
for message in messages:
yield message
current += 1




app = Bot()
app.run()

0 comments on commit 5e1ae54

Please sign in to comment.