Пример #1
0
 def decorator(func):
     async def wrapper(client, message):
         try:
             await func(client, message)
         except StopPropagation:
             raise StopPropagation
         except ContinuePropagation:
             raise ContinuePropagation
         except BaseException as e:
             logging.error(f"Exception - {func.__module__} - {func.__name__} : {e}")
             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 @DaisyXOT, If You Think This is A Error!__"
             try:
                 await client.send_message(Config.LOG_GRP, text)
             except Exception:
                 pass
     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
Пример #2
0
    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, (await client.get_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 ContinuePropagation:
                    raise ContinuePropagation
                except BaseException as e:
                    logging.error(
                        f"Exception - {func.__module__} - {func.__name__} : {e}"
                    )
                    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 @FridayChat, If You Think This is Serious A Error!__"
                    try:
                        await client.send_message(Config.LOG_GRP, text)
                    except Exception:
                        pass

        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
Пример #3
0
def add_handler(filter_s, func_, cmd):
    d_c_l = Config.DISABLED_SUDO_CMD_S
    if d_c_l:
        if "dev" in d_c_l:
            d_c_l = ['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)