Skip to content

Commit

Permalink
Pyrofork: Add sender_business_bot field to class Message
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Apr 5, 2024
1 parent 35eb8bf commit 3cce2ca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class Message(Object, Update):
The supergroup itself for messages from anonymous group administrators.
The linked channel for messages automatically forwarded to the discussion group.
sender_business_bot (:obj:`~pyrogram.types.User`, *optional*):
Sender of the message, sent on behalf of a business bot.
date (:py:obj:`~datetime.datetime`, *optional*):
Date the message was sent.
Expand Down Expand Up @@ -400,6 +403,7 @@ def __init__(
message_thread_id: int = None,
from_user: "types.User" = None,
sender_chat: "types.Chat" = None,
sender_business_bot: "types.User" = None,
date: datetime = None,
chat: "types.Chat" = None,
topics: "types.ForumTopic" = None,
Expand Down Expand Up @@ -502,6 +506,7 @@ def __init__(
self.message_thread_id = message_thread_id
self.from_user = from_user
self.sender_chat = sender_chat
self.sender_business_bot = sender_business_bot
self.date = date
self.chat = chat
self.topics = topics
Expand Down Expand Up @@ -876,6 +881,7 @@ async def _parse(
entities = [types.MessageEntity._parse(client, entity, users) for entity in message.entities]
entities = types.List(filter(lambda x: x is not None, entities))

sender_business_bot = None
forward_from = None
forward_sender_name = None
forward_from_chat = None
Expand Down Expand Up @@ -1027,6 +1033,9 @@ async def _parse(

reactions = types.MessageReactions._parse(client, message.reactions)

if message.via_business_bot_id:
sender_business_bot = types.User._parse(client, users.get(message.via_business_bot_id, None))

parsed_message = Message(
id=message.id,
message_thread_id=message_thread_id,
Expand All @@ -1035,6 +1044,7 @@ async def _parse(
topics=None,
from_user=from_user,
sender_chat=sender_chat,
sender_business_bot=sender_business_bot,
text=(
Str(message.message).init(entities) or None
if media is None or web_page_preview is not None
Expand Down

0 comments on commit 3cce2ca

Please sign in to comment.