Skip to content

Commit

Permalink
🔖 Update to v1.4.2
Browse files Browse the repository at this point in the history
Support ignore forwarded
  • Loading branch information
omg-xtao committed Nov 7, 2023
1 parent b9f5992 commit 3db24a0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pagermaid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
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()
Expand Down
4 changes: 3 additions & 1 deletion pagermaid/common/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ async def load_remote_plugins_no_cache(self) -> List[RemotePlugin]:
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)
Expand Down
16 changes: 12 additions & 4 deletions pagermaid/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -206,9 +213,10 @@ async def handler(client: Client, message: Message):
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",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3db24a0

Please sign in to comment.