diff --git a/botogram/objects/messages.py b/botogram/objects/messages.py index 1778eec..3a868c4 100644 --- a/botogram/objects/messages.py +++ b/botogram/objects/messages.py @@ -334,6 +334,8 @@ def from_(self): "forward_from": User, "forward_from_chat": Chat, "forward_from_message_id": int, + "forward_sender_name": str, + "forward_signature": str, "forward_date": int, "reply_to_message": _itself, "text": str, @@ -369,6 +371,7 @@ def from_(self): # Those are provided dynamically by self.forward_from "forward_from": "_forward_from", "forward_from_chat": "_forward_from_chat", + "forward_sender_name": "_forward_sender_name", } _check_equality_ = "message_id" @@ -390,12 +393,24 @@ def forward_from(self): """Get from where the message was forwarded""" # Provide either _forward_from or _forward_from_chat # _forward_from_chat is checked earlier because it's more correct + # _forward_sender_name is returned if the original sender + # has opted to hide his account + if self._forward_from_chat is not None: return self._forward_from_chat if self._forward_from is not None: return self._forward_from + if self._forward_sender_name is not None: + return self._forward_sender_name + + @property + def forward_hidden(self): + """Check if the original sender is hidden or not""" + + return isinstance(self.forward_from, str) + @property def channel_post_author(self): """Get the author of the channel post""" diff --git a/docs/api/telegram.rst b/docs/api/telegram.rst index e056c9a..4b9134b 100644 --- a/docs/api/telegram.rst +++ b/docs/api/telegram.rst @@ -1571,6 +1571,8 @@ about its business. * :py:class:`~botogram.User` when the original sender is an user * :py:class:`~botogram.Chat` when the message originated in a channel + * A string, when the original sender has opted to hide his account. + In this case, the attribute :py:attr:`~botogram.Message.forward_hidden` is set to ``True``. *This attribute can be None if it's not provided by Telegram.* @@ -1578,6 +1580,10 @@ about its business. The value can also be an instance of :py:class:`~botogram.Chat`. + .. versionchanged:: 0.7 + + The value can also be a string if the original sender is hidden. + .. py:attribute:: forward_from_message_id The ID of the original message that was forwarded. This is currently only @@ -1585,6 +1591,12 @@ about its business. .. versionadded:: 0.4 + .. py:attribute:: forward_signature + + The signature of the post author if present. This is currently only available for channel posts. + + .. versionadded:: 0.7 + .. py:attribute:: forward_date The integer date (in Unix time) of when the original message was sent, @@ -1592,6 +1604,12 @@ about its business. *This attribute can be None if it's not provided by Telegram.* + .. py:attribute:: forward_hidden + + When ``True`` indicates that the original sender has opted to hide his account. + + .. versionadded:: 0.7 + .. py:attribute:: reply_to_message The :py:class:`~botogram.Message` for which *this* message is a reply to. diff --git a/docs/changelog/0.7.rst b/docs/changelog/0.7.rst new file mode 100644 index 0000000..9a8f721 --- /dev/null +++ b/docs/changelog/0.7.rst @@ -0,0 +1,30 @@ +.. Copyright (c) 2015-2019 The Botogram Authors (see AUTHORS) + Documentation released under the MIT license (see LICENSE) + +=========================== +Changelog of botogram 0.7.x +=========================== + +Here you can find all the changes in the botogram 0.7.x releases. + +.. _changelog-0.7: + +botogram 0.7 +============ + +*Alpha release, not yet released.* + +Release description not yet written. + +New features +------------ + +* Enhancements in message forwarding + + * New return type for :py:attr:`~Message.forward_from` + * New attribute :py:attr:`~Message.forward_hidden` + * New attribute :py:attr:`~Message.forward_signature` + + +Bug fixes +---------