From 46a3c9f54062d7652e46f2986984d318fe40060b Mon Sep 17 00:00:00 2001 From: thedragonsinn <98635854+thedragonsinn@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:03:18 +0530 Subject: [PATCH] double log task fix, chat in log message, html tag fix in @try_. --- app/core/decorators/try_except.py | 4 ++-- app/plugins/tools/pm_n_tag_logger.py | 7 ++++--- app/plugins/tools/respond.py | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/core/decorators/try_except.py b/app/core/decorators/try_except.py index cc9aa92..78aa8f9 100644 --- a/app/core/decorators/try_except.py +++ b/app/core/decorators/try_except.py @@ -18,7 +18,7 @@ def try_(func): except BaseException: text, type = ( f"FUNC: {func.__name__}" - f"\n#TRACEBACK:\n
{traceback.format_exc()}
", + f"\n#TRACEBACK:\n
{traceback.format_exc()}
", "error", ) if text: @@ -36,7 +36,7 @@ def try_(func): except BaseException: text, type = ( f"FUNC: {func.__name__}" - f"\n#TRACEBACK:\n
{traceback.format_exc()}
", + f"\n#TRACEBACK:\n
{traceback.format_exc()}
", "error", ) if text: diff --git a/app/plugins/tools/pm_n_tag_logger.py b/app/plugins/tools/pm_n_tag_logger.py index 83dbb01..ec769b0 100644 --- a/app/plugins/tools/pm_n_tag_logger.py +++ b/app/plugins/tools/pm_n_tag_logger.py @@ -48,7 +48,8 @@ async def logger_switch(bot: BOT, message: Message): text=f"#{text.capitalize()}Logger is enabled: {value}!", type="info" ), ) - Config.MESSAGE_LOGGER_TASK = asyncio.create_task(runner()) + if not Config.MESSAGE_LOGGER_TASK or Config.MESSAGE_LOGGER_TASK.done(): + Config.MESSAGE_LOGGER_TASK = asyncio.create_task(runner()) basic_filters = ( @@ -179,7 +180,7 @@ async def log_chat(message: Message): try: logged = await message.forward(Config.MESSAGE_LOGGER_CHAT) await logged.reply( - text=f"#TAG\n{mention} [{u_id}]\nMessage: Link", + text=f"#TAG\n{mention} [{u_id}]\nMessage: \n{message.chat.title} ({message.chat.id})", ) except MessageIdInvalid: await log_deleted_message(message, data=(mention, u_id)) @@ -191,7 +192,7 @@ async def log_deleted_message(message: Message, data: tuple | None = None): mention, u_id = data else: mention, u_id = message.from_user.mention, message.from_user.id - notice = f"{mention} [{u_id}] deleted this message.\n\n---\n\nMessage: Link\n\n---\n\n" + notice = f"{mention} [{u_id}] deleted this message.\n\n---\n\nMessage: \n{message.chat.title or message.chat.first_name} ({message.chat.id})\n\n---\n\n" if not message.media: await bot.send_message( chat_id=Config.MESSAGE_LOGGER_CHAT, diff --git a/app/plugins/tools/respond.py b/app/plugins/tools/respond.py index 66df771..f954629 100644 --- a/app/plugins/tools/respond.py +++ b/app/plugins/tools/respond.py @@ -13,7 +13,8 @@ async def respond(bot: BOT, message: Message): """ if message.replied: inp_text = message.replied.text - match = re.search(pattern=r"\[(\d+)\]", string=inp_text) + pattern = r"\((\d+)\)" if "#TAG" in inp_text else r"\[(\d+)\]" + match = re.search(pattern=pattern, string=inp_text) if match: chat_id = match.group(1) text = message.input