Skip to content

Commit 0a5ad9c

Browse files
authored
Enhancements in message forwarding (#123)
* Fix installation documentation * Other documentation fixes * Enchantments in message forwarding * Add changelog * Fix PEP-8 * Fix typo
1 parent b1f98e3 commit 0a5ad9c

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

botogram/objects/messages.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ def from_(self):
334334
"forward_from": User,
335335
"forward_from_chat": Chat,
336336
"forward_from_message_id": int,
337+
"forward_sender_name": str,
338+
"forward_signature": str,
337339
"forward_date": int,
338340
"reply_to_message": _itself,
339341
"text": str,
@@ -369,6 +371,7 @@ def from_(self):
369371
# Those are provided dynamically by self.forward_from
370372
"forward_from": "_forward_from",
371373
"forward_from_chat": "_forward_from_chat",
374+
"forward_sender_name": "_forward_sender_name",
372375
}
373376
_check_equality_ = "message_id"
374377

@@ -390,12 +393,24 @@ def forward_from(self):
390393
"""Get from where the message was forwarded"""
391394
# Provide either _forward_from or _forward_from_chat
392395
# _forward_from_chat is checked earlier because it's more correct
396+
# _forward_sender_name is returned if the original sender
397+
# has opted to hide his account
398+
393399
if self._forward_from_chat is not None:
394400
return self._forward_from_chat
395401

396402
if self._forward_from is not None:
397403
return self._forward_from
398404

405+
if self._forward_sender_name is not None:
406+
return self._forward_sender_name
407+
408+
@property
409+
def forward_hidden(self):
410+
"""Check if the original sender is hidden or not"""
411+
412+
return isinstance(self.forward_from, str)
413+
399414
@property
400415
def channel_post_author(self):
401416
"""Get the author of the channel post"""

docs/api/telegram.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,27 +1571,45 @@ about its business.
15711571

15721572
* :py:class:`~botogram.User` when the original sender is an user
15731573
* :py:class:`~botogram.Chat` when the message originated in a channel
1574+
* A string, when the original sender has opted to hide his account.
1575+
In this case, the attribute :py:attr:`~botogram.Message.forward_hidden` is set to ``True``.
15741576

15751577
*This attribute can be None if it's not provided by Telegram.*
15761578

15771579
.. versionchanged:: 0.3
15781580

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

1583+
.. versionchanged:: 0.7
1584+
1585+
The value can also be a string if the original sender is hidden.
1586+
15811587
.. py:attribute:: forward_from_message_id
15821588
15831589
The ID of the original message that was forwarded. This is currently only
15841590
available for channel posts.
15851591

15861592
.. versionadded:: 0.4
15871593

1594+
.. py:attribute:: forward_signature
1595+
1596+
The signature of the post author if present. This is currently only available for channel posts.
1597+
1598+
.. versionadded:: 0.7
1599+
15881600
.. py:attribute:: forward_date
15891601
15901602
The integer date (in Unix time) of when the original message was sent,
15911603
when this message is a forward.
15921604

15931605
*This attribute can be None if it's not provided by Telegram.*
15941606

1607+
.. py:attribute:: forward_hidden
1608+
1609+
When ``True`` indicates that the original sender has opted to hide his account.
1610+
1611+
.. versionadded:: 0.7
1612+
15951613
.. py:attribute:: reply_to_message
15961614
15971615
The :py:class:`~botogram.Message` for which *this* message is a reply to.

docs/changelog/0.7.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.. Copyright (c) 2015-2019 The Botogram Authors (see AUTHORS)
2+
Documentation released under the MIT license (see LICENSE)
3+
4+
===========================
5+
Changelog of botogram 0.7.x
6+
===========================
7+
8+
Here you can find all the changes in the botogram 0.7.x releases.
9+
10+
.. _changelog-0.7:
11+
12+
botogram 0.7
13+
============
14+
15+
*Alpha release, not yet released.*
16+
17+
Release description not yet written.
18+
19+
New features
20+
------------
21+
22+
* Enhancements in message forwarding
23+
24+
* New return type for :py:attr:`~Message.forward_from`
25+
* New attribute :py:attr:`~Message.forward_hidden`
26+
* New attribute :py:attr:`~Message.forward_signature`
27+
28+
29+
Bug fixes
30+
---------

0 commit comments

Comments
 (0)