🔖 Update to v1.4.2

Support ignore forwarded
This commit is contained in:
xtaodada 2023-11-07 19:40:08 +08:00
parent b9f59927bd
commit 3db24a013c
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
4 changed files with 18 additions and 8 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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"""
logs.error(report)
if Config.ERROR_REPORT:
await attach_report(
report,
f"exception.{time()}.pgp.txt",

View File

@ -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