diff --git a/tgEasy/__init__.py b/tgEasy/__init__.py index 55c188a..4e390ed 100644 --- a/tgEasy/__init__.py +++ b/tgEasy/__init__.py @@ -22,7 +22,8 @@ import pyrogram from pyrogram import client from pyromod import listen -from pyromod.helpers import array_chunk, bki, btn, force_reply, ikb, kb, kbtn, ntb +from pyromod.helpers import (array_chunk, bki, btn, force_reply, ikb, kb, kbtn, + ntb) from pyromod.nav import Pagination from .config import Config @@ -30,7 +31,7 @@ from .helpers import * from .scaffold import Scaffold -__version__ = "1.3.0" +__version__ = "1.3.1" __copyright__ = "Copyright 2021 Jayant Hegde Kageri " __license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)" logging = logger.getLogger("tgEasy") diff --git a/tgEasy/decorater/adminsOnly.py b/tgEasy/decorater/adminsOnly.py index 50eea9e..a7fa211 100644 --- a/tgEasy/decorater/adminsOnly.py +++ b/tgEasy/decorater/adminsOnly.py @@ -20,7 +20,6 @@ import pyrogram from cachetools import TTLCache -from pyrogram.types.messages_and_media import message from tgEasy.scaffold import Scaffold @@ -114,13 +113,13 @@ def adminsOnly( """ # `tgEasy.tgClient.adminsOnly` - A decorater for running the function only if the admin have the specified Rights. - - We are still Working on this to make it to check Rights for Anonoymous Admins, Stay Tuned. + - If the admin is Anonymous Admin, it also checks his rights by making a Callback. - Parameters: - permission (str): - Permission which the User must have to use the Functions - TRUST_ANON_ADMIN (bool) **optional**: - - If User is Anonymous Admin also, It Runs the Function, By Default False + - If the user is an Anonymous Admin, then it bypasses his right check. # Example .. code-block:: python @@ -143,9 +142,6 @@ async def decorator(client, message): "This command can be used in supergroups only.", ) if message.sender_chat and not TRUST_ANON_ADMINS: - # return await message.reply_text( - # "The Right Check for Anonymous Admins is in Development. So you cannot perform this Action for Now, If you don't want this and want to Allow Anonymous Admins for performing Actions in this time Please Contact Bot Owner.", - # ) ANON[int(f"{message.chat.id}{message.message_id}")] = ( message, func, diff --git a/tgEasy/decorater/command.py b/tgEasy/decorater/command.py index b2e455c..7cf0c0a 100644 --- a/tgEasy/decorater/command.py +++ b/tgEasy/decorater/command.py @@ -34,6 +34,7 @@ def command( group_only: typing.Union[bool, bool] = False, self_admin: typing.Union[bool, bool] = False, self_only: typing.Union[bool, bool] = False, + handler: typing.Optional[list] = Config.HANDLERS, filter: typing.Union[pyrogram.filters.Filter, pyrogram.filters.Filter] = None, *args, **kwargs @@ -54,6 +55,9 @@ def command( - self_only (bool) **optional**: - If True, the command will only excute if used by Self only, By Default False. + - handler (list) **optional**: + - If set, the command will be handled by the specified Handler, By Default `Config.HANDLERS`. + - self_admin (bool) **optional**: - If True, the command will only executeed if the Bot is Admin in the Chat, By Default False @@ -74,14 +78,14 @@ async def start(client, message): if filter: if self_only: filter = ( - pyrogram.filters.command(command, prefixes=Config.HANDLERS) + pyrogram.filters.command(command, prefixes=handler) & ~pyrogram.filters.edited & filter & pyrogram.filters.me ) else: filter = ( - pyrogram.filters.command(command, prefixes=Config.HANDLERS) + pyrogram.filters.command(command, prefixes=handler) & ~pyrogram.filters.edited & filter & pyrogram.filters.me @@ -89,13 +93,13 @@ async def start(client, message): else: if self_only: filter = ( - pyrogram.filters.command(command, prefixes=Config.HANDLERS) + pyrogram.filters.command(command, prefixes=handler) & ~pyrogram.filters.edited & pyrogram.filters.me ) else: filter = ( - pyrogram.filters.command(command, prefixes=Config.HANDLERS) + pyrogram.filters.command(command, prefixes=handler) & ~pyrogram.filters.edited ) diff --git a/tgEasy/helpers/get_user.py b/tgEasy/helpers/get_user.py index 3479c04..4d2ab0e 100644 --- a/tgEasy/helpers/get_user.py +++ b/tgEasy/helpers/get_user.py @@ -23,7 +23,7 @@ async def get_user( m: typing.Union[pyrogram.types.Message, pyrogram.types.CallbackQuery] -): +) -> pyrogram.types.User or bool: """ ### `tgEasy.get_user` - Gets a User from Message/RepliedMessage/CallbackQuery @@ -88,7 +88,7 @@ async def ban(client, message): async def get_user_adv( m: typing.Union[pyrogram.types.Message, pyrogram.types.CallbackQuery] -): +) -> pyrogram.types.User or bool: """ ### `tgEasy.get_user_adv` - A Function to Get the User from the Message/CallbackQuery, If there is None arguments, returns the From User. diff --git a/tgEasy/helpers/handle_error.py b/tgEasy/helpers/handle_error.py index 7387012..4947409 100644 --- a/tgEasy/helpers/handle_error.py +++ b/tgEasy/helpers/handle_error.py @@ -84,3 +84,4 @@ async def start(client, message): pass logging.exception(traceback.format_exc()) os.remove("crash.log") + return True diff --git a/tgEasy/helpers/send_typing.py b/tgEasy/helpers/send_typing.py index 2938194..22ad249 100644 --- a/tgEasy/helpers/send_typing.py +++ b/tgEasy/helpers/send_typing.py @@ -23,7 +23,7 @@ async def send_typing( m: typing.Union[pyrogram.types.Message, pyrogram.types.CallbackQuery] -): +) -> bool: """ ### `tgEasy.send_typing` - A Function to Send the Typing Status to the Chat. diff --git a/tgEasy/scaffold.py b/tgEasy/scaffold.py index 9ad2aba..c0478ca 100644 --- a/tgEasy/scaffold.py +++ b/tgEasy/scaffold.py @@ -40,9 +40,3 @@ def callback(*args, **kwargs): def adminsOnly(*args, **kwargs): pass - - async def check_rights(*args, **kwargs): - pass - - async def is_admin(*args, **kwargs): - pass