Compare commits

...

9 Commits

Author SHA1 Message Date
Jannes Höke dc27ff41ef bump version to 4.1.2 2016-05-22 13:01:14 +02:00
Jannes Höke 68ec73afb6 use kwargs on messageentity 2016-05-22 12:58:19 +02:00
Rahiel Kasim 0ace0aa016 README: remove "Getting the Code" section, confuses users like #297 2016-05-19 17:06:28 +02:00
Jannes Höke f5847be8ca update file size from 684 to 685 2016-05-17 10:19:00 +02:00
Jannes Höke ba26a8ba5d use command filter instead of regexhandler #292 2016-05-17 07:36:04 +02:00
Jannes Höke d028d4edd0 bump to 4.1.1 2016-05-16 16:05:02 +02:00
Jannes Höke 4d770843cc use non-deprecated methods 2016-05-16 15:02:51 +02:00
Rahiel Kasim 53de38f6c9 README: fix formatting inline code 2016-05-16 01:46:42 +02:00
Leandro Toledo be105a2d4a Update CHANGES.rst 2016-05-15 20:24:09 -03:00
8 changed files with 32 additions and 46 deletions
+20
View File
@@ -1,3 +1,23 @@
**2016-05-22**
*Released 4.1.2*
- Fix ``MessageEntity`` decoding with Bot API 2.1 changes
**2016-05-16**
*Released 4.1.1*
- Fix deprecation warning in ``Dispatcher``
**2016-05-15**
*Released 4.1*
- Implement API changes from May 6, 2016
- Fix bug when ``start_polling`` with ``clean=True``
- Methods now have snake_case equivalent, for example ``telegram.Bot.send_message`` is the same as ``telegram.Bot.sendMessage``
**2016-05-01**
*Released 4.0.3*
+3 -37
View File
@@ -49,8 +49,6 @@ Table of contents
- `Installing`_
- `Getting the code`_
- `Getting started`_
#. `Learning by example`_
@@ -118,37 +116,6 @@ You can install or upgrade python-telegram-bot with:
$ pip install python-telegram-bot --upgrade
===================
_`Getting the code`
===================
The code is hosted at https://github.com/python-telegram-bot/python-telegram-bot
Check out the latest development version anonymously with:
.. code:: shell
$ git clone https://github.com/python-telegram-bot/python-telegram-bot
$ cd python-telegram-bot
Install dependencies:
.. code:: shell
$ pip install -r requirements.txt -r requirements-dev.txt
Run tests:
.. code:: shell
$ make test
To see other available options, run:
.. code:: shell
$ make help
==================
_`Getting started`
==================
@@ -197,7 +164,7 @@ _`API`
Note: Using the ``Bot`` class directly is the 'old' method, we have an easier way to make bots described in the next section. All of this is however still important information, even if you're using the ``telegram.ext`` submodule!
The API is exposed via the ``telegram.Bot`` class. The methods have names as described in the official `Telegram Bot API <https://core.telegram.org/bots/api>`_, but equivalent snake_case methods are available for `PEP8 <https://www.python.org/dev/peps/pep-0008/>`_ enthusiasts. So for example `telegram.Bot.send_message` is the same as `telegram.Bot.sendMessage`.
The API is exposed via the ``telegram.Bot`` class. The methods have names as described in the official `Telegram Bot API <https://core.telegram.org/bots/api>`_, but equivalent snake_case methods are available for `PEP8 <https://www.python.org/dev/peps/pep-0008/>`_ enthusiasts. So for example ``telegram.Bot.send_message`` is the same as ``telegram.Bot.sendMessage``.
To generate an Access Token you have to talk to `BotFather <https://telegram.me/botfather>`_ and follow a few simple steps (described `here <https://core.telegram.org/bots#6-botfather>`_).
@@ -398,15 +365,14 @@ To enable our bot to respond to inline queries, we can add the following (you wi
>>> inline_caps_handler = InlineQueryHandler(inline_caps)
>>> dispatcher.add_handler(inline_caps_handler)
People might try to send commands to the bot that it doesn't understand, so we can use a ``RegexHandler`` to recognize all commands that were not recognized by the previous handlers. **Note:** This handler has to be added last, else it will be triggered before the ``CommandHandlers`` had a chance to look at the update:
People might try to send commands to the bot that it doesn't understand, so we can use a ``MessageHandler`` with a ``command`` filter to recognize all commands that were not recognized by the previous handlers. **Note:** This handler has to be added last, else it will be triggered before the ``CommandHandlers`` had a chance to look at the update:
.. code:: python
>>> def unknown(bot, update):
... bot.sendMessage(chat_id=update.message.chat_id, text="Sorry, I didn't understand that command.")
...
>>> from telegram.ext import RegexHandler
>>> unknown_handler = RegexHandler(r'/.*', unknown)
>>> unknown_handler = MessageHandler([Filters.command], unknown)
>>> dispatcher.add_handler(unknown_handler)
If you're done playing around, stop the bot with this:
+1 -1
View File
@@ -60,7 +60,7 @@ author = u'Leandro Toledo'
# The short X.Y version.
version = '4.1'
# The full version, including alpha/beta/rc tags.
release = '4.1'
release = '4.1.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
+1 -1
View File
@@ -24,7 +24,7 @@ def requirements():
setup(name='python-telegram-bot',
version='4.1',
version='4.1.2',
author='Leandro Toledo',
author_email='devs@python-telegram-bot.org',
license='LGPLv3',
+1 -1
View File
@@ -81,7 +81,7 @@ from .update import Update
from .bot import Bot
__author__ = 'devs@python-telegram-bot.org'
__version__ = '4.1'
__version__ = '4.1.2'
__all__ = ['Audio', 'Bot', 'Chat', 'ChatAction', 'ChosenInlineResult', 'CallbackQuery', 'Contact',
'Document', 'Emoji', 'File', 'ForceReply', 'InlineKeyboardButton',
'InlineKeyboardMarkup', 'InlineQuery', 'InlineQueryResult', 'InlineQueryResult',
+2 -2
View File
@@ -176,8 +176,8 @@ class Dispatcher(object):
for group in self.groups:
for handler in self.handlers[group]:
try:
if handler.checkUpdate(update):
handler.handleUpdate(update, self)
if handler.check_update(update):
handler.handle_update(update, self)
break
# Dispatch any errors
except TelegramError as te:
+2 -2
View File
@@ -33,13 +33,13 @@ class MessageEntity(TelegramObject):
url (Optional[str]):
"""
def __init__(self, type, offset, length, url=None):
def __init__(self, type, offset, length, **kwargs):
# Required
self.type = type
self.offset = offset
self.length = length
# Optionals
self.url = url
self.url = kwargs.get('url')
@staticmethod
def de_json(data):
+2 -2
View File
@@ -145,7 +145,7 @@ class BotTest(BaseTest, unittest.TestCase):
chat_id=self._chat_id)
self.assertTrue(self.is_json(message.to_json()))
self.assertEqual(message.photo[0].file_size, 684)
self.assertEqual(message.photo[0].file_size, 685)
@flaky(3, 1)
@timeout(10)
@@ -155,7 +155,7 @@ class BotTest(BaseTest, unittest.TestCase):
chat_id=self._chat_id)
self.assertTrue(self.is_json(message.to_json()))
self.assertEqual(message.photo[0].file_size, 684)
self.assertEqual(message.photo[0].file_size, 685)
@flaky(3, 1)
@timeout(10)