mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 14:04:51 +00:00
Pyrogram: Add message_thread_id and is_topic_message fields to Message class, and is_forum fields to Chat class
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
73554b9d38
commit
6f8aaa449c
2 changed files with 27 additions and 0 deletions
|
|
@ -63,6 +63,9 @@ class Message(Object, Update):
|
||||||
id (``int``):
|
id (``int``):
|
||||||
Unique message identifier inside this chat.
|
Unique message identifier inside this chat.
|
||||||
|
|
||||||
|
message_thread_id (``int``, *optional*):
|
||||||
|
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||||
|
|
||||||
from_user (:obj:`~pyrogram.types.User`, *optional*):
|
from_user (:obj:`~pyrogram.types.User`, *optional*):
|
||||||
Sender, empty for messages sent to channels.
|
Sender, empty for messages sent to channels.
|
||||||
|
|
||||||
|
|
@ -96,6 +99,9 @@ class Message(Object, Update):
|
||||||
forward_date (:py:obj:`~datetime.datetime`, *optional*):
|
forward_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
For forwarded messages, date the original message was sent.
|
For forwarded messages, date the original message was sent.
|
||||||
|
|
||||||
|
is_topic_message (``bool``, *optional*):
|
||||||
|
True, if the message is sent to a forum topic
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
The id of the message which this message directly replied to.
|
The id of the message which this message directly replied to.
|
||||||
|
|
||||||
|
|
@ -309,6 +315,7 @@ class Message(Object, Update):
|
||||||
*,
|
*,
|
||||||
client: "pyrogram.Client" = None,
|
client: "pyrogram.Client" = None,
|
||||||
id: int,
|
id: int,
|
||||||
|
message_thread_id: int = None,
|
||||||
from_user: "types.User" = None,
|
from_user: "types.User" = None,
|
||||||
sender_chat: "types.Chat" = None,
|
sender_chat: "types.Chat" = None,
|
||||||
date: datetime = None,
|
date: datetime = None,
|
||||||
|
|
@ -319,6 +326,7 @@ class Message(Object, Update):
|
||||||
forward_from_message_id: int = None,
|
forward_from_message_id: int = None,
|
||||||
forward_signature: str = None,
|
forward_signature: str = None,
|
||||||
forward_date: datetime = None,
|
forward_date: datetime = None,
|
||||||
|
is_topic_message: bool = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
reply_to_top_message_id: int = None,
|
reply_to_top_message_id: int = None,
|
||||||
reply_to_message: "Message" = None,
|
reply_to_message: "Message" = None,
|
||||||
|
|
@ -385,6 +393,7 @@ class Message(Object, Update):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.id = id
|
self.id = id
|
||||||
|
self.message_thread_id = message_thread_id
|
||||||
self.from_user = from_user
|
self.from_user = from_user
|
||||||
self.sender_chat = sender_chat
|
self.sender_chat = sender_chat
|
||||||
self.date = date
|
self.date = date
|
||||||
|
|
@ -395,6 +404,7 @@ class Message(Object, Update):
|
||||||
self.forward_from_message_id = forward_from_message_id
|
self.forward_from_message_id = forward_from_message_id
|
||||||
self.forward_signature = forward_signature
|
self.forward_signature = forward_signature
|
||||||
self.forward_date = forward_date
|
self.forward_date = forward_date
|
||||||
|
self.is_topic_message = is_topic_message
|
||||||
self.reply_to_message_id = reply_to_message_id
|
self.reply_to_message_id = reply_to_message_id
|
||||||
self.reply_to_top_message_id = reply_to_top_message_id
|
self.reply_to_top_message_id = reply_to_top_message_id
|
||||||
self.reply_to_message = reply_to_message
|
self.reply_to_message = reply_to_message
|
||||||
|
|
@ -612,6 +622,7 @@ class Message(Object, Update):
|
||||||
return parsed_message
|
return parsed_message
|
||||||
|
|
||||||
if isinstance(message, raw.types.Message):
|
if isinstance(message, raw.types.Message):
|
||||||
|
message_thread_id = None
|
||||||
entities = [types.MessageEntity._parse(client, entity, users) for entity in message.entities]
|
entities = [types.MessageEntity._parse(client, entity, users) for entity in message.entities]
|
||||||
entities = types.List(filter(lambda x: x is not None, entities))
|
entities = types.List(filter(lambda x: x is not None, entities))
|
||||||
|
|
||||||
|
|
@ -621,6 +632,7 @@ class Message(Object, Update):
|
||||||
forward_from_message_id = None
|
forward_from_message_id = None
|
||||||
forward_signature = None
|
forward_signature = None
|
||||||
forward_date = None
|
forward_date = None
|
||||||
|
is_topic_message = None
|
||||||
|
|
||||||
forward_header = message.fwd_from # type: raw.types.MessageFwdHeader
|
forward_header = message.fwd_from # type: raw.types.MessageFwdHeader
|
||||||
|
|
||||||
|
|
@ -751,6 +763,7 @@ class Message(Object, Update):
|
||||||
|
|
||||||
parsed_message = Message(
|
parsed_message = Message(
|
||||||
id=message.id,
|
id=message.id,
|
||||||
|
message_thread_id=message_thread_id,
|
||||||
date=utils.timestamp_to_datetime(message.date),
|
date=utils.timestamp_to_datetime(message.date),
|
||||||
chat=types.Chat._parse(client, message, users, chats, is_chat=True),
|
chat=types.Chat._parse(client, message, users, chats, is_chat=True),
|
||||||
from_user=from_user,
|
from_user=from_user,
|
||||||
|
|
@ -783,6 +796,7 @@ class Message(Object, Update):
|
||||||
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,
|
||||||
|
is_topic_message=is_topic_message,
|
||||||
mentioned=message.mentioned,
|
mentioned=message.mentioned,
|
||||||
scheduled=is_scheduled,
|
scheduled=is_scheduled,
|
||||||
from_scheduled=message.from_scheduled,
|
from_scheduled=message.from_scheduled,
|
||||||
|
|
@ -817,6 +831,13 @@ class Message(Object, Update):
|
||||||
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
|
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
|
||||||
parsed_message.reply_to_top_message_id = message.reply_to.reply_to_top_id
|
parsed_message.reply_to_top_message_id = message.reply_to.reply_to_top_id
|
||||||
|
|
||||||
|
if message.reply_to.forum_topic:
|
||||||
|
if message.reply_to.reply_to_top_id:
|
||||||
|
parsed_message.message_thread_id = message.reply_to.reply_to_top_id
|
||||||
|
else:
|
||||||
|
parsed_message.message_thread_id = message.reply_to.reply_to_msg_id
|
||||||
|
parsed_message.is_topic_message = True
|
||||||
|
|
||||||
if replies:
|
if replies:
|
||||||
try:
|
try:
|
||||||
key = (parsed_message.chat.id, parsed_message.reply_to_message_id)
|
key = (parsed_message.chat.id, parsed_message.reply_to_message_id)
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,9 @@ class Chat(Object):
|
||||||
is_support (``bool``):
|
is_support (``bool``):
|
||||||
True, if this chat is part of the Telegram support team. Users and bots only.
|
True, if this chat is part of the Telegram support team. Users and bots only.
|
||||||
|
|
||||||
|
is_forum (``bool``, *optional*):
|
||||||
|
True, if the supergroup chat is a forum
|
||||||
|
|
||||||
title (``str``, *optional*):
|
title (``str``, *optional*):
|
||||||
Title, for supergroups, channels and basic group chats.
|
Title, for supergroups, channels and basic group chats.
|
||||||
|
|
||||||
|
|
@ -143,6 +146,7 @@ class Chat(Object):
|
||||||
is_scam: bool = None,
|
is_scam: bool = None,
|
||||||
is_fake: bool = None,
|
is_fake: bool = None,
|
||||||
is_support: bool = None,
|
is_support: bool = None,
|
||||||
|
is_forum: bool = None,
|
||||||
title: str = None,
|
title: str = None,
|
||||||
username: str = None,
|
username: str = None,
|
||||||
first_name: str = None,
|
first_name: str = None,
|
||||||
|
|
@ -174,6 +178,7 @@ class Chat(Object):
|
||||||
self.is_scam = is_scam
|
self.is_scam = is_scam
|
||||||
self.is_fake = is_fake
|
self.is_fake = is_fake
|
||||||
self.is_support = is_support
|
self.is_support = is_support
|
||||||
|
self.is_forum = is_forum
|
||||||
self.title = title
|
self.title = title
|
||||||
self.username = username
|
self.username = username
|
||||||
self.first_name = first_name
|
self.first_name = first_name
|
||||||
|
|
@ -246,6 +251,7 @@ class Chat(Object):
|
||||||
is_creator=getattr(channel, "creator", None),
|
is_creator=getattr(channel, "creator", None),
|
||||||
is_scam=getattr(channel, "scam", None),
|
is_scam=getattr(channel, "scam", None),
|
||||||
is_fake=getattr(channel, "fake", None),
|
is_fake=getattr(channel, "fake", None),
|
||||||
|
is_forum=getattr(channel, "forum", None),
|
||||||
title=channel.title,
|
title=channel.title,
|
||||||
username=getattr(channel, "username", None),
|
username=getattr(channel, "username", None),
|
||||||
photo=types.ChatPhoto._parse(client, getattr(channel, "photo", None), peer_id,
|
photo=types.ChatPhoto._parse(client, getattr(channel, "photo", None), peer_id,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue