2015-09-20 17:28:10 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2020-02-02 22:08:54 +01:00
|
|
|
# Copyright (C) 2015-2020
|
2016-01-05 14:12:03 +01:00
|
|
|
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
2015-09-20 17:28:10 +02:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser Public License
|
|
|
|
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
2016-10-17 00:22:40 +02:00
|
|
|
"""This module contains an object that represents a Telegram File."""
|
2018-09-01 16:58:08 +02:00
|
|
|
from base64 import b64decode
|
2015-09-20 17:28:10 +02:00
|
|
|
from os.path import basename
|
2020-02-06 11:21:21 +01:00
|
|
|
import os
|
2015-09-20 17:28:10 +02:00
|
|
|
|
2017-06-23 00:48:24 +02:00
|
|
|
from future.backports.urllib import parse as urllib_parse
|
|
|
|
|
2015-09-20 17:28:10 +02:00
|
|
|
from telegram import TelegramObject
|
Bot API 4.0 (#1168)
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)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
from telegram.passport.credentials import decrypt
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
class File(TelegramObject):
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
|
|
|
This object represents a file ready to be downloaded. The file can be downloaded with
|
|
|
|
:attr:`download`. It is guaranteed that the link will be valid for at least 1 hour. When the
|
|
|
|
link expires, a new one can be requested by calling getFile.
|
|
|
|
|
|
|
|
Note:
|
|
|
|
Maximum file size to download is 20 MB
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
|
|
Attributes:
|
2017-07-23 22:33:08 +02:00
|
|
|
file_id (:obj:`str`): Unique identifier for this file.
|
2020-03-28 16:37:26 +01:00
|
|
|
file_unique_id (:obj:`str`): Unique identifier for this file, which
|
|
|
|
is supposed to be the same over time and for different bots.
|
|
|
|
Can't be used to download or reuse the file.
|
2017-07-23 22:33:08 +02:00
|
|
|
file_size (:obj:`str`): Optional. File size.
|
|
|
|
file_path (:obj:`str`): Optional. File path. Use :attr:`download` to get the file.
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
|
|
Args:
|
2020-03-28 16:37:26 +01:00
|
|
|
file_id (:obj:`str`): Identifier for this file, which can be used to download
|
|
|
|
or reuse the file.
|
|
|
|
file_unique_id (:obj:`str`): Unique and the same over time and
|
|
|
|
for different bots file identifier.
|
2017-07-23 22:33:08 +02:00
|
|
|
file_size (:obj:`int`, optional): Optional. File size, if known.
|
|
|
|
file_path (:obj:`str`, optional): File path. Use :attr:`download` to get the file.
|
|
|
|
bot (:obj:`telegram.Bot`, optional): Bot to use with shortcut method.
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2017-09-01 08:43:08 +02:00
|
|
|
|
Bot API 4.0 (#1168)
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)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
Note:
|
|
|
|
If you obtain an instance of this class from :attr:`telegram.PassportFile.get_file`,
|
|
|
|
then it will automatically be decrypted as it downloads when you call :attr:`download()`.
|
|
|
|
|
2015-09-20 17:28:10 +02:00
|
|
|
"""
|
|
|
|
|
2020-03-28 16:37:26 +01:00
|
|
|
def __init__(self,
|
|
|
|
file_id,
|
|
|
|
file_unique_id,
|
|
|
|
bot=None,
|
|
|
|
file_size=None,
|
|
|
|
file_path=None,
|
|
|
|
**kwargs):
|
2015-09-20 17:28:10 +02:00
|
|
|
# Required
|
|
|
|
self.file_id = str(file_id)
|
2020-03-28 16:37:26 +01:00
|
|
|
self.file_unique_id = str(file_unique_id)
|
2015-09-20 17:28:10 +02:00
|
|
|
# Optionals
|
2017-01-11 19:41:39 +01:00
|
|
|
self.file_size = file_size
|
2017-06-23 00:48:24 +02:00
|
|
|
self.file_path = file_path
|
2016-09-20 06:36:55 +02:00
|
|
|
self.bot = bot
|
Bot API 4.0 (#1168)
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)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
self._credentials = None
|
2016-09-20 06:36:55 +02:00
|
|
|
|
2020-03-28 16:37:26 +01:00
|
|
|
self._id_attrs = (self.file_unique_id,)
|
2017-05-14 23:29:31 +02:00
|
|
|
|
2017-07-23 21:14:38 +02:00
|
|
|
@classmethod
|
|
|
|
def de_json(cls, data, bot):
|
2015-09-20 17:28:10 +02:00
|
|
|
if not data:
|
|
|
|
return None
|
|
|
|
|
2017-07-23 21:14:38 +02:00
|
|
|
return cls(bot=bot, **data)
|
2015-09-20 17:28:10 +02:00
|
|
|
|
2017-01-06 22:48:34 +01:00
|
|
|
def download(self, custom_path=None, out=None, timeout=None):
|
2015-09-20 17:28:10 +02:00
|
|
|
"""
|
2016-12-18 03:05:00 +01:00
|
|
|
Download this file. By default, the file is saved in the current working directory with its
|
2020-02-06 11:21:21 +01:00
|
|
|
original filename as reported by Telegram. If the file has no filename, it the file ID will
|
|
|
|
be used as filename. If a :attr:`custom_path` is supplied, it will be saved to that path
|
|
|
|
instead. If :attr:`out` is defined, the file contents will be saved to that object using
|
|
|
|
the ``out.write`` method.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
Note:
|
2018-03-01 09:10:04 +01:00
|
|
|
:attr:`custom_path` and :attr:`out` are mutually exclusive.
|
2016-12-18 03:05:00 +01:00
|
|
|
|
2017-01-06 22:48:34 +01:00
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
custom_path (:obj:`str`, optional): Custom path.
|
2018-03-01 09:10:04 +01:00
|
|
|
out (:obj:`io.BufferedWriter`, optional): A file-like object. Must be opened for
|
|
|
|
writing in binary mode, if applicable.
|
2017-07-23 22:33:08 +02:00
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
|
|
|
|
the read timeout from the server (instead of the one specified during creation of
|
|
|
|
the connection pool).
|
2016-12-18 03:05:00 +01:00
|
|
|
|
2018-03-01 09:10:04 +01:00
|
|
|
Returns:
|
|
|
|
:obj:`str` | :obj:`io.BufferedWriter`: The same object as :attr:`out` if specified.
|
|
|
|
Otherwise, returns the filename downloaded to.
|
|
|
|
|
2016-12-18 03:05:00 +01:00
|
|
|
Raises:
|
2018-03-01 09:10:04 +01:00
|
|
|
ValueError: If both :attr:`custom_path` and :attr:`out` are passed.
|
2016-12-18 03:05:00 +01:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2016-12-18 03:05:00 +01:00
|
|
|
if custom_path is not None and out is not None:
|
|
|
|
raise ValueError('custom_path and out are mutually exclusive')
|
|
|
|
|
2017-06-23 00:48:24 +02:00
|
|
|
# Convert any UTF-8 char into a url encoded ASCII string.
|
2018-03-01 09:10:04 +01:00
|
|
|
url = self._get_encoded_url()
|
2015-09-20 17:28:10 +02:00
|
|
|
|
2016-12-18 03:05:00 +01:00
|
|
|
if out:
|
|
|
|
buf = self.bot.request.retrieve(url)
|
Bot API 4.0 (#1168)
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)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
if self._credentials:
|
2018-09-01 16:58:08 +02:00
|
|
|
buf = decrypt(b64decode(self._credentials.secret),
|
|
|
|
b64decode(self._credentials.hash),
|
|
|
|
buf)
|
2016-12-18 03:05:00 +01:00
|
|
|
out.write(buf)
|
2018-03-01 09:10:04 +01:00
|
|
|
return out
|
2015-09-20 17:28:10 +02:00
|
|
|
else:
|
2016-12-18 03:05:00 +01:00
|
|
|
if custom_path:
|
|
|
|
filename = custom_path
|
2020-02-06 11:21:21 +01:00
|
|
|
elif self.file_path:
|
2017-06-23 00:48:24 +02:00
|
|
|
filename = basename(self.file_path)
|
2020-02-06 11:21:21 +01:00
|
|
|
else:
|
|
|
|
filename = os.path.join(os.getcwd(), self.file_id)
|
2015-09-20 17:28:10 +02:00
|
|
|
|
Bot API 4.0 (#1168)
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)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
buf = self.bot.request.retrieve(url, timeout=timeout)
|
|
|
|
if self._credentials:
|
2018-09-01 16:58:08 +02:00
|
|
|
buf = decrypt(b64decode(self._credentials.secret),
|
|
|
|
b64decode(self._credentials.hash),
|
|
|
|
buf)
|
Bot API 4.0 (#1168)
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)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
with open(filename, 'wb') as fobj:
|
|
|
|
fobj.write(buf)
|
2018-03-01 09:10:04 +01:00
|
|
|
return filename
|
|
|
|
|
|
|
|
def _get_encoded_url(self):
|
|
|
|
"""Convert any UTF-8 char in :obj:`File.file_path` into a url encoded ASCII string."""
|
|
|
|
sres = urllib_parse.urlsplit(self.file_path)
|
|
|
|
return urllib_parse.urlunsplit(urllib_parse.SplitResult(
|
|
|
|
sres.scheme, sres.netloc, urllib_parse.quote(sres.path), sres.query, sres.fragment))
|
|
|
|
|
|
|
|
def download_as_bytearray(self, buf=None):
|
|
|
|
"""Download this file and return it as a bytearray.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
buf (:obj:`bytearray`, optional): Extend the given bytearray with the downloaded data.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bytearray`: The same object as :attr:`buf` if it was specified. Otherwise a newly
|
|
|
|
allocated :obj:`bytearray`.
|
|
|
|
|
|
|
|
"""
|
|
|
|
if buf is None:
|
|
|
|
buf = bytearray()
|
|
|
|
|
|
|
|
buf.extend(self.bot.request.retrieve(self._get_encoded_url()))
|
|
|
|
return buf
|
Bot API 4.0 (#1168)
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)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
def set_credentials(self, credentials):
|
|
|
|
self._credentials = credentials
|