From 3db24a013c0ea94e0fe3ed2fea235fcd0758726d Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 7 Nov 2023 19:40:08 +0800 Subject: [PATCH] :bookmark: Update to v1.4.2 Support ignore forwarded --- pagermaid/__init__.py | 4 ++-- pagermaid/common/plugin.py | 4 +++- pagermaid/listener.py | 16 ++++++++++++---- requirements.txt | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pagermaid/__init__.py b/pagermaid/__init__.py index e711937..02f83ca 100644 --- a/pagermaid/__init__.py +++ b/pagermaid/__init__.py @@ -21,8 +21,8 @@ from pagermaid.scheduler import scheduler import pyromod.listen from pyrogram import Client -pgm_version = "1.4.1" -pgm_version_code = 1401 +pgm_version = "1.4.2" +pgm_version_code = 1402 CMD_LIST = {} module_dir = __path__[0] working_dir = getcwd() diff --git a/pagermaid/common/plugin.py b/pagermaid/common/plugin.py index e75821a..d338ddc 100644 --- a/pagermaid/common/plugin.py +++ b/pagermaid/common/plugin.py @@ -222,7 +222,9 @@ class PluginManager: self.remote_manager.enable_remote(remote) for plugin in plugin_list: try: - plugin_model = RemotePlugin(**plugin, status=False, remote_source=remote) + plugin_model = RemotePlugin( + **plugin, status=False, remote_source=remote + ) if plugin_model.name in plugins_name: continue plugins.append(plugin_model) diff --git a/pagermaid/listener.py b/pagermaid/listener.py index ea1c4ff..6f6e401 100644 --- a/pagermaid/listener.py +++ b/pagermaid/listener.py @@ -49,6 +49,7 @@ def listener(**args): pattern = sudo_pattern = args.get("pattern") diagnostics = args.get("diagnostics", True) ignore_edited = args.get("ignore_edited", False) + ignore_forwarded = args.get("ignore_forwarded", True) is_plugin = args.get("is_plugin", True) incoming = args.get("incoming", False) outgoing = args.get("outgoing", True) @@ -82,13 +83,17 @@ def listener(**args): if sudo_pattern is not None and not sudo_pattern.startswith("(?i)"): sudo_pattern = f"(?i){sudo_pattern}" if outgoing and not incoming: - base_filters = filters.me & ~filters.via_bot & ~filters.forwarded + base_filters = filters.me & ~filters.via_bot + if ignore_forwarded: + base_filters &= ~filters.forwarded elif incoming and not outgoing: base_filters = filters.incoming & ~filters.me else: base_filters = filters.all permission_name = get_permission_name(is_plugin, need_admin, command) - sudo_filters = sudo_filter(permission_name) & ~filters.via_bot & ~filters.forwarded + sudo_filters = sudo_filter(permission_name) & ~filters.via_bot + if ignore_forwarded: + sudo_filters &= ~filters.forwarded if args["pattern"]: base_filters &= filters.regex(args["pattern"]) sudo_filters &= filters.regex(sudo_pattern) @@ -100,6 +105,8 @@ def listener(**args): sudo_filters &= filters.private if "ignore_edited" in args: del args["ignore_edited"] + if "ignore_forwarded" in args: + del args["ignore_forwarded"] if "command" in args: del args["command"] if "diagnostics" in args: @@ -206,9 +213,10 @@ def listener(**args): await message.edit(lang("run_error"), no_reply=True) # noqa if not diagnostics: return - if Config.ERROR_REPORT: - report = f"""# Generated: {strftime('%H:%M %d/%m/%Y', gmtime())}. \n# ChatID: {message.chat.id}. \n# UserID: {message.from_user.id if message.from_user else message.sender_chat.id}. \n# Message: \n-----BEGIN TARGET MESSAGE-----\n{message.text or message.caption}\n-----END TARGET MESSAGE-----\n# Traceback: \n-----BEGIN TRACEBACK-----\n{str(exc_format)}\n-----END TRACEBACK-----\n# Error: "{str(exc_info)}". \n""" + report = f"""# Generated: {strftime('%H:%M %d/%m/%Y', gmtime())}. \n# ChatID: {message.chat.id}. \n# UserID: {message.from_user.id if message.from_user else message.sender_chat.id}. \n# Message: \n-----BEGIN TARGET MESSAGE-----\n{message.text or message.caption}\n-----END TARGET MESSAGE-----\n# Traceback: \n-----BEGIN TRACEBACK-----\n{str(exc_format)}\n-----END TRACEBACK-----\n# Error: "{str(exc_info)}". \n""" + logs.error(report) + if Config.ERROR_REPORT: await attach_report( report, f"exception.{time()}.pgp.txt", diff --git a/requirements.txt b/requirements.txt index 9c6c69c..66faa58 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ httpx==0.25.0 apscheduler==3.10.4 sqlitedict~=2.1.0 casbin==1.33.0 -sentry-sdk==1.33.1 +sentry-sdk==1.34.0 PyQRCode>=1.2.1 PyPng fastapi==0.104.1