mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-14 13:36:43 +03:00
Add clear_mentions parameter to .send_read_acknowledge()
This commit is contained in:
parent
045f7f5643
commit
8038971753
|
@ -32,7 +32,7 @@ from .tl.functions.contacts import (
|
||||||
from .tl.functions.messages import (
|
from .tl.functions.messages import (
|
||||||
GetDialogsRequest, GetHistoryRequest, SendMediaRequest,
|
GetDialogsRequest, GetHistoryRequest, SendMediaRequest,
|
||||||
SendMessageRequest, GetChatsRequest, GetAllDraftsRequest,
|
SendMessageRequest, GetChatsRequest, GetAllDraftsRequest,
|
||||||
CheckChatInviteRequest
|
CheckChatInviteRequest, ReadMentionsRequest
|
||||||
)
|
)
|
||||||
|
|
||||||
from .tl.functions import channels
|
from .tl.functions import channels
|
||||||
|
@ -639,7 +639,8 @@ class TelegramClient(TelegramBareClient):
|
||||||
|
|
||||||
return messages
|
return messages
|
||||||
|
|
||||||
def send_read_acknowledge(self, entity, message=None, max_id=None):
|
def send_read_acknowledge(self, entity, message=None, max_id=None,
|
||||||
|
clear_mentions=False):
|
||||||
"""
|
"""
|
||||||
Sends a "read acknowledge" (i.e., notifying the given peer that we've
|
Sends a "read acknowledge" (i.e., notifying the given peer that we've
|
||||||
read their messages, also known as the "double check").
|
read their messages, also known as the "double check").
|
||||||
|
@ -654,23 +655,38 @@ class TelegramClient(TelegramBareClient):
|
||||||
max_id (:obj:`int`):
|
max_id (:obj:`int`):
|
||||||
Overrides messages, until which message should the
|
Overrides messages, until which message should the
|
||||||
acknowledge should be sent.
|
acknowledge should be sent.
|
||||||
|
|
||||||
|
clear_mentions (:obj:`bool`):
|
||||||
|
Whether the mention badge should be cleared (so that
|
||||||
|
there are no more mentions) or not for the given entity.
|
||||||
|
|
||||||
|
If no message is provided, this will be the only action
|
||||||
|
taken.
|
||||||
"""
|
"""
|
||||||
if max_id is None:
|
if max_id is None:
|
||||||
if not messages:
|
if message:
|
||||||
raise ValueError(
|
|
||||||
'Either a message list or a max_id must be provided.')
|
|
||||||
|
|
||||||
if hasattr(message, '__iter__'):
|
if hasattr(message, '__iter__'):
|
||||||
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 = self.get_input_entity(entity)
|
entity = self.get_input_entity(entity)
|
||||||
|
if clear_mentions:
|
||||||
|
self(ReadMentionsRequest(entity))
|
||||||
|
if max_id is None:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if max_id is not None:
|
||||||
if isinstance(entity, InputPeerChannel):
|
if isinstance(entity, InputPeerChannel):
|
||||||
return self(channels.ReadHistoryRequest(entity, max_id=max_id))
|
return self(channels.ReadHistoryRequest(entity, max_id=max_id))
|
||||||
else:
|
else:
|
||||||
return self(messages.ReadHistoryRequest(entity, max_id=max_id))
|
return self(messages.ReadHistoryRequest(entity, max_id=max_id))
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_reply_to(reply_to):
|
def _get_reply_to(reply_to):
|
||||||
"""Sanitizes the 'reply_to' parameter a user may send"""
|
"""Sanitizes the 'reply_to' parameter a user may send"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user