Implemented #1 (Sending messages read acknowledge)

This commit is contained in:
Lonami 2016-10-02 13:57:03 +02:00
parent 30f15e67ac
commit 1ecd51c7d1

View File

@ -21,7 +21,10 @@ from telethon.tl.functions import InvokeWithLayerRequest, InitConnectionRequest
from telethon.tl.functions.help import GetConfigRequest
from telethon.tl.functions.auth import SendCodeRequest, SignInRequest, SignUpRequest, LogOutRequest
from telethon.tl.functions.upload import SaveFilePartRequest, GetFileRequest
from telethon.tl.functions.messages import GetDialogsRequest, GetHistoryRequest, SendMessageRequest, SendMediaRequest
from telethon.tl.functions.messages import \
GetDialogsRequest, GetHistoryRequest, \
SendMessageRequest, SendMediaRequest, \
ReadHistoryRequest
import telethon.helpers as utils
import telethon.network.authenticator as authenticator
@ -279,6 +282,25 @@ class TelegramClient:
return total_messages, result.messages, users
def send_read_acknowledge(self, input_peer, messages=None, max_id=None):
"""Sends a "read acknowledge" (i.e., notifying the given peer that we've
read their messages, also known as the "double check ✅✅").
Either a list of messages (or a single message) can be given,
or the maximum message ID (until which message we want to send the read acknowledge).
Returns an AffectedMessages TLObject"""
if max_id is None:
if not messages:
raise InvalidParameterError('Either a message list or a max_id must be provided.')
if isinstance(messages, list):
max_id = max(msg.id for msg in messages)
else:
max_id = messages.id
return self.invoke(ReadHistoryRequest(peer=input_peer, max_id=max_id))
# endregion
# TODO Handle media downloading/uploading in a different session?