mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Implemented #1 (Sending messages read acknowledge)
This commit is contained in:
parent
30f15e67ac
commit
1ecd51c7d1
|
@ -21,7 +21,10 @@ from telethon.tl.functions import InvokeWithLayerRequest, InitConnectionRequest
|
||||||
from telethon.tl.functions.help import GetConfigRequest
|
from telethon.tl.functions.help import GetConfigRequest
|
||||||
from telethon.tl.functions.auth import SendCodeRequest, SignInRequest, SignUpRequest, LogOutRequest
|
from telethon.tl.functions.auth import SendCodeRequest, SignInRequest, SignUpRequest, LogOutRequest
|
||||||
from telethon.tl.functions.upload import SaveFilePartRequest, GetFileRequest
|
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.helpers as utils
|
||||||
import telethon.network.authenticator as authenticator
|
import telethon.network.authenticator as authenticator
|
||||||
|
@ -279,6 +282,25 @@ class TelegramClient:
|
||||||
|
|
||||||
return total_messages, result.messages, users
|
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
|
# endregion
|
||||||
|
|
||||||
# TODO Handle media downloading/uploading in a different session?
|
# TODO Handle media downloading/uploading in a different session?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user