Compare commits

...

4 Commits

Author SHA1 Message Date
Noam Meltzer 13ab6d43d3 CHANGES.rst: Added 7.0.1 release notes.
[ci skip]
2017-07-28 21:22:48 +03:00
Eldinnie 2ba7505eaf Fix TypeError exception in RegexHandler (#751)
fixes #750
2017-07-28 20:47:42 +03:00
Eldinnie 5ed06df840 callback query docstring (#749)
showed from instead of from_user and was missing the informational note about it.

[ci skip]
2017-07-28 17:41:25 +03:00
Noam Meltzer eef1238d60 Comment out unitest test_send_contact_with_contact
Caused too many "RetryAfter: Flood control exceeded" errors.

[ci skip]
2017-07-28 17:39:21 +03:00
7 changed files with 42 additions and 18 deletions
+6
View File
@@ -2,6 +2,12 @@
Changes
=======
**2017-07-28**
*Released 7.0.1*
- Fix TypeError exception in RegexHandler (PR #751).
- Small documentation fix (PR #749).
**2017-07-25**
*Released 7.0.0*
+1 -1
View File
@@ -60,7 +60,7 @@ author = u'Leandro Toledo'
# The short X.Y version.
version = '7.0' # telegram.__version__[:3]
# The full version, including alpha/beta/rc tags.
release = '7.0.0' # telegram.__version__
release = '7.0.1' # telegram.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
+3 -2
View File
@@ -30,11 +30,12 @@ class CallbackQuery(TelegramObject):
inline mode), the field :attr:`inline_message_id` will be present.
Note:
* In Python `from` is a reserved word, use `from_user` instead.
Exactly one of the fields :attr:`data` or :attr:`game_short_name` will be present.
Attributes:
id (:obj:`str`): Unique identifier for this query.
from (:class:`telegram.User`): Sender.
from_user (:class:`telegram.User`): Sender.
message (:class:`telegram.Message`): Optional. Message with the callback button that
originated the query.
inline_message_id (:obj:`str`): Optional. Identifier of the message sent via the bot in
@@ -46,7 +47,7 @@ class CallbackQuery(TelegramObject):
Args:
id (:obj:`str`): Unique identifier for this query.
from (:class:`telegram.User`): Sender.
from_user (:class:`telegram.User`): Sender.
message (:class:`telegram.Message`, optional): Message with the callback button that
originated the query. Note that message content and message date will not be available
if the message is too old.
+4 -3
View File
@@ -142,11 +142,12 @@ class RegexHandler(Handler):
Returns:
:obj:`bool`
"""
if not isinstance(update, Update) and not update.effective_message:
return False
if any([(self.message_updates and update.message),
(self.edited_updates and update.edited_message),
(self.channel_post_updates and update.channel_post)]) and (
isinstance(update, Update)):
(self.channel_post_updates and update.channel_post)]) and \
update.effective_message.text:
match = re.match(self.pattern, update.effective_message.text)
return bool(match)
return False
+1 -1
View File
@@ -17,4 +17,4 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
__version__ = '7.0.0'
__version__ = '7.0.1'
+2
View File
@@ -53,12 +53,14 @@ class ContactTest(BaseTest, unittest.TestCase):
self.assertEqual(contact.last_name, self.last_name)
self.assertEqual(contact.user_id, self.user_id)
'''Commented out because it caused too many "RetryAfter: Flood control exceeded" errors.
def test_send_contact_with_contact(self):
con = telegram.Contact.de_json(self.json_dict, self._bot)
message = self._bot.send_contact(contact=con, chat_id=self._chat_id)
contact = message.contact
self.assertEqual(contact, con)
'''
def test_contact_to_json(self):
contact = telegram.Contact.de_json(self.json_dict, self._bot)
+25 -11
View File
@@ -34,8 +34,6 @@ from random import randrange
from future.builtins import bytes
from telegram.utils.request import Request as Requester
try:
# python2
from urllib2 import urlopen, Request, HTTPError
@@ -47,12 +45,12 @@ except ImportError:
sys.path.append('.')
from telegram import (Update, Message, TelegramError, User, Chat, Bot,
InlineQuery, CallbackQuery, ShippingQuery, PreCheckoutQuery)
InlineQuery, CallbackQuery)
from telegram.ext import *
from telegram.ext.dispatcher import run_async
from telegram.error import Unauthorized, InvalidToken
from tests.base import BaseTest
from threading import Lock, Thread, current_thread, Semaphore
from threading import Lock, Thread, current_thread
# Enable logging
root = logging.getLogger()
@@ -248,6 +246,23 @@ class UpdaterTest(BaseTest, unittest.TestCase):
sleep(.1)
self.assertTrue(None is self.received_message)
def test_regex_handler_without_message(self):
self._setup_updater('Test3')
d = self.updater.dispatcher
handler = RegexHandler(r'Te.*', self.telegramHandlerTest)
d.add_handler(handler)
# message, no text
m = Message(1, User(1, "testuser"), None, Chat(2, "private"), video="My_vid",
caption="test ")
d.process_update(Update(1, message=m))
self.assertEqual(self.message_count, 0)
# no message
c = InlineQuery(2, User(1, "testuser"), "my_query", offset=15)
d.process_update(Update(2, inline_query=c))
self.assertEqual(self.message_count, 0)
def test_addRemoveTelegramCommandHandler(self):
self._setup_updater('', messages=0)
d = self.updater.dispatcher
@@ -926,7 +941,6 @@ class UpdaterTest(BaseTest, unittest.TestCase):
class MockBot(object):
def __init__(self,
text,
messages=1,
@@ -973,12 +987,12 @@ class MockBot(object):
raise self.bootstrap_err
def get_updates(self,
offset=None,
limit=100,
timeout=0,
network_delay=None,
read_latency=2.,
allowed_updates=None):
offset=None,
limit=100,
timeout=0,
network_delay=None,
read_latency=2.,
allowed_updates=None):
if self.raise_error:
raise TelegramError('Test Error 2')