Partial update to layer 120

This commit is contained in:
Lonami Exo
2020-10-30 20:06:31 +01:00
parent 353b88ea5a
commit d83c154f8d
4 changed files with 31 additions and 22 deletions

View File

@@ -1247,7 +1247,7 @@ class MessageMethods:
notify: bool = False
):
"""
Pins or unpins a message in a chat.
Pins a message in a chat.
The default behaviour is to *not* notify members, unlike the
official applications.

View File

@@ -31,14 +31,15 @@ class ChatAction(EventBuilder):
"""
@classmethod
def build(cls, update, others=None, self_id=None):
if isinstance(update, types.UpdateChannelPinnedMessage) and update.id == 0:
raise RuntimeError('FIXME: handle new pinned updates')
if isinstance(update, types.UpdatePinnedChannelMessages) and update.id == 0:
# Telegram does not always send
# UpdateChannelPinnedMessage for new pins
# but always for unpin, with update.id = 0
return cls.Event(types.PeerChannel(update.channel_id),
unpin=True)
elif isinstance(update, types.UpdateChatPinnedMessage) and update.id == 0:
elif isinstance(update, types.UpdatePinnedMessages) and update.id == 0:
return cls.Event(types.PeerChat(update.chat_id),
unpin=True)

View File

@@ -61,6 +61,9 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
Whether the edited mark of this message is edited
should be hidden (e.g. in GUI clients) or shown.
pinned (`bool`):
Whether this message is currently pinned or not.
id (`int`):
The ID of this message. This field is *always* present.
Any other member is optional and may be `None`.
@@ -166,8 +169,8 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
fwd_from=None, via_bot_id=None, media=None, reply_markup=None,
entities=None, views=None, edit_date=None, post_author=None,
grouped_id=None, from_scheduled=None, legacy=None,
edit_hide=None, restriction_reason=None, forwards=None,
replies=None,
edit_hide=None, pinned=None, restriction_reason=None,
forwards=None, replies=None,
# For MessageAction (mandatory)
action=None):
@@ -195,6 +198,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
self.forwards = forwards
self.replies = replies
self.edit_date = edit_date
self.pinned = pinned
self.post_author = post_author
self.grouped_id = grouped_id
self.restriction_reason = restriction_reason