mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-08 16:04:51 +00:00
nothing
This commit is contained in:
parent
3d3ff37adf
commit
484980105c
6 changed files with 88 additions and 49 deletions
|
|
@ -309,6 +309,23 @@ class Dispatcher:
|
||||||
finally:
|
finally:
|
||||||
for lock in self.locks_list:
|
for lock in self.locks_list:
|
||||||
lock.release()
|
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())
|
self.loop.create_task(fn())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,15 @@ from pyrogram import types, raw, utils
|
||||||
|
|
||||||
|
|
||||||
async def get_chunk(
|
async def get_chunk(
|
||||||
*,
|
*,
|
||||||
client: "pyrogram.Client",
|
client: "pyrogram.Client",
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
limit: int = 0,
|
limit: int = 0,
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
from_message_id: int = 0,
|
from_message_id: int = 0,
|
||||||
from_date: datetime = utils.zero_datetime(),
|
from_date: datetime = utils.zero_datetime(),
|
||||||
min_id: int = 0,
|
min_id: int = 0,
|
||||||
max_id: int = 0
|
max_id: int = 0
|
||||||
):
|
):
|
||||||
messages = await client.invoke(
|
messages = await client.invoke(
|
||||||
raw.functions.messages.GetHistory(
|
raw.functions.messages.GetHistory(
|
||||||
|
|
@ -54,14 +54,14 @@ async def get_chunk(
|
||||||
|
|
||||||
class GetChatHistory:
|
class GetChatHistory:
|
||||||
async def get_chat_history(
|
async def get_chat_history(
|
||||||
self: "pyrogram.Client",
|
self: "pyrogram.Client",
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
limit: int = 0,
|
limit: int = 0,
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
offset_id: int = 0,
|
offset_id: int = 0,
|
||||||
offset_date: datetime = utils.zero_datetime(),
|
offset_date: datetime = utils.zero_datetime(),
|
||||||
min_id: int = 0,
|
min_id: int = 0,
|
||||||
max_id: int = 0
|
max_id: int = 0
|
||||||
) -> Optional[AsyncGenerator["types.Message", None]]:
|
) -> Optional[AsyncGenerator["types.Message", None]]:
|
||||||
"""Get messages from a chat history.
|
"""Get messages from a chat history.
|
||||||
|
|
||||||
|
|
@ -133,3 +133,16 @@ class GetChatHistory:
|
||||||
|
|
||||||
if current >= total:
|
if current >= total:
|
||||||
return
|
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
|
||||||
|
|
|
||||||
|
|
@ -65,15 +65,17 @@ class InputMediaAudio(InputMedia):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
media: Union[str, BinaryIO],
|
media: Union[str, BinaryIO],
|
||||||
thumb: str = None,
|
thumb: str = None,
|
||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: Optional["enums.ParseMode"] = None,
|
parse_mode: Optional["enums.ParseMode"] = None,
|
||||||
caption_entities: List[MessageEntity] = None,
|
caption_entities: List[MessageEntity] = None,
|
||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
performer: str = "",
|
performer: str = "",
|
||||||
title: str = ""
|
title: str = "",
|
||||||
|
*args,
|
||||||
|
**kwargs
|
||||||
):
|
):
|
||||||
super().__init__(media, caption, parse_mode, caption_entities)
|
super().__init__(media, caption, parse_mode, caption_entities)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,14 @@ class InputMediaDocument(InputMedia):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
media: Union[str, BinaryIO],
|
media: Union[str, BinaryIO],
|
||||||
thumb: str = None,
|
thumb: str = None,
|
||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: Optional["enums.ParseMode"] = None,
|
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)
|
super().__init__(media, caption, parse_mode, caption_entities)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,15 @@ class InputMediaPhoto(InputMedia):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
media: Union[str, BinaryIO],
|
media: Union[str, BinaryIO],
|
||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: Optional["enums.ParseMode"] = None,
|
parse_mode: Optional["enums.ParseMode"] = None,
|
||||||
caption_entities: List[MessageEntity] = None,
|
caption_entities: List[MessageEntity] = None,
|
||||||
has_spoiler: bool = None
|
has_spoiler: bool = None,
|
||||||
|
*args,
|
||||||
|
**kwargs
|
||||||
|
|
||||||
):
|
):
|
||||||
super().__init__(media, caption, parse_mode, caption_entities)
|
super().__init__(media, caption, parse_mode, caption_entities)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,17 +70,19 @@ class InputMediaVideo(InputMedia):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
media: Union[str, BinaryIO],
|
media: Union[str, BinaryIO],
|
||||||
thumb: str = None,
|
thumb: str = None,
|
||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: Optional["enums.ParseMode"] = None,
|
parse_mode: Optional["enums.ParseMode"] = None,
|
||||||
caption_entities: List[MessageEntity] = None,
|
caption_entities: List[MessageEntity] = None,
|
||||||
width: int = 0,
|
width: int = 0,
|
||||||
height: int = 0,
|
height: int = 0,
|
||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
supports_streaming: bool = True,
|
supports_streaming: bool = True,
|
||||||
has_spoiler: bool = None,
|
has_spoiler: bool = None,
|
||||||
|
*args,
|
||||||
|
**kwargs
|
||||||
):
|
):
|
||||||
super().__init__(media, caption, parse_mode, caption_entities)
|
super().__init__(media, caption, parse_mode, caption_entities)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue