From a617027a007772fa1f9ff69a1fbe870f0952b199 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 13 Dec 2023 12:53:03 +0800 Subject: [PATCH] :bookmark: Update to v1.4.4 Default ignore reacted edit message --- pagermaid/__init__.py | 8 +++++--- pagermaid/listener.py | 10 ++++++++-- pyromod/utils/mod_filters.py | 11 +++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 pyromod/utils/mod_filters.py diff --git a/pagermaid/__init__.py b/pagermaid/__init__.py index 4612ec8..d03f82b 100644 --- a/pagermaid/__init__.py +++ b/pagermaid/__init__.py @@ -22,8 +22,8 @@ from pagermaid.scheduler import scheduler import pyromod.listen from pyrogram import Client -pgm_version = "1.4.3" -pgm_version_code = 1403 +pgm_version = "1.4.4" +pgm_version_code = 1404 CMD_LIST = {} module_dir = __path__[0] working_dir = getcwd() @@ -50,7 +50,9 @@ root_logger.addHandler(logging_handler) pyro_logger = getLogger("pyrogram") pyro_logger.setLevel(INFO if Config.DEBUG else CRITICAL) pyro_logger.addHandler(logging_handler) -file_handler = FileHandler(filename="data/pagermaid.log.txt", mode="w", encoding="utf-8") +file_handler = FileHandler( + filename="data/pagermaid.log.txt", mode="w", encoding="utf-8" +) file_handler.setFormatter(Formatter(logging_format)) root_logger.addHandler(file_handler) basicConfig(level=DEBUG if Config.DEBUG else INFO) diff --git a/pagermaid/listener.py b/pagermaid/listener.py index 6f6e401..c153912 100644 --- a/pagermaid/listener.py +++ b/pagermaid/listener.py @@ -35,6 +35,7 @@ from pagermaid.utils import ( ) from pagermaid.hook import Hook from pagermaid.web import web +from pyromod.utils import mod_filters _lock = asyncio.Lock() @@ -49,6 +50,7 @@ def listener(**args): pattern = sudo_pattern = args.get("pattern") diagnostics = args.get("diagnostics", True) ignore_edited = args.get("ignore_edited", False) + ignore_reacted = args.get("ignore_reacted", True) ignore_forwarded = args.get("ignore_forwarded", True) is_plugin = args.get("is_plugin", True) incoming = args.get("incoming", False) @@ -84,8 +86,6 @@ def listener(**args): sudo_pattern = f"(?i){sudo_pattern}" if outgoing and not incoming: 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: @@ -93,7 +93,11 @@ def listener(**args): permission_name = get_permission_name(is_plugin, need_admin, command) sudo_filters = sudo_filter(permission_name) & ~filters.via_bot if ignore_forwarded: + base_filters &= ~filters.forwarded sudo_filters &= ~filters.forwarded + if ignore_reacted: + base_filters &= ~mod_filters.reacted + sudo_filters &= ~mod_filters.reacted if args["pattern"]: base_filters &= filters.regex(args["pattern"]) sudo_filters &= filters.regex(sudo_pattern) @@ -105,6 +109,8 @@ def listener(**args): sudo_filters &= filters.private if "ignore_edited" in args: del args["ignore_edited"] + if "ignore_reacted" in args: + del args["ignore_reacted"] if "ignore_forwarded" in args: del args["ignore_forwarded"] if "command" in args: diff --git a/pyromod/utils/mod_filters.py b/pyromod/utils/mod_filters.py new file mode 100644 index 0000000..145a812 --- /dev/null +++ b/pyromod/utils/mod_filters.py @@ -0,0 +1,11 @@ +from pyrogram.filters import create + +from pagermaid.enums import Message + + +async def reacted_filter(_, __, m: Message): + return m.reactions is not None + + +reacted = create(reacted_filter) +"""Filter messages that are reacted."""