Skip to content

Commit

Permalink
fix: circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Gorn committed Jun 9, 2024
1 parent aa14752 commit 5ea9972
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# venv
__pycache__
.venv

# env
.env
.env
*.session
2 changes: 0 additions & 2 deletions Bot/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
from typing import Union
from .config import Config
from .translation import Translation
from .filters import Filter


class BotClient(Client):

def __init__(self):
self.filters = Filter
self.sleep = asyncio.sleep
self.session: ClientSession = None
self.config = Config
Expand Down
File renamed without changes.
9 changes: 5 additions & 4 deletions Bot/plugins/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from pyrogram import Client, filters
from pyrogram.types import Message
from pyrogram.errors import FloodWait, Forbidden, BadRequest
from ..functions.filters import Filter


@Client.on_message(filters.private & filters.command('broadcast') & filters.reply & client.filters.database & filters.user(users=client.config.OWNER_ID))
@Client.on_message(filters.private & filters.command('broadcast') & filters.reply & Filter.database & filters.user(users=client.config.OWNER_ID))
async def broadcast(bot: Client, update: Message):
message = await update.reply(text='Broadcast started...')
async for user in client.database.xurluploader.users.find({}):
Expand All @@ -25,12 +26,12 @@ async def broadcast(bot: Client, update: Message):
await message.edit(text='Broadcast done.')


@Client.on_message(filters.private & filters.command('broadcast') & ~filters.reply & client.filters.database & filters.user(users=client.config.OWNER_ID))
@Client.on_message(filters.private & filters.command('broadcast') & ~filters.reply & Filter.database & filters.user(users=client.config.OWNER_ID))
async def broadcast_no_reply(bot: Client, update: Message):
await update.reply('Reply to a message.')


@Client.on_message(filters.private & filters.command('ban') & client.filters.database & filters.user(users=client.config.OWNER_ID))
@Client.on_message(filters.private & filters.command('ban') & Filter.database & filters.user(users=client.config.OWNER_ID))
async def ban(bot: Client, update: Message):
try:
user_id = int(update.command[1])
Expand All @@ -46,7 +47,7 @@ async def ban(bot: Client, update: Message):
await update.reply('User ID is not exist in database.')


@Client.on_message(filters.private & filters.command('unban') & client.filters.database & filters.user(users=client.config.OWNER_ID))
@Client.on_message(filters.private & filters.command('unban') & Filter.database & filters.user(users=client.config.OWNER_ID))
async def unban(bot: Client, update: Message):
try:
user_id = int(update.command[1])
Expand Down
5 changes: 3 additions & 2 deletions Bot/plugins/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

from pyrogram import Client, filters
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
from ..functions.filters import Filter
from .. import client


@Client.on_message(filters.private & filters.command("help") & client.filters.auth_users)
@Client.on_message(filters.private & filters.command("help") & Filter.auth_users)
async def help(bot: Client, update: Message):
await bot.send_message(
chat_id=update.chat.id,
Expand All @@ -18,7 +19,7 @@ async def help(bot: Client, update: Message):
)


@Client.on_message(filters.private & filters.command("start") & client.filters.auth_users)
@Client.on_message(filters.private & filters.command("start") & Filter.auth_users)
async def start(bot: Client, update: Message):
await bot.send_message(
chat_id=update.chat.id,
Expand Down
3 changes: 2 additions & 1 deletion Bot/plugins/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from PIL import Image
from ..functions.download import download_coroutine
from ..functions.display_progress import humanbytes
from ..functions.filters import Filter
from .. import client


Expand All @@ -21,7 +22,7 @@
pattern=r'(https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&//=]*))(.*)?')


@Client.on_message(filters.private & filters.regex(pattern=URL_REGEX) & client.filters.auth_users)
@Client.on_message(filters.private & filters.regex(pattern=URL_REGEX) & Filter.auth_users)
async def echo_http(bot: Client, update: Message):
if client.database:
user = await client.database.xurluploader.users.find_one({'id': update.from_user.id})
Expand Down
7 changes: 4 additions & 3 deletions Bot/plugins/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pyrogram import Client, filters
from pyrogram.types import Message
from ..functions.helper import URL_REGEX, run_cmd
from ..functions.filters import Filter


async def reply_to_photo_filter(_, __, m: Message):
Expand All @@ -12,7 +13,7 @@ async def no_args_filter(_, __, m: Message):
return True if len(m.command) == 1 else False


@Client.on_message(filters.private & filters.command('caption') & client.filters.auth_users)
@Client.on_message(filters.private & filters.command('caption') & Filter.auth_users)
async def custom_caption(bot: Client, update: Message):
if client.database:
user = await client.database.xurluploader.users.find_one({'id': update.from_user.id})
Expand All @@ -34,7 +35,7 @@ async def custom_caption(bot: Client, update: Message):
client.custom_caption[update.from_user.id] = caption


@Client.on_message(filters.private & filters.command('thumbnail') & ~filters.reply & (filters.regex(pattern=URL_REGEX) | filters.create(no_args_filter)) & client.filters.auth_users)
@Client.on_message(filters.private & filters.command('thumbnail') & ~filters.reply & (filters.regex(pattern=URL_REGEX) | filters.create(no_args_filter)) & Filter.auth_users)
async def custom_thumbnail(bot: Client, update: Message):
if client.database:
user = await client.database.xurluploader.users.find_one({'id': update.from_user.id})
Expand All @@ -59,7 +60,7 @@ async def custom_thumbnail(bot: Client, update: Message):
client.custom_thumbnail[update.from_user.id] = thumbnail


@Client.on_message(filters.private & filters.command('thumbnail') & filters.reply & filters.create(reply_to_photo_filter) & client.filters.auth_users)
@Client.on_message(filters.private & filters.command('thumbnail') & filters.reply & filters.create(reply_to_photo_filter) & Filter.auth_users)
async def custom_thumbnail_reply(bot: Client, update: Message):
client.custom_thumbnail[update.from_user.id] = await update.reply_to_message.download(file_name=f'{client.config.DOWNLOAD_LOCATION}/{update.from_user.id}.jpg')
await update.reply(text='Custom thumbnail updated.')

0 comments on commit 5ea9972

Please sign in to comment.