mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2026-06-23 01:35:29 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13ab6d43d3 | |||
| 2ba7505eaf | |||
| 5ed06df840 | |||
| eef1238d60 |
@@ -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
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
@@ -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'
|
||||
|
||||
@@ -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
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user