Skip to content

Commit 4bb921c

Browse files
author
Pietro Albini
committed
Merge pull request #49 from thesharp/master
2 parents 6913d01 + 7af7196 commit 4bb921c

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

botogram/objects/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from .base import BaseObject, multiple, _itself
1010
from . import mixins
11+
from .. import utils
1112

1213

1314
class User(BaseObject, mixins.ChatMixin):
@@ -303,6 +304,12 @@ class Message(BaseObject, mixins.MessageMixin):
303304
https://core.telegram.org/bots/api#message
304305
"""
305306

307+
@property
308+
@utils.deprecated("Message.from_", "1.0",
309+
"Rename property to Message.sender")
310+
def from_(self):
311+
return self.sender
312+
306313
required = {
307314
"message_id": int,
308315
"from": User,
@@ -335,7 +342,7 @@ class Message(BaseObject, mixins.MessageMixin):
335342
"migrate_from_chat_id": int,
336343
}
337344
replace_keys = {
338-
"from": "from_",
345+
"from": "sender",
339346
}
340347

341348

docs/api/telegram.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,26 @@ about its business.
508508
509509
The integer ID of the message.
510510

511+
.. py:attribute:: sender
512+
513+
The sending :py:class:`~botogram.User` of the message. Note the trailing
514+
underscore, needed due to 'from' being a python keyword.
515+
516+
*This attribute can be None if it's not provided by Telegram.*
517+
518+
.. versionchanged:: 0.2
519+
520+
Before it was called ``from_``.
521+
511522
.. py:attribute:: from_
512523
513524
The sending :py:class:`~botogram.User` of the message. Note the trailing
514525
underscore, needed due to 'from' being a python keyword.
515526

516527
*This attribute can be None if it's not provided by Telegram.*
517528

529+
.. deprecated:: 0.2 It will be removed in botogram 1.0
530+
518531
.. py:attribute:: date
519532
520533
The integer date of when the message was sent, in Unix time.

docs/channels.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ cites botogram in a chat, you can do this:
7777
@bot.message_contains("botogram")
7878
def we_are_famous(bot, chat, message):
7979
user = "Someone"
80-
if message.from_.username is not None:
81-
user = message.from_.username
80+
if message.sender.username is not None:
81+
user = message.sender.username
8282
8383
bot.send("@my_channel", "%s mentioned botogram!" % user)
8484

docs/custom-components.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ the :py:meth:`botogram.Component.add_before_processing_hook` method:
9595
self.add_before_processing_hook(self.filter)
9696
9797
def filter(self, chat, message):
98-
if message.from_.id not in self.allowed:
98+
if message.sender.id not in self.allowed:
9999
return True # Stop processing the update
100100
101101
And the component is complete! The filter simply checks if the message
@@ -117,7 +117,7 @@ source code of the component is the following:
117117
self.add_before_processing_hook(self.filter)
118118
119119
def filter(self, chat, message):
120-
if message.from_.id not in self.allowed:
120+
if message.sender.id not in self.allowed:
121121
return True # Stop processing the update
122122
123123
.. _custom-components-use:

0 commit comments

Comments
 (0)