mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2026-06-20 08:05:27 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dc27ff41ef | |||
| 68ec73afb6 | |||
| 0ace0aa016 | |||
| f5847be8ca | |||
| ba26a8ba5d | |||
| d028d4edd0 | |||
| 4d770843cc | |||
| 53de38f6c9 | |||
| be105a2d4a |
+20
@@ -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
@@ -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
@@ -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.
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user