Skip to content

Commit

Permalink
🔖 Update to v1.4.4
Browse files Browse the repository at this point in the history
Default ignore reacted edit message
  • Loading branch information
omg-xtao committed Dec 13, 2023
1 parent 8fb39b1 commit a617027
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 5 additions & 3 deletions pagermaid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
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()
Expand All @@ -50,7 +50,9 @@
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)
Expand Down
10 changes: 8 additions & 2 deletions pagermaid/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
)
from pagermaid.hook import Hook
from pagermaid.web import web
from pyromod.utils import mod_filters

_lock = asyncio.Lock()

Expand All @@ -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)
Expand Down Expand Up @@ -84,16 +86,18 @@ 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:
base_filters = filters.all
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)
Expand All @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions pyromod/utils/mod_filters.py
Original file line number Diff line number Diff line change
@@ -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."""

0 comments on commit a617027

Please sign in to comment.