Better behaviour for send_read_acknowledge

This commit is contained in:
Lonami Exo 2018-11-24 20:30:10 +01:00
parent 7e168cb4fb
commit 09b16f96fc

View File

@ -725,6 +725,9 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
This effectively marks a message as read (or more than one) in the This effectively marks a message as read (or more than one) in the
given conversation. given conversation.
If neither message nor maximum ID are provided, all messages will be
marked as read by assuming that ``max_id = 0``.
Args: Args:
entity (`entity`): entity (`entity`):
The chat where these messages are located. The chat where these messages are located.
@ -744,14 +747,13 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
taken. taken.
""" """
if max_id is None: if max_id is None:
if message: if not message:
max_id = 0
else:
if utils.is_list_like(message): if utils.is_list_like(message):
max_id = max(msg.id for msg in message) max_id = max(msg.id for msg in message)
else: else:
max_id = message.id max_id = message.id
elif not clear_mentions:
raise ValueError(
'Either a message list or a max_id must be provided.')
entity = await self.get_input_entity(entity) entity = await self.get_input_entity(entity)
if clear_mentions: if clear_mentions: