mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Update pin_chat_message to return Message instead of bool
This commit is contained in:
parent
58eb10a676
commit
8ee5ea02b1
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from pyrogram import raw
|
from pyrogram import raw, types
|
||||||
from pyrogram.scaffold import Scaffold
|
from pyrogram.scaffold import Scaffold
|
||||||
|
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class PinChatMessage(Scaffold):
|
|||||||
message_id: int,
|
message_id: int,
|
||||||
disable_notification: bool = False,
|
disable_notification: bool = False,
|
||||||
both_sides: bool = False,
|
both_sides: bool = False,
|
||||||
) -> bool:
|
) -> "types.Message":
|
||||||
"""Pin a message in a group, channel or your own chat.
|
"""Pin a message in a group, channel or your own chat.
|
||||||
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in
|
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in
|
||||||
the supergroup or "can_edit_messages" admin right in the channel.
|
the supergroup or "can_edit_messages" admin right in the channel.
|
||||||
@ -50,7 +50,7 @@ class PinChatMessage(Scaffold):
|
|||||||
Applicable to private chats only. Defaults to False.
|
Applicable to private chats only. Defaults to False.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
``bool``: True on success.
|
:obj:`~pyrogram.types.Message`: On success, the service message is returned.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@ -61,7 +61,7 @@ class PinChatMessage(Scaffold):
|
|||||||
# Pin without notification
|
# Pin without notification
|
||||||
app.pin_chat_message(chat_id, message_id, disable_notification=True)
|
app.pin_chat_message(chat_id, message_id, disable_notification=True)
|
||||||
"""
|
"""
|
||||||
await self.send(
|
r = await self.send(
|
||||||
raw.functions.messages.UpdatePinnedMessage(
|
raw.functions.messages.UpdatePinnedMessage(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
id=message_id,
|
id=message_id,
|
||||||
@ -70,4 +70,10 @@ class PinChatMessage(Scaffold):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
users = {u.id: u for u in r.users}
|
||||||
|
chats = {c.id: c for c in r.chats}
|
||||||
|
|
||||||
|
for i in r.updates:
|
||||||
|
if isinstance(i, (raw.types.UpdateNewMessage,
|
||||||
|
raw.types.UpdateNewChannelMessage)):
|
||||||
|
return await types.Message._parse(self, i.message, users, chats)
|
||||||
|
@ -3423,7 +3423,7 @@ class Message(Object, Update):
|
|||||||
options=option
|
options=option
|
||||||
)
|
)
|
||||||
|
|
||||||
async def pin(self, disable_notification: bool = False, both_sides: bool = False) -> bool:
|
async def pin(self, disable_notification: bool = False, both_sides: bool = False) -> "types.Message":
|
||||||
"""Bound method *pin* of :obj:`~pyrogram.types.Message`.
|
"""Bound method *pin* of :obj:`~pyrogram.types.Message`.
|
||||||
|
|
||||||
Use as a shortcut for:
|
Use as a shortcut for:
|
||||||
@ -3450,7 +3450,7 @@ class Message(Object, Update):
|
|||||||
Applicable to private chats only. Defaults to False.
|
Applicable to private chats only. Defaults to False.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
True on success.
|
:obj:`~pyrogram.types.Message`: On success, the service message is returned.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
RPCError: In case of a Telegram RPC error.
|
RPCError: In case of a Telegram RPC error.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user