Skip to content

Commit a556976

Browse files
committed
Add Message.forward_from_message_id and Message.channel_post_author
1 parent 8082a3d commit a556976

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

botogram/objects/messages.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ def from_(self):
334334
"entities": ParsedText,
335335
"forward_from": User,
336336
"forward_from_chat": Chat,
337+
"forward_from_message_id": int,
337338
"forward_date": int,
338339
"reply_to_message": _itself,
339340
"text": str,
@@ -394,6 +395,16 @@ def forward_from(self):
394395
if self._forward_from is not None:
395396
return self._forward_from
396397

398+
@property
399+
def channel_post_author(self):
400+
"""Get the author of the channel post"""
401+
if self.chat.type == "channel":
402+
return self.sender
403+
404+
if self._forward_from_chat is not None:
405+
if self.forward_from.type == "channel":
406+
return self._forward_from
407+
397408
@property
398409
@utils.deprecated("Message.new_chat_participant", "1.0",
399410
"Rename property to Message.new_chat_member")

docs/api/telegram.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,13 @@ about its business.
11301130

11311131
The value can also be an instance of :py:class:`~botogram.Chat`.
11321132

1133+
.. py:attribute:: forward_from_message_id
1134+
1135+
The ID of the original message that was forwarded. This is currently only
1136+
available for channel posts.
1137+
1138+
.. versionadded:: 0.4
1139+
11331140
.. py:attribute:: forward_date
11341141
11351142
The integer date (in Unix time) of when the original message was sent,
@@ -1229,6 +1236,14 @@ about its business.
12291236

12301237
*This attribute can be None if the message isn't a venue.*
12311238

1239+
.. py:attribute:: channel_post_author
1240+
1241+
The author of the message. This only works if the message is a channel
1242+
post and it's signed by the author, even if the message is forwarded.
1243+
Otherwise it's *None*.
1244+
1245+
.. versionadded:: 0.4
1246+
12321247
.. py:attribute:: new_chat_member
12331248
12341249
A :py:class:`~botogram.User` object representing a new member of a group

docs/changelog/0.4.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ New features
6060

6161
* New method :py:meth:`botogram.Message.edit_attach`
6262

63+
* Added new attributes on the :py:class:`~botogram.Message` object:
64+
65+
* New attribute :py:attr:`botogram.Message.channel_post_author`
66+
* New attribute :py:attr:`botogram.Message.forward_from_message_id`
67+
6368
Performance improvements
6469
------------------------
6570

0 commit comments

Comments
 (0)