Skip to content

Commit f735a37

Browse files
authored
Merge from master and resolve conflicts
Merge from master and resolve conflicts
2 parents f314915 + e9d08c6 commit f735a37

30 files changed

+246
-131
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "telegram/vendor/urllib3"]
2-
path = telegram/vendor/urllib3
2+
path = telegram/vendor/ptb_urllib3
33
url = https://github.com/python-telegram-bot/urllib3.git
44
branch = ptb

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ install:
1818
script:
1919
- nosetests -v --with-flaky --no-flaky-report --with-coverage --cover-package=telegram/ tests
2020
- if [[ $TRAVIS_PYTHON_VERSION == 3.5 ]]; then pre-commit run --all-files; fi
21+
- python ./setup.py bdist_dumb
2122
after_success:
2223
coveralls

CHANGES.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
Changes
33
=======
44

5-
**2017-05-21**
5+
**2017-05-29**
6+
7+
*Released 6.0.2*
8+
9+
- Avoid confusion with user's ``urllib3`` by renaming vendored ``urllib3`` to ``ptb_urllib3``
10+
11+
**2017-05-19**
612

713
*Released 6.0.1*
814

@@ -80,6 +86,7 @@ Changes
8086

8187
- Rework ``JobQueue``
8288
- Introduce ``ConversationHandler``
89+
- Introduce ``telegram.constants`` - https://github.com/python-telegram-bot/python-telegram-bot/pull/342
8390

8491
**2016-07-12**
8592

README.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ make the development of bots easy and straightforward. These classes are contain
8484
Telegram API support
8585
====================
8686

87-
As of **4. Dec 2016**, all types and methods of the Telegram Bot API are supported.
87+
As of **21. May 2017**, all types and methods of the Telegram Bot API 2.3.1 are supported. Additionally, the ``deleteMessage`` API function and the field ``User.language_code`` are supported.
88+
89+
Also, version 6.1 beta 0 is available, offering full but experimental Bot API 3.0 coverage:
90+
91+
.. code:: shell
92+
93+
$ pip install python-telegram-bot==6.1b0
8894
8995
==========
9096
Installing

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# The short X.Y version.
6262
version = '6.0' # telegram.__version__[:3]
6363
# The full version, including alpha/beta/rc tags.
64-
release = '6.0.1' # telegram.__version__
64+
release = '6.0.2' # telegram.__version__
6565

6666
# The language for content autogenerated by Sphinx. Refer to documentation
6767
# for a list of supported languages.

setup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ def requirements():
1818

1919

2020
packages = find_packages(exclude=['tests*'])
21-
packages.extend(['telegram.vendor.urllib3.urllib3',
22-
'telegram.vendor.urllib3.urllib3.packages', 'telegram.vendor.urllib3.urllib3.packages.ssl_match_hostname',
23-
'telegram.vendor.urllib3.urllib3.packages.backports', 'telegram.vendor.urllib3.urllib3.contrib',
24-
'telegram.vendor.urllib3.urllib3.util',
25-
])
2621

2722
with codecs.open('README.rst', 'r', 'utf-8') as fd:
2823
fn = os.path.join('telegram', 'version.py')

telegram/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import sys
2323
import os
2424

25-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'vendor', 'urllib3'))
26-
2725
from .base import TelegramObject
2826
from .user import User
2927
from .chat import Chat

telegram/bot.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,9 @@ def send_video_note(self,
687687
688688
Args:
689689
chat_id (int|str): Unique identifier for the message recipient - Chat id.
690-
voice: Video note to send. Pass a file_id as String to send a video note that exists
691-
on the Telegram servers (recommended) or upload a new video. Sending video notes
692-
by a URL is currently unsupported
690+
video_note (InputFile|str): Video note to send. Pass a file_id as String to send a
691+
video note that exists on the Telegram servers (recommended) or upload a new video.
692+
Sending video notes by a URL is currently unsupported
693693
duration (Optional[int]): Duration of sent audio in seconds.
694694
length (Optional[int]): Video width and height
695695
disable_notification (Optional[bool]): Sends the message silently. iOS users will not
@@ -713,9 +713,9 @@ def send_video_note(self,
713713

714714
data = {'chat_id': chat_id, 'video_note': video_note}
715715

716-
if duration:
716+
if duration is not None:
717717
data['duration'] = duration
718-
if length:
718+
if length is not None:
719719
data['length'] = length
720720

721721
return self._message_wrapper(
@@ -1906,23 +1906,23 @@ def send_invoice(self,
19061906
'prices': [p.to_dict() for p in prices]
19071907
}
19081908

1909-
if photo_url:
1909+
if photo_url is not None:
19101910
data['photo_url'] = photo_url
1911-
if photo_size:
1911+
if photo_size is not None:
19121912
data['photo_size'] = photo_size
1913-
if photo_width:
1913+
if photo_width is not None:
19141914
data['photo_width'] = photo_width
1915-
if photo_height:
1915+
if photo_height is not None:
19161916
data['photo_height'] = photo_height
1917-
if need_name:
1917+
if need_name is not None:
19181918
data['need_name'] = need_name
1919-
if need_phone_number:
1919+
if need_phone_number is not None:
19201920
data['need_phone_number'] = need_phone_number
19211921
if need_email:
19221922
data['need_email'] = need_email
1923-
if need_shipping_address:
1923+
if need_shipping_address is not None:
19241924
data['need_shipping_address'] = need_shipping_address
1925-
if is_flexible:
1925+
if is_flexible is not None:
19261926
data['is_flexible'] = is_flexible
19271927

19281928
return url, data
@@ -1944,12 +1944,12 @@ def answer_shipping_query(self,
19441944
ok (bool): Specify True if delivery to the specified address is possible and False if
19451945
there are any problems (for example, if delivery to the specified address
19461946
is not possible)
1947-
shipping_options (List[:class:`telegram.ShippingOption`]): Required if ok is True. A
1948-
list of available shipping options.
1949-
error_message (str): Required if ok is False. Error message in human readable form
1950-
that explains why it is impossible to complete the order (e.g. "Sorry, delivery
1951-
to your desired address is unavailable'). Telegram will display this message
1952-
to the user.
1947+
shipping_options (Optional[List[:class:`telegram.ShippingOption`]]): Required if ok is
1948+
True. A list of available shipping options.
1949+
error_message (Optional[str]): Required if ok is False. Error message in human readable
1950+
form that explains why it is impossible to complete the order (e.g. "Sorry,
1951+
delivery to your desired address is unavailable'). Telegram will display this
1952+
message to the user.
19531953
**kwargs (dict): Arbitrary keyword arguments.
19541954
19551955
Returns:
@@ -1976,7 +1976,7 @@ def answer_shipping_query(self,
19761976

19771977
if ok is True:
19781978
data['shipping_options'] = shipping_options
1979-
if error_message:
1979+
if error_message is not None:
19801980
data['error_message'] = error_message
19811981

19821982
result = self._request.post(url_, data, timeout=timeout)
@@ -1994,11 +1994,11 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok,
19941994
pre_checkout_query_id (str): Unique identifier for the query to be answered
19951995
ok (bool): Specify True if everything is alright (goods are available, etc.) and the
19961996
bot is ready to proceed with the order. Use False if there are any problems.
1997-
error_message (str): Required if ok is False. Error message in human readable form that
1998-
explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody
1999-
just bought the last of our amazing black T-shirts while you were busy filling out
2000-
your payment details. Please choose a different color or garment!"). Telegram will
2001-
display this message to the user.
1997+
error_message (Optional[str]): Required if ok is False. Error message in human readable
1998+
form that explains the reason for failure to proceed with the checkout (e.g.
1999+
"Sorry, somebody just bought the last of our amazing black T-shirts while you were
2000+
busy filling out your payment details. Please choose a different color or
2001+
garment!"). Telegram will display this message to the user.
20022002
**kwargs (dict): Arbitrary keyword arguments.
20032003
20042004
Returns:
@@ -2020,7 +2020,7 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok,
20202020

20212021
data = {'pre_checkout_query_id': pre_checkout_query_id, 'ok': ok}
20222022

2023-
if error_message:
2023+
if error_message is not None:
20242024
data['error_message'] = error_message
20252025

20262026
result = self._request.post(url_, data, timeout=timeout)

telegram/ext/filters.py

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,68 @@ def filter(self, message):
214214

215215
class _StatusUpdate(BaseFilter):
216216

217+
class _NewChatMembers(BaseFilter):
218+
219+
def filter(self, message):
220+
return bool(message.new_chat_members)
221+
222+
new_chat_members = _NewChatMembers()
223+
224+
class _LeftChatMember(BaseFilter):
225+
226+
def filter(self, message):
227+
return bool(message.left_chat_member)
228+
229+
left_chat_member = _LeftChatMember()
230+
231+
class _NewChatTitle(BaseFilter):
232+
233+
def filter(self, message):
234+
return bool(message.new_chat_title)
235+
236+
new_chat_title = _NewChatTitle()
237+
238+
class _NewChatPhoto(BaseFilter):
239+
240+
def filter(self, message):
241+
return bool(message.new_chat_photo)
242+
243+
new_chat_photo = _NewChatPhoto()
244+
245+
class _DeleteChatPhoto(BaseFilter):
246+
247+
def filter(self, message):
248+
return bool(message.delete_chat_photo)
249+
250+
delete_chat_photo = _DeleteChatPhoto()
251+
252+
class _ChatCreated(BaseFilter):
253+
254+
def filter(self, message):
255+
return bool(message.group_chat_created or message.supergroup_chat_created or
256+
message.channel_chat_created)
257+
258+
chat_created = _ChatCreated()
259+
260+
class _Migrate(BaseFilter):
261+
262+
def filter(self, message):
263+
return bool(message.migrate_from_chat_id or message.migrate_to_chat_id)
264+
265+
migrate = _Migrate()
266+
267+
class _PinnedMessage(BaseFilter):
268+
269+
def filter(self, message):
270+
return bool(message.pinned_message)
271+
272+
pinned_message = _PinnedMessage()
273+
217274
def filter(self, message):
218-
return bool(message.new_chat_member or message.left_chat_member
219-
or message.new_chat_title or message.new_chat_photo
220-
or message.delete_chat_photo or message.group_chat_created
221-
or message.supergroup_chat_created or message.channel_chat_created
222-
or message.migrate_to_chat_id or message.migrate_from_chat_id
223-
or message.pinned_message)
275+
return bool(self.new_chat_members(message) or self.left_chat_member(message) or
276+
self.new_chat_title(message) or self.new_chat_photo(message) or
277+
self.delete_chat_photo(message) or self.chat_created(message) or
278+
self.migrate(message) or self.pinned_message(message))
224279

225280
status_update = _StatusUpdate()
226281

@@ -276,6 +331,20 @@ def filter(self, message):
276331

277332
group = _Group()
278333

334+
class _Invoice(BaseFilter):
335+
336+
def filter(self, message):
337+
return bool(message.invoice)
338+
339+
invoice = _Invoice()
340+
341+
class _SuccessfulPayment(BaseFilter):
342+
343+
def filter(self, message):
344+
return bool(message.successful_payment)
345+
346+
successful_payment = _SuccessfulPayment()
347+
279348
class language(BaseFilter):
280349
"""
281350
Filters messages to only allow those which are from users with a certain language code.

telegram/inlinequeryresultgif.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ def __init__(self,
6161
thumb_url,
6262
gif_width=None,
6363
gif_height=None,
64-
gif_duration=None,
6564
title=None,
6665
caption=None,
6766
reply_markup=None,
6867
input_message_content=None,
68+
gif_duration=None,
6969
**kwargs):
7070

7171
# Required

0 commit comments

Comments
 (0)