Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions botogram/objects/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"

Expand All @@ -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"""
Expand Down
18 changes: 18 additions & 0 deletions docs/api/telegram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1571,27 +1571,45 @@ 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.*

.. versionchanged:: 0.3

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
available for channel posts.

.. 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,
when this message is a forward.

*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.
Expand Down
30 changes: 30 additions & 0 deletions docs/changelog/0.7.rst
Original file line number Diff line number Diff line change
@@ -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
---------