mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 05:30:15 +00:00
Merge branch 'develop' into asyncio
# Conflicts: # pyrogram/client/ext/utils.py # pyrogram/client/types/messages_and_media/message.py
This commit is contained in:
commit
cedb1f069a
@ -1,4 +1,5 @@
|
|||||||
id message
|
id message
|
||||||
CHAT_WRITE_FORBIDDEN You don't have rights to send messages in this chat
|
CHAT_WRITE_FORBIDDEN You don't have rights to send messages in this chat
|
||||||
RIGHT_FORBIDDEN One or more admin rights can't be applied to this kind of chat (channel/supergroup)
|
RIGHT_FORBIDDEN One or more admin rights can't be applied to this kind of chat (channel/supergroup)
|
||||||
CHAT_ADMIN_INVITE_REQUIRED You don't have rights to invite other users
|
CHAT_ADMIN_INVITE_REQUIRED You don't have rights to invite other users
|
||||||
|
MESSAGE_DELETE_FORBIDDEN You don't have rights to delete messages in this chat
|
|
@ -618,6 +618,7 @@ async def parse_messages(
|
|||||||
forward_from_message_id=forward_from_message_id,
|
forward_from_message_id=forward_from_message_id,
|
||||||
forward_signature=forward_signature,
|
forward_signature=forward_signature,
|
||||||
forward_date=forward_date,
|
forward_date=forward_date,
|
||||||
|
mentioned=message.mentioned,
|
||||||
edit_date=message.edit_date,
|
edit_date=message.edit_date,
|
||||||
media_group_id=message.grouped_id,
|
media_group_id=message.grouped_id,
|
||||||
photo=photo,
|
photo=photo,
|
||||||
@ -652,7 +653,7 @@ async def parse_messages(
|
|||||||
replies=replies - 1
|
replies=replies - 1
|
||||||
)
|
)
|
||||||
except MessageIdsEmpty:
|
except MessageIdsEmpty:
|
||||||
m.reply_to_message = None
|
pass
|
||||||
elif isinstance(message, types.MessageService):
|
elif isinstance(message, types.MessageService):
|
||||||
action = message.action
|
action = message.action
|
||||||
|
|
||||||
@ -753,11 +754,14 @@ async def parse_messages(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(action, types.MessageActionPinMessage):
|
if isinstance(action, types.MessageActionPinMessage):
|
||||||
m.pinned_message = await client.get_messages(
|
try:
|
||||||
m.chat.id,
|
m.pinned_message = await client.get_messages(
|
||||||
reply_to_message_ids=message.id,
|
m.chat.id,
|
||||||
replies=0
|
reply_to_message_ids=message.id,
|
||||||
)
|
replies=0
|
||||||
|
)
|
||||||
|
except MessageIdsEmpty:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
m = pyrogram_types.Message(message_id=message.id, client=proxy(client))
|
m = pyrogram_types.Message(message_id=message.id, client=proxy(client))
|
||||||
|
|
||||||
|
@ -168,6 +168,9 @@ class Filters:
|
|||||||
|
|
||||||
dan = create("Dan", lambda _, m: bool(m.from_user and m.from_user.id == 23122162))
|
dan = create("Dan", lambda _, m: bool(m.from_user and m.from_user.id == 23122162))
|
||||||
|
|
||||||
|
mentioned = create("Mentioned", lambda _, m: bool(m.mentioned))
|
||||||
|
"""Filter messages containing mentions"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def command(command: str or list,
|
def command(command: str or list,
|
||||||
prefix: str or list = "/",
|
prefix: str or list = "/",
|
||||||
@ -281,15 +284,16 @@ class Filters:
|
|||||||
Args:
|
Args:
|
||||||
chats (``int`` | ``str`` | ``list``):
|
chats (``int`` | ``str`` | ``list``):
|
||||||
Pass one or more chat ids/usernames to filter chats.
|
Pass one or more chat ids/usernames to filter chats.
|
||||||
|
For your personal cloud (Saved Messages) you can simply use “me” or “self”.
|
||||||
Defaults to None (no chats).
|
Defaults to None (no chats).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, chats: int or str or list = None):
|
def __init__(self, chats: int or str or list = None):
|
||||||
chats = [] if chats is None else chats if type(chats) is list else [chats]
|
chats = [] if chats is None else chats if type(chats) is list else [chats]
|
||||||
super().__init__(
|
super().__init__(
|
||||||
{i.lower().strip("@") if type(i) is str else i for i in chats}
|
{"me" if i in ["me", "self"] else i.lower().strip("@") if type(i) is str else i for i in chats}
|
||||||
if type(chats) is list else
|
if type(chats) is list else
|
||||||
{chats.lower().strip("@") if type(chats) is str else chats}
|
{"me" if chats in ["me", "self"] else chats.lower().strip("@") if type(chats) is str else chats}
|
||||||
)
|
)
|
||||||
|
|
||||||
def __call__(self, message):
|
def __call__(self, message):
|
||||||
@ -297,7 +301,10 @@ class Filters:
|
|||||||
message.chat
|
message.chat
|
||||||
and (message.chat.id in self
|
and (message.chat.id in self
|
||||||
or (message.chat.username
|
or (message.chat.username
|
||||||
and message.chat.username.lower() in self))
|
and message.chat.username.lower() in self)
|
||||||
|
or ("me" in self and message.from_user
|
||||||
|
and message.from_user.is_self
|
||||||
|
and not message.outgoing))
|
||||||
)
|
)
|
||||||
|
|
||||||
service = create(
|
service = create(
|
||||||
|
@ -55,6 +55,9 @@ class Message(Object):
|
|||||||
For replies, the original message. Note that the Message object in this field will not contain
|
For replies, the original message. Note that the Message object in this field will not contain
|
||||||
further reply_to_message fields even if it itself is a reply.
|
further reply_to_message fields even if it itself is a reply.
|
||||||
|
|
||||||
|
mentioned (``bool``, *optional*):
|
||||||
|
The message contains a mention.
|
||||||
|
|
||||||
edit_date (``int``, *optional*):
|
edit_date (``int``, *optional*):
|
||||||
Date the message was last edited in Unix time.
|
Date the message was last edited in Unix time.
|
||||||
|
|
||||||
@ -206,6 +209,7 @@ class Message(Object):
|
|||||||
forward_signature: str = None,
|
forward_signature: str = None,
|
||||||
forward_date: int = None,
|
forward_date: int = None,
|
||||||
reply_to_message=None,
|
reply_to_message=None,
|
||||||
|
mentioned=None,
|
||||||
edit_date: int = None,
|
edit_date: int = None,
|
||||||
media_group_id: str = None,
|
media_group_id: str = None,
|
||||||
author_signature: str = None,
|
author_signature: str = None,
|
||||||
@ -253,6 +257,7 @@ class Message(Object):
|
|||||||
self.forward_signature = forward_signature # flags.4?string
|
self.forward_signature = forward_signature # flags.4?string
|
||||||
self.forward_date = forward_date # flags.5?int
|
self.forward_date = forward_date # flags.5?int
|
||||||
self.reply_to_message = reply_to_message # flags.6?Message
|
self.reply_to_message = reply_to_message # flags.6?Message
|
||||||
|
self.mentioned = mentioned
|
||||||
self.edit_date = edit_date # flags.7?int
|
self.edit_date = edit_date # flags.7?int
|
||||||
self.media_group_id = media_group_id # flags.8?string
|
self.media_group_id = media_group_id # flags.8?string
|
||||||
self.author_signature = author_signature # flags.9?string
|
self.author_signature = author_signature # flags.9?string
|
||||||
@ -364,6 +369,54 @@ class Message(Object):
|
|||||||
reply_markup=reply_markup
|
reply_markup=reply_markup
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def edit(self, text: str, parse_mode: str = "", disable_web_page_preview: bool = None, reply_markup=None):
|
||||||
|
"""Bound method *edit* of :obj:`Message <pyrogram.Message>
|
||||||
|
|
||||||
|
Use as a shortcut for:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
client.edit_message_text(
|
||||||
|
chat_id=message.chat.id,
|
||||||
|
message_id=message.message_id,
|
||||||
|
text="hello",
|
||||||
|
)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
message.edit("hello")
|
||||||
|
|
||||||
|
Args:
|
||||||
|
text (``str``):
|
||||||
|
New text of the message.
|
||||||
|
|
||||||
|
parse_mode (``str``, *optional*):
|
||||||
|
Use :obj:`MARKDOWN <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.HTML>`
|
||||||
|
if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your message.
|
||||||
|
Defaults to Markdown.
|
||||||
|
|
||||||
|
disable_web_page_preview (``bool``, *optional*):
|
||||||
|
Disables link previews for links in this message.
|
||||||
|
|
||||||
|
reply_markup (:obj:`InlineKeyboardMarkup`, *optional*):
|
||||||
|
An InlineKeyboardMarkup object.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
On success, the edited :obj:`Message <pyrogram.Message>` is returned.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
|
"""
|
||||||
|
return await self._client.edit_message_text(
|
||||||
|
chat_id=self.chat.id,
|
||||||
|
message_id=self.message_id,
|
||||||
|
text=text,
|
||||||
|
parse_mode=parse_mode,
|
||||||
|
disable_web_page_preview=disable_web_page_preview,
|
||||||
|
reply_markup=reply_markup
|
||||||
|
)
|
||||||
|
|
||||||
async def forward(self,
|
async def forward(self,
|
||||||
chat_id: int or str,
|
chat_id: int or str,
|
||||||
disable_notification: bool = None):
|
disable_notification: bool = None):
|
||||||
|
Loading…
Reference in New Issue
Block a user