Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
04f8433
Added vCard field to Contact
mathefreak1 Jul 26, 2018
db46c09
Fixed Test
mathefreak1 Jul 26, 2018
78ddbc2
Fixed Test
mathefreak1 Jul 26, 2018
b1c1a7b
Fixed Test
mathefreak1 Jul 26, 2018
7cad904
Fixed Test
mathefreak1 Jul 26, 2018
33df3a8
Fixed Test
mathefreak1 Jul 26, 2018
2f71df5
add skelleton editmessagemedia
Eldinnie Jul 26, 2018
97d26de
Fixed Test
mathefreak1 Jul 26, 2018
513e018
Fixed Test
mathefreak1 Jul 26, 2018
b9879a6
complete add edit_message_media
Eldinnie Jul 26, 2018
bffafa4
Revert "Fixed Test"
mathefreak1 Jul 27, 2018
273994e
Revert "Fixed Test"
mathefreak1 Jul 27, 2018
1d601c4
Revert "Fixed Test"
mathefreak1 Jul 27, 2018
2721fe7
Revert "Fixed Test"
mathefreak1 Jul 27, 2018
b929f57
Revert "Fixed Test"
mathefreak1 Jul 27, 2018
27f9562
Revert "Added vCard field to Contact"
mathefreak1 Jul 27, 2018
86ff673
Fixed issues from PR #1166
mathefreak1 Jul 27, 2018
d9900e3
Checking if vCard exists is not necessary
mathefreak1 Jul 27, 2018
7024e1d
Fixing backwards compatibility
mathefreak1 Jul 27, 2018
cfab7d0
Added support for telegram passport. Decryption is not implemented yet.
mathefreak1 Jul 29, 2018
f3c4ae6
Fixed tests
mathefreak1 Jul 29, 2018
caa44f8
Fixed tests
mathefreak1 Jul 29, 2018
b26fc88
Fixed tests
mathefreak1 Jul 29, 2018
4ac586d
Fixed tests
mathefreak1 Jul 29, 2018
fee4cd5
Fixed tests
mathefreak1 Jul 29, 2018
80913ef
Fixed tests
mathefreak1 Jul 29, 2018
baeb49a
Fixed tests
mathefreak1 Jul 29, 2018
3961591
Fixed Bug
mathefreak1 Jul 29, 2018
f89aa7b
Remove print
mathefreak1 Jul 29, 2018
a09394b
Add basic passport decryption.
jsmnbom Jul 31, 2018
c717a70
Move passport errors to single file
jsmnbom Aug 10, 2018
2c82a5d
Add better passport credential handling
jsmnbom Aug 10, 2018
a637b42
Add better passport example
jsmnbom Aug 10, 2018
e1234e2
Add additional passport datatypes
jsmnbom Aug 10, 2018
738a4ba
Allow passing private key password to updator
jsmnbom Aug 10, 2018
9092731
Add passport docs
jsmnbom Aug 10, 2018
9f5b33f
Only accept passport messages in passportbot examples
jsmnbom Aug 10, 2018
f7e22a9
Fix some tests
jsmnbom Aug 10, 2018
f9fe0a2
Allow multiple inputfiles in requests
jsmnbom Aug 11, 2018
2d20bbc
Aad thumb to send_* methods + new inputfile tests
jsmnbom Aug 11, 2018
a5a31dc
Animation (#1172)
spontanurlaub Aug 11, 2018
d93b567
Add thumb file
jsmnbom Aug 11, 2018
caf5358
Add proper thumb support to animation
jsmnbom Aug 11, 2018
4205257
Fix tests
jsmnbom Aug 11, 2018
891bc73
Fix thumbs by attach=True + fix docs
jsmnbom Aug 11, 2018
c3e631d
Move inputmedia to single file + fix their thumbs
jsmnbom Aug 11, 2018
551a5ba
Add InputMediaDocument and InputMediaAudio + tests
jsmnbom Aug 11, 2018
760867e
Fix pylint error
jsmnbom Aug 11, 2018
237484e
Fix non ascii '
jsmnbom Aug 11, 2018
555b5cc
Fix mimetype tests - mimetype guessing is funky
jsmnbom Aug 11, 2018
fa914ff
Fix animation test on py2
jsmnbom Aug 11, 2018
16b32a0
Improve coverage
jsmnbom Aug 11, 2018
7340f29
Fix animation test on appveyor
jsmnbom Aug 11, 2018
a8a5d49
Using correct escape function
mathefreak1 Aug 12, 2018
014ba26
Merge remote-tracking branch 'origin/Passport' into Passport
mathefreak1 Aug 12, 2018
755497b
Ignore inputfile in offical test
jsmnbom Aug 12, 2018
6a92fa7
Remove thumb from inputmediaphoto
jsmnbom Aug 12, 2018
4a102d6
Merge branch 'bot-api-4.0' into improve-inputfile
jsmnbom Aug 12, 2018
a34efa5
Merge pull request #1184 from python-telegram-bot/improve-inputfile
jsmnbom Aug 12, 2018
56eb69c
Small doc fixes
jsmnbom Aug 12, 2018
bc4ded8
Merge pull request #1169 from code1mountain/vCard_field
jsmnbom Aug 12, 2018
c1fbed2
Make edit_message_media work with new files
jsmnbom Aug 12, 2018
b3f4de2
Allow parsing of already encrypted stuff into passportdata
jsmnbom Aug 12, 2018
50c9376
Add proper passportdata decryption tests
jsmnbom Aug 12, 2018
14d75a2
Replace non ascii chars with ascii ones
jsmnbom Aug 12, 2018
ef48a09
Remove test_passportdata
jsmnbom Aug 12, 2018
69b03c5
Make passport decryption work on py2
jsmnbom Aug 12, 2018
948c3b3
Add cashtag and phone_number msg entities
jsmnbom Aug 12, 2018
2017e65
Make small doc fixes
jsmnbom Aug 12, 2018
6e5c696
Merge #1170
jsmnbom Aug 12, 2018
e0768bc
Merge remote-tracking branch 'origin/bot-api-4.0' into bot-api-4.0
jsmnbom Aug 12, 2018
8678ae5
Finish merging #1170
jsmnbom Aug 12, 2018
9f2806e
Finish merging #1174
jsmnbom Aug 12, 2018
555afea
Adapt test_official to work with passport stuff
jsmnbom Aug 12, 2018
1d173a0
Add docs for more passport stuff and new inputmedia
jsmnbom Aug 12, 2018
e2ff3d6
Remove passport_auth_url
jsmnbom Aug 19, 2018
2edbadd
Warn instead of raise on decryption errors
jsmnbom Aug 19, 2018
eabde10
Add some tests for decryption warnings
jsmnbom Aug 19, 2018
2a5b7b6
Fix tests on py2
jsmnbom Aug 19, 2018
f4f4645
Fix flake8 being weird
jsmnbom Aug 19, 2018
a04c1cd
small changes
Eldinnie Aug 20, 2018
c421816
Remove no crypto test, as we require it to be installed
jsmnbom Aug 21, 2018
72d2fd5
Remove unused import
jsmnbom Aug 21, 2018
78f08c4
Make passport docstrings better
jsmnbom Aug 21, 2018
2be1c8f
Update CHANGES with v11 stuff + README to reflect bot api 4.0 support
jsmnbom Aug 21, 2018
a464ea5
Add more tests and comments
jsmnbom Aug 23, 2018
9557b72
Don't decrypt passport data automatically
jsmnbom Aug 24, 2018
4e13aee
Handle credentials better
jsmnbom Aug 25, 2018
0681197
Small fixes
jsmnbom Aug 25, 2018
c2d9d61
Update passport tests
jsmnbom Aug 25, 2018
55faee6
Docstring fixes
jsmnbom Aug 25, 2018
d19200a
Passport fixes
jsmnbom Aug 26, 2018
57f12b7
Fix invoice tests now that urllib3 handles request encoding
jsmnbom Aug 27, 2018
367e76e
Fix invoice test
jsmnbom Aug 29, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
=======
Changes
=======

*Released 11.0.0*

Fully support Bot API version 4.0!

Telegram Passport (`#1174`_):

- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to `our telegram passport wiki page`_ for more info
- NOTE: Passport decryption requires new dependency `cryptography`.

Inputfile rework (`#1184`_):

- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send\_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.

Other Bot API 4.0 changes:

- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (`#1170`_)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (`#1166`_)
- Support new message entities: CASHTAG and PHONE_NUMBER. (`#1179`_)
- Cashtag seems to be things like `$USD` and `$GBP`, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (`#1172`_)


.. _`#1174`: https://github.com/python-telegram-bot/python-telegram-bot/pull/1174
.. _`#1184`: https://github.com/python-telegram-bot/python-telegram-bot/pull/1184
.. _`#1170`: https://github.com/python-telegram-bot/python-telegram-bot/pull/1170
.. _`#1166`: https://github.com/python-telegram-bot/python-telegram-bot/pull/1166
.. _`#1179`: https://github.com/python-telegram-bot/python-telegram-bot/pull/1179
.. _`#1172`: https://github.com/python-telegram-bot/python-telegram-bot/pull/1172
.. _`our telegram passport wiki page`: https://git.io/fAvYd

**2018-05-02**
*Released 10.1.0*

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ make the development of bots easy and straightforward. These classes are contain
Telegram API support
====================

All types and methods of the Telegram Bot API 3.6 are supported.
All types and methods of the Telegram Bot API **4.0** are supported.

==========
Installing
Expand Down
6 changes: 6 additions & 0 deletions docs/source/telegram.credentials.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.Credentials
====================

.. autoclass:: telegram.Credentials
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.datacredentials.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.DataCredentials
========================

.. autoclass:: telegram.DataCredentials
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.encryptedcredentials.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.EncryptedCredentials
=============================

.. autoclass:: telegram.EncryptedCredentials
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.encryptedpassportelement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.EncryptedPassportElement
=================================

.. autoclass:: telegram.EncryptedPassportElement
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.filecredentials.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.FileCredentials
========================

.. autoclass:: telegram.FileCredentials
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.iddocumentdata.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.IdDocumentData
=======================

.. autoclass:: telegram.IdDocumentData
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.inputmediaanimation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.InputMediaAnimation
============================

.. autoclass:: telegram.InputMediaAnimation
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.inputmediaaudio.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.InputMediaAudio
========================

.. autoclass:: telegram.InputMediaAudio
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.inputmediadocument.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.InputMediaDocument
===========================

.. autoclass:: telegram.InputMediaDocument
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.passportdata.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.PassportData
=====================

.. autoclass:: telegram.PassportData
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.passportelementerror.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.PassportElementError
=============================

.. autoclass:: telegram.PassportElementError
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.passportelementerrordatafield.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.PassportElementErrorDataField
======================================

.. autoclass:: telegram.PassportElementErrorDataField
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.passportelementerrorfile.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.PassportElementErrorFile
=================================

.. autoclass:: telegram.PassportElementErrorFile
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.passportelementerrorfiles.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.PassportElementErrorFiles
==================================

.. autoclass:: telegram.PassportElementErrorFiles
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.passportelementerrorfrontside.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.PassportElementErrorFrontSide
======================================

.. autoclass:: telegram.PassportElementErrorFrontSide
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.passportelementerrorreverseside.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.PassportElementErrorReverseSide
========================================

.. autoclass:: telegram.PassportElementErrorReverseSide
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.passportfile.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.PassportFile
=====================

.. autoclass:: telegram.PassportFile
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.personaldetails.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.PersonalDetails
========================

.. autoclass:: telegram.PersonalDetails
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.residentialaddress.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.ResidentialAddress
===========================

.. autoclass:: telegram.ResidentialAddress
:members:
:show-inheritance:
29 changes: 28 additions & 1 deletion docs/source/telegram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ telegram package

telegram.ext
telegram.utils
telegram.animation
telegram.audio
telegram.bot
telegram.callbackquery
Expand All @@ -22,6 +23,9 @@ telegram package
telegram.inlinekeyboardmarkup
telegram.inputfile
telegram.inputmedia
telegram.inputmediaanimation
telegram.inputmediaaudio
telegram.inputmediadocument
telegram.inputmediaphoto
telegram.inputmediavideo
telegram.keyboardbutton
Expand Down Expand Up @@ -106,10 +110,33 @@ Games
.. toctree::

telegram.game
telegram.animation
telegram.callbackgame
telegram.gamehighscore

Passport
--------

.. toctree::

telegram.passportelementerror
telegram.passportelementerrorfile
telegram.passportelementerrorreverseside
telegram.passportelementerrorfrontside
telegram.passportelementerrorfiles
telegram.passportelementerrordatafield
telegram.passportelementerrorfile
telegram.credentials
telegram.datacredentials
telegram.securedata
telegram.filecredentials
telegram.iddocumentdata
telegram.personaldetails
telegram.residentialaddress
telegram.passportdata
telegram.passportfile
telegram.encryptedpassportelement
telegram.encryptedcredentials


Module contents
---------------
Expand Down
6 changes: 6 additions & 0 deletions docs/source/telegram.securedata.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
telegram.SecureData
===================

.. autoclass:: telegram.SecureData
:members:
:show-inheritance:
29 changes: 29 additions & 0 deletions examples/passportbot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Telegram passport test!</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!--- Needs file from https://github.com/TelegramMessenger/TGPassportJsSDK downloaded --->
<script src="telegram-passport.js"></script>
<script>
"use strict";

Telegram.Passport.createAuthButton('telegram_passport_auth', {
bot_id: BOT_ID, // YOUR BOT ID
scope: ['id_document', 'phone_number', 'email'], // WHAT DATA YOU WANT TO RECEIVE
public_key: '-----BEGIN PUBLIC KEY----- ...', // YOUR PUBLIC KEY
payload: 'thisisatest', // YOUR BOT WILL RECEIVE THIS DATA WITH THE REQUEST
callback_url: 'https://example.org' // TELEGRAM WILL SEND YOUR USER BACK TO THIS URL
});

</script>
</head>
<body>
<h1>Telegram passport test</h1>

<div id="telegram_passport_auth"></div>
</body>
</html>
99 changes: 99 additions & 0 deletions examples/passportbot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Simple Bot to print/download all incoming passport data
# This program is dedicated to the public domain under the CC0 license.
"""
See https://telegram.org/blog/passport for info about what telegram passport is.

See https://git.io/fAvYd for how to use Telegram Passport properly with python-telegram-bot.

"""
import logging

from telegram.ext import Updater, MessageHandler, Filters

# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.DEBUG)

logger = logging.getLogger(__name__)


def msg(bot, update):
# If we received any passport data
passport_data = update.message.passport_data
if passport_data:
# If our payload doesn't match what we think, this Update did not originate from us
# Ideally you would randomize the payload on the server
if passport_data.decrypted_credentials.payload != 'thisisatest':
return

# Print the decrypted credential data
# For all elements
# Print their decrypted data
# Files will be downloaded to current directory
for data in passport_data.decrypted_data: # This is where the data gets decrypted
if data.type == 'phone_number':
print('Phone: ', data.phone_number)
elif data.type == 'email':
print('Email: ', data.email)
if data.type in ('personal_details', 'passport', 'driver_license', 'identity_card',
'identity_passport', 'address'):
print(data.type, data.data)
if data.type in ('utility_bill', 'bank_statement', 'rental_agreement',
'passport_registration', 'temporary_registration'):
print(data.type, len(data.files), 'files')
for file in data.files:
actual_file = file.get_file()
print(actual_file)
actual_file.download()
if data.type in ('passport', 'driver_license', 'identity_card',
'internal_passport'):
if data.front_side:
file = data.front_side.get_file()
print(data.type, file)
file.download()
if data.type in ('driver_license' and 'identity_card'):
if data.reverse_side:
file = data.reverse_side.get_file()
print(data.type, file)
file.download()
if data.type in ('passport', 'driver_license', 'identity_card',
'internal_passport'):
if data.selfie:
file = data.selfie.get_file()
print(data.type, file)
file.download()


def error(bot, update, error):
"""Log Errors caused by Updates."""
logger.warning('Update "%s" caused error "%s"', update, error)


def main():
"""Start the bot."""
# Create the Updater and pass it your token and private key
updater = Updater("TOKEN", private_key=open('private.key', 'rb').read())

# Get the dispatcher to register handlers
dp = updater.dispatcher

# On messages that include passport data call msg
dp.add_handler(MessageHandler(Filters.passport_data, msg))

# log all errors
dp.add_error_handler(error)

# Start the Bot
updater.start_polling()

# Run the bot until you press Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT. This should be used most of the time, since
# start_polling() is non-blocking and will stop the bot gracefully.
updater.idle()


if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
future>=0.16.0
certifi
cryptography
Loading