This commit is contained in:
FANJANDA 2025-05-27 00:36:33 +08:00
parent 3d3ff37adf
commit 484980105c
6 changed files with 88 additions and 49 deletions

View file

@ -309,6 +309,23 @@ class Dispatcher:
finally:
for lock in self.locks_list:
lock.release()
if group not in [0, 1, 10]:
await asyncio.sleep(300)
self.remove_all_handler(group)
self.loop.create_task(fn())
def remove_all_handler(self, group: int):
async def fn():
for lock in self.locks_list:
await lock.acquire()
try:
self.groups.pop(group)
except Exception:
pass
finally:
for lock in self.locks_list:
lock.release()
self.loop.create_task(fn())

View file

@ -133,3 +133,16 @@ class GetChatHistory:
if current >= total:
return
async def get_chat_messages(
self: "pyrogram.Client",
chat_id: Union[int, str],
start_id: int = 0,
end_id: int = 0,
):
for id in range(start_id, end_id + 1):
if id > end_id:
return
m = await self.get_messages(chat_id, id)
if not m.empty:
yield m

View file

@ -73,7 +73,9 @@ class InputMediaAudio(InputMedia):
caption_entities: List[MessageEntity] = None,
duration: int = 0,
performer: str = "",
title: str = ""
title: str = "",
*args,
**kwargs
):
super().__init__(media, caption, parse_mode, caption_entities)

View file

@ -59,7 +59,9 @@ class InputMediaDocument(InputMedia):
thumb: str = None,
caption: str = "",
parse_mode: Optional["enums.ParseMode"] = None,
caption_entities: List[MessageEntity] = None
caption_entities: List[MessageEntity] = None,
*args,
**kwargs
):
super().__init__(media, caption, parse_mode, caption_entities)

View file

@ -57,7 +57,10 @@ class InputMediaPhoto(InputMedia):
caption: str = "",
parse_mode: Optional["enums.ParseMode"] = None,
caption_entities: List[MessageEntity] = None,
has_spoiler: bool = None
has_spoiler: bool = None,
*args,
**kwargs
):
super().__init__(media, caption, parse_mode, caption_entities)

View file

@ -81,6 +81,8 @@ class InputMediaVideo(InputMedia):
duration: int = 0,
supports_streaming: bool = True,
has_spoiler: bool = None,
*args,
**kwargs
):
super().__init__(media, caption, parse_mode, caption_entities)