mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Update some methods
This commit is contained in:
parent
e27e782e50
commit
35ebe8ea9d
@ -26,8 +26,9 @@ class SendReaction:
|
||||
async def send_reaction(
|
||||
self: "pyrogram.Client",
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
emoji: str = "",
|
||||
message_id: int = None,
|
||||
story_id: int = None,
|
||||
emoji: Union[int, str] = None,
|
||||
big: bool = False
|
||||
) -> bool:
|
||||
"""Send a reaction to a message.
|
||||
@ -41,7 +42,10 @@ class SendReaction:
|
||||
message_id (``int``):
|
||||
Identifier of the message.
|
||||
|
||||
emoji (``str``, *optional*):
|
||||
story_id (``int``):
|
||||
Identifier of the story.
|
||||
|
||||
emoji (``int`` | ``str``, *optional*):
|
||||
Reaction emoji.
|
||||
Pass "" as emoji (default) to retract the reaction.
|
||||
|
||||
@ -61,13 +65,25 @@ class SendReaction:
|
||||
# Retract a reaction
|
||||
await app.send_reaction(chat_id, message_id)
|
||||
"""
|
||||
await self.invoke(
|
||||
raw.functions.messages.SendReaction(
|
||||
if isinstance(emoji, int):
|
||||
emoji = [raw.types.ReactionCustomEmoji(document_id=emoji)]
|
||||
else:
|
||||
emoji = [raw.types.ReactionEmoji(emoticon=emoji)] if emoji else None
|
||||
|
||||
if story_id:
|
||||
rpc = raw.functions.stories.SendReaction(
|
||||
peer=await self.resolve_peer(chat_id),
|
||||
story_id=story_id,
|
||||
reaction=emoji,
|
||||
)
|
||||
else:
|
||||
rpc = raw.functions.messages.SendReaction(
|
||||
peer=await self.resolve_peer(chat_id),
|
||||
msg_id=message_id,
|
||||
reaction=[raw.types.ReactionEmoji(emoticon=emoji)] if emoji else None,
|
||||
reaction=emoji,
|
||||
big=big
|
||||
)
|
||||
)
|
||||
|
||||
await self.invoke(rpc)
|
||||
|
||||
return True
|
||||
|
@ -47,34 +47,46 @@ class GetStoriesArchive:
|
||||
offset_id (``int``, *optional*):
|
||||
Identifier of the first story to be returned.
|
||||
|
||||
Returns:
|
||||
``Generator``: On success, a generator yielding :obj:`~pyrogram.types.Story` objects is returned.
|
||||
Yields:
|
||||
:obj:`~pyrogram.types.Story` objects.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
# Get story archive
|
||||
# Get stories archive
|
||||
async for story in app.get_stories_archive(chat_id):
|
||||
print(story)
|
||||
|
||||
Raises:
|
||||
ValueError: In case of invalid arguments.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
current = 0
|
||||
total = abs(limit) or (1 << 31)
|
||||
limit = min(100, total)
|
||||
|
||||
r = await self.invoke(
|
||||
raw.functions.stories.GetStoriesArchive(
|
||||
peer=peer,
|
||||
offset_id=offset_id,
|
||||
limit=limit
|
||||
while True:
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
r = await self.invoke(
|
||||
raw.functions.stories.GetStoriesArchive(
|
||||
peer=peer,
|
||||
offset_id=offset_id,
|
||||
limit=limit
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
for story in r.stories:
|
||||
yield await types.Story._parse(
|
||||
self,
|
||||
story,
|
||||
{i.id: i for i in r.users},
|
||||
{i.id: i for i in r.chats},
|
||||
peer
|
||||
)
|
||||
if not r.stories:
|
||||
return
|
||||
|
||||
last = r.stories[-1]
|
||||
offset_id = last.id
|
||||
|
||||
for story in r.stories:
|
||||
yield await types.Story._parse(
|
||||
self,
|
||||
story,
|
||||
{i.id: i for i in r.users},
|
||||
{i.id: i for i in r.chats},
|
||||
peer
|
||||
)
|
||||
|
||||
current += 1
|
||||
|
||||
if current >= total:
|
||||
return
|
||||
|
@ -28,7 +28,7 @@ class PinStories:
|
||||
self: "pyrogram.Client",
|
||||
chat_id: Union[int, str],
|
||||
stories_ids: Union[int, Iterable[int]],
|
||||
pinned: bool,
|
||||
pinned: bool = False,
|
||||
) -> List[int]:
|
||||
"""Toggle stories pinned.
|
||||
|
||||
|
@ -3598,7 +3598,7 @@ class Message(Object, Update):
|
||||
else:
|
||||
await self.reply(button, quote=quote)
|
||||
|
||||
async def react(self, emoji: str = "", big: bool = False) -> bool:
|
||||
async def react(self, emoji: Union[int, str] = None, big: bool = False) -> bool:
|
||||
"""Bound method *react* of :obj:`~pyrogram.types.Message`.
|
||||
|
||||
Use as a shortcut for:
|
||||
|
Loading…
Reference in New Issue
Block a user