def add_handler(filter_s, func_, cmd): d_c_l = Config.DISABLED_SUDO_CMD_S if d_c_l: d_c_l = d_c_l.split(" ") d_c_l = list(d_c_l) if "dev" in d_c_l: d_c_l.extend(['eval', 'bash', 'install']) if any(item in list(d_c_l) for item in list(cmd)): filter_s = (filters.me & filters.command(cmd, Config.COMMAND_HANDLER) & ~filters.via_bot & ~filters.forwarded) Friday.add_handler(MessageHandler(func_, filters=filter_s), group=0) if Friday2: Friday2.add_handler(MessageHandler(func_, filters=filter_s), group=0) if Friday3: Friday3.add_handler(MessageHandler(func_, filters=filter_s), group=0) if Friday4: Friday4.add_handler(MessageHandler(func_, filters=filter_s), group=0)
def decorator(func): async def wrapper(client, message): message.Engine = Engine try: await func(client, message) except StopPropagation: raise StopPropagation except ContinuePropagation: raise ContinuePropagation except UserNotParticipant: pass except MessageEmpty: pass except BaseException: logging.error( f"Exception - {func.__module__} - {func.__name__}") TZ = pytz.timezone(Config.TZ) datetime_tz = datetime.now(TZ) text = "**!ERROR WHILE HANDLING UPDATES!**\n\n" text += f"\n**Trace Back : ** `{str(format_exc())}`" text += f"\n**Plugin-Name :** `{func.__module__}`" text += f"\n**Function Name :** `{func.__name__}` \n" text += datetime_tz.strftime( "**Date :** `%Y-%m-%d` \n**Time :** `%H:%M:%S`") text += "\n\n__You can Forward This to @FridayChat, If You Think This is A Error!__" try: await client.send_message(Config.LOG_GRP, text) except BaseException: logging.error(text) message.continue_propagation() Friday.add_handler(MessageHandler(wrapper, filters=filter_s), group=0) if Friday2: Friday2.add_handler(MessageHandler(wrapper, filters=filter_s), group=0) if Friday3: Friday3.add_handler(MessageHandler(wrapper, filters=filter_s), group=0) if Friday4: Friday4.add_handler(MessageHandler(wrapper, filters=filter_s), group=0) return wrapper
async def fetch_plugins_from_channel(): """Fetch Plugins From Channel""" try: async for message in Friday.search_messages( Config.PLUGIN_CHANNEL, filter="document", query=".py" ): hmm = message.document.file_name if not os.path.exists(os.path.join("./plugins/", hmm)): await Friday.download_media(message, file_name="./plugins/") except BaseException as e: logging.error(f"Failed! To Install Plugins From Plugin Channel Due To {e}!") return logging.info("All Plugins From Plugin Channel Loaded!")
def decorator(func): async def wrapper(client, message): chat_type = message.chat.type if only_if_admin and not await is_admin_or_owner( message, (client.me).id): await edit_or_reply( message, "`This Command Only Works, If You Are Admin Of The Chat!`") return if group_only and chat_type != "supergroup": await edit_or_reply(message, "`Are you sure this is a group?`") return if chnnl_only and chat_type != "channel": await edit_or_reply(message, "This Command Only Works In Channel!") return if pm_only and chat_type != "private": await edit_or_reply(message, "`This Cmd Only Works On PM!`") return if ignore_errors: await func(client, message) else: try: await func(client, message) except StopPropagation: raise StopPropagation except KeyboardInterrupt: pass except MessageNotModified: pass except MessageIdInvalid: logging.warning( "Please Don't Delete Commands While it's Processing..") except UserNotParticipant: pass except ContinuePropagation: raise ContinuePropagation except BaseException as e: logging.error( f"Exception - {func.__module__} - {func.__name__}") TZ = pytz.timezone(Config.TZ) datetime_tz = datetime.now(TZ) text = "**!ERROR - REPORT!**\n\n" text += f"\n**Trace Back : ** `{str(format_exc())}`" text += f"\n**Plugin-Name :** `{func.__module__}`" text += f"\n**Function Name :** `{func.__name__}` \n" text += datetime_tz.strftime( "**Date :** `%Y-%m-%d` \n**Time :** `%H:%M:%S`") text += "\n\n__You can Forward This to @WhiteDevil_Support, If You Think This is Serious A Error!__" try: await client.send_message(Config.LOG_GRP, text) except BaseException: logging.error(text) message.continue_propagation() Friday.add_handler(MessageHandler(wrapper, filters=filterm), group) if Friday2: Friday2.add_handler(MessageHandler(wrapper, filters=filterm), group) if Friday3: Friday3.add_handler(MessageHandler(wrapper, filters=filterm), group) if Friday4: Friday4.add_handler(MessageHandler(wrapper, filters=filterm), group) return wrapper