🔖 Update to v1.2.23

This commit is contained in:
xtaodada 2023-01-14 13:49:08 +08:00
parent eccf9b13c0
commit 7465805535
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
5 changed files with 27 additions and 17 deletions

View File

@ -15,7 +15,7 @@ from pyrogram import Client
from pyromod.listen.temp_fix import temp_fix, read_chat_history from pyromod.listen.temp_fix import temp_fix, read_chat_history
pgm_version = "1.2.22" pgm_version = "1.2.23"
CMD_LIST = {} CMD_LIST = {}
module_dir = __path__[0] module_dir = __path__[0]
working_dir = getcwd() working_dir = getcwd()

View File

@ -1,7 +1,6 @@
import asyncio
import contextlib import contextlib
import sys import sys
import secrets
from asyncio import sleep
from time import strftime, gmtime, time from time import strftime, gmtime, time
from traceback import format_exc from traceback import format_exc
@ -22,11 +21,7 @@ from pagermaid.single_utils import Message, AlreadyInConversationError, TimeoutC
from pagermaid.utils import lang, attach_report, sudo_filter, alias_command, get_permission_name, process_exit from pagermaid.utils import lang, attach_report, sudo_filter, alias_command, get_permission_name, process_exit
from pagermaid.hook import Hook from pagermaid.hook import Hook
secret_generator = secrets.SystemRandom() _lock = asyncio.Lock()
def noop(*args, **kw):
pass
def listener(**args): def listener(**args):
@ -129,8 +124,7 @@ def listener(**args):
message.parameter = None message.parameter = None
message.arguments = None message.arguments = None
# solve same process # solve same process
if not message.outgoing: async with _lock:
await sleep(secret_generator.randint(1, 100) / 1000)
if (message.chat.id, message.id) in read_context: if (message.chat.id, message.id) in read_context:
raise ContinuePropagation raise ContinuePropagation
read_context[(message.chat.id, message.id)] = True read_context[(message.chat.id, message.id)] = True
@ -206,10 +200,12 @@ def listener(**args):
message.continue_propagation() message.continue_propagation()
bot.add_handler(MessageHandler(handler, filters=base_filters), group=0 + priority) bot.add_handler(MessageHandler(handler, filters=base_filters), group=0 + priority)
bot.add_handler(MessageHandler(handler, filters=sudo_filters), group=50 + priority) if command:
bot.add_handler(MessageHandler(handler, filters=sudo_filters), group=50 + priority)
if not ignore_edited: if not ignore_edited:
bot.add_handler(EditedMessageHandler(handler, filters=base_filters), group=1 + priority) bot.add_handler(EditedMessageHandler(handler, filters=base_filters), group=1 + priority)
bot.add_handler(EditedMessageHandler(handler, filters=sudo_filters), group=51 + priority) if command:
bot.add_handler(EditedMessageHandler(handler, filters=sudo_filters), group=51 + priority)
return handler return handler
@ -233,6 +229,11 @@ def raw_listener(filter_s):
def decorator(function): def decorator(function):
async def handler(client, message): async def handler(client, message):
# solve same process
async with _lock:
if (message.chat.id, message.id) in read_context:
raise ContinuePropagation
read_context[(message.chat.id, message.id)] = True
try: try:
if function.__code__.co_argcount == 1: if function.__code__.co_argcount == 1:
await function(message) await function(message)

View File

@ -4,14 +4,16 @@ import os
import pagermaid.config import pagermaid.config
import pagermaid.modules import pagermaid.modules
from pagermaid import logs, help_messages, all_permissions, hook_functions, read_context
from pagermaid import bot, logs, help_messages, all_permissions, hook_functions from pagermaid.enums import Message
from pagermaid.hook import Hook from pagermaid.hook import Hook
from pagermaid.listener import listener from pagermaid.listener import listener
from pagermaid.utils import lang, Message from pagermaid.services import bot, scheduler
from pagermaid.utils import lang
async def reload_all(): async def reload_all():
read_context.clear()
bot.dispatcher.remove_all_handlers() bot.dispatcher.remove_all_handlers()
bot.job.remove_all_jobs() bot.job.remove_all_jobs()
with contextlib.suppress(RuntimeError): with contextlib.suppress(RuntimeError):
@ -51,3 +53,8 @@ async def reload_plugins(message: Message):
""" To reload plugins. """ """ To reload plugins. """
await reload_all() await reload_all()
await message.edit(lang("reload_ok")) await message.edit(lang("reload_ok"))
@scheduler.scheduled_job("cron", hour="4", id="reload.clear_read_context")
async def clear_read_context_cron():
read_context.clear()

View File

@ -20,6 +20,8 @@ async def temp_fix(
parsed.reply_to_top_message_id = parsed.reply_to_message_id parsed.reply_to_top_message_id = parsed.reply_to_message_id
parsed.reply_to_message_id = None parsed.reply_to_message_id = None
parsed.reply_to_message = None parsed.reply_to_message = None
# make message.text as message.caption
parsed.text = parsed.text or parsed.caption
return parsed return parsed

View File

@ -1,4 +1,4 @@
pyrogram==2.0.95 pyrogram==2.0.97
TgCrypto==1.2.5 TgCrypto==1.2.5
Pillow>=8.4.0 Pillow>=8.4.0
pytz>=2021.3 pytz>=2021.3
@ -9,4 +9,4 @@ httpx
apscheduler apscheduler
sqlitedict sqlitedict
casbin==1.17.5 casbin==1.17.5
sentry-sdk==1.12.1 sentry-sdk==1.13.0