2015-07-07 21:50:36 +02:00
|
|
|
|
#!/usr/bin/env python
|
2017-07-01 17:08:45 +02:00
|
|
|
|
# -*- coding: utf-8 -*-
|
2015-08-28 17:19:30 +02:00
|
|
|
|
# pylint: disable=E0611,E0213,E1102,C0103,E1101,W0613,R0913,R0904
|
2015-08-11 21:58:17 +02:00
|
|
|
|
#
|
|
|
|
|
# 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-08-11 21:58:17 +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 Bot."""
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2016-04-24 15:06:59 +02:00
|
|
|
|
import functools
|
2020-02-06 11:22:56 +01:00
|
|
|
|
import inspect
|
|
|
|
|
from decorator import decorate
|
2019-02-13 11:37:13 +01: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
|
|
|
|
try:
|
|
|
|
|
import ujson as json
|
|
|
|
|
except ImportError:
|
|
|
|
|
import json
|
2016-05-24 01:22:31 +02:00
|
|
|
|
import logging
|
2016-12-11 22:44:52 +01:00
|
|
|
|
import warnings
|
2017-07-01 17:08:45 +02:00
|
|
|
|
from datetime import datetime
|
2016-04-27 00:28:21 +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
|
|
|
|
from cryptography.hazmat.backends import default_backend
|
|
|
|
|
from cryptography.hazmat.primitives import serialization
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
2016-05-24 01:22:31 +02:00
|
|
|
|
from telegram import (User, Message, Update, Chat, ChatMember, UserProfilePhotos, File,
|
2017-07-25 00:35:22 +02:00
|
|
|
|
ReplyMarkup, TelegramObject, WebhookInfo, GameHighScore, StickerSet,
|
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
|
|
|
|
PhotoSize, Audio, Document, Sticker, Video, Animation, Voice, VideoNote,
|
2020-04-10 19:22:45 +02:00
|
|
|
|
Location, Venue, Contact, InputFile, Poll, BotCommand)
|
2016-10-17 00:09:44 +02:00
|
|
|
|
from telegram.error import InvalidToken, TelegramError
|
2020-02-06 11:22:56 +01:00
|
|
|
|
from telegram.utils.helpers import to_timestamp, DEFAULT_NONE
|
2016-09-06 15:38:07 +02:00
|
|
|
|
from telegram.utils.request import Request
|
2015-08-09 14:41:58 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
|
2017-06-18 12:14:24 +02:00
|
|
|
|
def info(func):
|
|
|
|
|
@functools.wraps(func)
|
|
|
|
|
def decorator(self, *args, **kwargs):
|
|
|
|
|
if not self.bot:
|
|
|
|
|
self.get_me()
|
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
if self._commands is None:
|
|
|
|
|
self.get_my_commands()
|
|
|
|
|
|
2017-06-18 12:14:24 +02:00
|
|
|
|
result = func(self, *args, **kwargs)
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
return decorator
|
|
|
|
|
|
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
def log(func, *args, **kwargs):
|
2017-06-18 12:14:24 +02:00
|
|
|
|
logger = logging.getLogger(func.__module__)
|
|
|
|
|
|
|
|
|
|
def decorator(self, *args, **kwargs):
|
|
|
|
|
logger.debug('Entering: %s', func.__name__)
|
2020-02-06 11:22:56 +01:00
|
|
|
|
result = func(*args, **kwargs)
|
2017-06-18 12:14:24 +02:00
|
|
|
|
logger.debug(result)
|
|
|
|
|
logger.debug('Exiting: %s', func.__name__)
|
|
|
|
|
return result
|
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
return decorate(func, decorator)
|
2017-06-18 12:14:24 +02:00
|
|
|
|
|
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
class Bot(TelegramObject):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""This object represents a Telegram Bot.
|
2015-08-28 17:19:30 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
token (:obj:`str`): Bot's unique authentication.
|
|
|
|
|
base_url (:obj:`str`, optional): Telegram Bot API service URL.
|
|
|
|
|
base_file_url (:obj:`str`, optional): Telegram Bot API file URL.
|
2017-09-07 21:55:06 +02:00
|
|
|
|
request (:obj:`telegram.utils.request.Request`, optional): Pre initialized
|
2017-10-11 23:39:09 +02:00
|
|
|
|
:obj:`telegram.utils.request.Request`.
|
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
|
|
|
|
private_key (:obj:`bytes`, optional): Private key for decryption of telegram passport data.
|
|
|
|
|
private_key_password (:obj:`bytes`, optional): Password for above private key.
|
2020-02-06 11:22:56 +01:00
|
|
|
|
defaults (:class:`telegram.ext.Defaults`, optional): An object containing default values to
|
|
|
|
|
be used if not set explicitly in the bot methods.
|
2017-09-01 08:43:08 +02:00
|
|
|
|
|
2015-08-28 17:19:30 +02:00
|
|
|
|
"""
|
2015-07-09 18:19:58 +02:00
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
def __new__(cls, *args, **kwargs):
|
|
|
|
|
# Get default values from kwargs
|
|
|
|
|
defaults = kwargs.get('defaults')
|
|
|
|
|
|
|
|
|
|
# Make an instance of the class
|
2020-06-15 18:20:51 +02:00
|
|
|
|
instance = super().__new__(cls)
|
2020-02-06 11:22:56 +01:00
|
|
|
|
|
|
|
|
|
if not defaults:
|
|
|
|
|
return instance
|
|
|
|
|
|
|
|
|
|
# For each method ...
|
|
|
|
|
for method_name, method in inspect.getmembers(instance, predicate=inspect.ismethod):
|
|
|
|
|
# ... get kwargs
|
|
|
|
|
argspec = inspect.getargspec(method)
|
|
|
|
|
kwarg_names = argspec.args[-len(argspec.defaults or []):]
|
|
|
|
|
# ... check if Defaults has a attribute that matches the kwarg name
|
|
|
|
|
needs_default = [
|
|
|
|
|
kwarg_name for kwarg_name in kwarg_names if hasattr(defaults, kwarg_name)
|
|
|
|
|
]
|
|
|
|
|
# ... make a dict of kwarg name and the default value
|
|
|
|
|
default_kwargs = {
|
|
|
|
|
kwarg_name: getattr(defaults, kwarg_name) for kwarg_name in needs_default if (
|
|
|
|
|
getattr(defaults, kwarg_name) is not DEFAULT_NONE
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
# ... apply the defaults using a partial
|
|
|
|
|
if default_kwargs:
|
|
|
|
|
setattr(instance, method_name, functools.partial(method, **default_kwargs))
|
|
|
|
|
|
|
|
|
|
return instance
|
|
|
|
|
|
|
|
|
|
def __init__(self,
|
|
|
|
|
token,
|
|
|
|
|
base_url=None,
|
|
|
|
|
base_file_url=None,
|
|
|
|
|
request=None,
|
|
|
|
|
private_key=None,
|
|
|
|
|
private_key_password=None,
|
|
|
|
|
defaults=None):
|
2016-05-26 21:09:14 +02:00
|
|
|
|
self.token = self._validate_token(token)
|
2015-07-08 22:23:18 +02:00
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
# Gather default
|
|
|
|
|
self.defaults = defaults
|
|
|
|
|
|
2016-10-13 21:52:53 +02:00
|
|
|
|
if base_url is None:
|
|
|
|
|
base_url = 'https://api.telegram.org/bot'
|
2015-07-08 22:23:18 +02:00
|
|
|
|
|
2016-10-13 21:52:53 +02:00
|
|
|
|
if base_file_url is None:
|
|
|
|
|
base_file_url = 'https://api.telegram.org/file/bot'
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
2016-10-13 21:52:53 +02:00
|
|
|
|
self.base_url = str(base_url) + str(self.token)
|
|
|
|
|
self.base_file_url = str(base_file_url) + str(self.token)
|
2015-08-14 21:25:27 +02:00
|
|
|
|
self.bot = None
|
2020-04-10 19:22:45 +02:00
|
|
|
|
self._commands = None
|
2016-09-06 15:38:07 +02:00
|
|
|
|
self._request = request or Request()
|
2015-08-28 17:19:30 +02:00
|
|
|
|
self.logger = logging.getLogger(__name__)
|
2015-07-20 13:36: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
|
|
|
|
if private_key:
|
|
|
|
|
self.private_key = serialization.load_pem_private_key(private_key,
|
|
|
|
|
password=private_key_password,
|
|
|
|
|
backend=default_backend())
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
def _message(self, url, data, reply_to_message_id=None, disable_notification=None,
|
|
|
|
|
reply_markup=None, timeout=None, **kwargs):
|
|
|
|
|
if reply_to_message_id is not None:
|
|
|
|
|
data['reply_to_message_id'] = reply_to_message_id
|
|
|
|
|
|
|
|
|
|
if disable_notification is not None:
|
|
|
|
|
data['disable_notification'] = disable_notification
|
|
|
|
|
|
|
|
|
|
if reply_markup is not None:
|
|
|
|
|
if isinstance(reply_markup, ReplyMarkup):
|
2020-04-11 09:44:40 +02:00
|
|
|
|
# We need to_json() instead of to_dict() here, because reply_markups may be
|
|
|
|
|
# attached to media messages, which aren't json dumped by utils.request
|
|
|
|
|
data['reply_markup'] = reply_markup.to_json()
|
2019-02-13 11:37:13 +01:00
|
|
|
|
else:
|
|
|
|
|
data['reply_markup'] = reply_markup
|
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
if data.get('media') and (data['media'].parse_mode == DEFAULT_NONE):
|
|
|
|
|
if self.defaults:
|
|
|
|
|
data['media'].parse_mode = self.defaults.parse_mode
|
|
|
|
|
else:
|
|
|
|
|
data['media'].parse_mode = None
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
if result is True:
|
|
|
|
|
return result
|
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
if self.defaults:
|
|
|
|
|
result['default_quote'] = self.defaults.quote
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return Message.de_json(result, self)
|
|
|
|
|
|
2016-09-06 15:38:07 +02:00
|
|
|
|
@property
|
|
|
|
|
def request(self):
|
|
|
|
|
return self._request
|
|
|
|
|
|
2016-05-26 21:09:14 +02:00
|
|
|
|
@staticmethod
|
|
|
|
|
def _validate_token(token):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""A very basic validation on token."""
|
2016-05-26 21:09:14 +02:00
|
|
|
|
if any(x.isspace() for x in token):
|
|
|
|
|
raise InvalidToken()
|
|
|
|
|
|
|
|
|
|
left, sep, _right = token.partition(':')
|
|
|
|
|
if (not sep) or (not left.isdigit()) or (len(left) < 3):
|
|
|
|
|
raise InvalidToken()
|
|
|
|
|
|
|
|
|
|
return token
|
|
|
|
|
|
2015-08-14 21:25:27 +02:00
|
|
|
|
@property
|
|
|
|
|
@info
|
|
|
|
|
def id(self):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
""":obj:`int`: Unique identifier for this bot."""
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2015-08-14 21:25:27 +02:00
|
|
|
|
return self.bot.id
|
2015-07-08 22:23:18 +02:00
|
|
|
|
|
2015-08-14 21:25:27 +02:00
|
|
|
|
@property
|
|
|
|
|
@info
|
|
|
|
|
def first_name(self):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
""":obj:`str`: Bot's first name."""
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2015-08-14 21:25:27 +02:00
|
|
|
|
return self.bot.first_name
|
2015-07-08 22:23:18 +02:00
|
|
|
|
|
2015-08-14 21:25:27 +02:00
|
|
|
|
@property
|
|
|
|
|
@info
|
|
|
|
|
def last_name(self):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
""":obj:`str`: Optional. Bot's last name."""
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2015-08-14 21:25:27 +02:00
|
|
|
|
return self.bot.last_name
|
2015-07-20 13:59:41 +02:00
|
|
|
|
|
2015-08-14 21:25:27 +02:00
|
|
|
|
@property
|
|
|
|
|
@info
|
|
|
|
|
def username(self):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
""":obj:`str`: Bot's username."""
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2015-08-14 21:25:27 +02:00
|
|
|
|
return self.bot.username
|
2015-07-08 22:23:18 +02:00
|
|
|
|
|
2020-03-09 22:17:05 +01:00
|
|
|
|
@property
|
|
|
|
|
@info
|
|
|
|
|
def link(self):
|
|
|
|
|
""":obj:`str`: Convenience property. Returns the t.me link of the bot."""
|
|
|
|
|
|
|
|
|
|
return "https://t.me/{}".format(self.username)
|
|
|
|
|
|
2020-03-29 09:52:30 +02:00
|
|
|
|
@property
|
|
|
|
|
@info
|
|
|
|
|
def can_join_groups(self):
|
|
|
|
|
""":obj:`str`: Bot's can_join_groups attribute."""
|
|
|
|
|
|
|
|
|
|
return self.bot.can_join_groups
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
@info
|
|
|
|
|
def can_read_all_group_messages(self):
|
|
|
|
|
""":obj:`str`: Bot's can_read_all_group_messages attribute."""
|
|
|
|
|
|
|
|
|
|
return self.bot.can_read_all_group_messages
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
@info
|
|
|
|
|
def supports_inline_queries(self):
|
|
|
|
|
""":obj:`str`: Bot's supports_inline_queries attribute."""
|
|
|
|
|
|
|
|
|
|
return self.bot.supports_inline_queries
|
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
@property
|
|
|
|
|
@info
|
|
|
|
|
def commands(self):
|
|
|
|
|
"""List[:class:`BotCommand`]: Bot's commands."""
|
|
|
|
|
|
|
|
|
|
return self._commands
|
|
|
|
|
|
2015-07-08 22:23:18 +02:00
|
|
|
|
@property
|
2015-07-15 15:05:31 +02:00
|
|
|
|
def name(self):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
""":obj:`str`: Bot's @username."""
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
return '@{}'.format(self.username)
|
2015-07-08 22:23:18 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_me(self, timeout=None, **kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""A simple method for testing your bot's auth token. Requires no parameters.
|
2015-07-20 12:53:58 +02:00
|
|
|
|
|
2017-01-06 22:48:34 +01:00
|
|
|
|
Args:
|
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).
|
2017-01-06 22:48:34 +01:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
Returns:
|
2016-10-17 00:11:20 +02:00
|
|
|
|
:class:`telegram.User`: A :class:`telegram.User` instance representing that bot if the
|
2017-07-23 22:33:08 +02:00
|
|
|
|
credentials are valid, :obj:`None` otherwise.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getMe'.format(self.base_url)
|
2015-07-20 12:53:58 +02:00
|
|
|
|
|
2017-01-06 22:48:34 +01:00
|
|
|
|
result = self._request.get(url, timeout=timeout)
|
2015-07-20 12:53:58 +02:00
|
|
|
|
|
2016-09-20 06:36:55 +02:00
|
|
|
|
self.bot = User.de_json(result, self)
|
2015-08-14 21:30:30 +02:00
|
|
|
|
|
2015-08-14 21:25:27 +02:00
|
|
|
|
return self.bot
|
2015-07-20 12:53:58 +02:00
|
|
|
|
|
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_message(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
text,
|
|
|
|
|
parse_mode=None,
|
|
|
|
|
disable_web_page_preview=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to send text messages.
|
2015-07-08 00:54:00 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2020-04-10 20:05:01 +02:00
|
|
|
|
text (:obj:`str`): Text of the message to be sent. Max 4096 characters after entities
|
|
|
|
|
parsing. Also found as :attr:`telegram.constants.MAX_MESSAGE_LENGTH`.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
parse_mode (:obj:`str`): Send Markdown or HTML, if you want Telegram apps to show bold,
|
|
|
|
|
italic, fixed-width text or inline URLs in your bot's message. See the constants in
|
|
|
|
|
:class:`telegram.ParseMode` for the available modes.
|
|
|
|
|
disable_web_page_preview (:obj:`bool`, optional): Disables link previews for links in
|
|
|
|
|
this message.
|
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
2016-04-19 14:04:25 +02:00
|
|
|
|
receive a notification with no sound.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
|
|
|
|
|
A JSON-serialized object for an inline keyboard, custom reply keyboard,
|
|
|
|
|
instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 21:58:18 +02:00
|
|
|
|
|
2015-07-08 00:54:00 +02:00
|
|
|
|
Returns:
|
2016-10-17 00:11:20 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent message is returned.
|
2016-04-19 14:04:25 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendMessage'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'text': text}
|
2015-07-12 00:01:02 +02:00
|
|
|
|
|
2015-09-10 19:15:20 +02:00
|
|
|
|
if parse_mode:
|
|
|
|
|
data['parse_mode'] = parse_mode
|
2015-07-07 21:50:36 +02:00
|
|
|
|
if disable_web_page_preview:
|
|
|
|
|
data['disable_web_page_preview'] = disable_web_page_preview
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
timeout=timeout, **kwargs)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2017-05-12 17:40:57 +02:00
|
|
|
|
@log
|
2017-06-18 12:14:24 +02:00
|
|
|
|
def delete_message(self, chat_id, message_id, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
2019-08-23 21:20:41 +02:00
|
|
|
|
Use this method to delete a message, including service messages, with the following
|
|
|
|
|
limitations:
|
|
|
|
|
|
|
|
|
|
- A message can only be deleted if it was sent less than 48 hours ago.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
- A dice message in a private chat can only be deleted if it was sent more than 24
|
|
|
|
|
hours ago.
|
2019-08-23 21:20:41 +02:00
|
|
|
|
- Bots can delete outgoing messages in private chats, groups, and supergroups.
|
|
|
|
|
- Bots can delete incoming messages in private chats.
|
|
|
|
|
- Bots granted can_post_messages permissions can delete outgoing messages in channels.
|
|
|
|
|
- If the bot is an administrator of a group, it can delete any message there.
|
|
|
|
|
- If the bot has can_delete_messages permission in a supergroup or a channel, it can
|
|
|
|
|
delete any message there.
|
2017-05-12 17:40:57 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
|
|
|
|
message_id (:obj:`int`): Identifier of the message to delete.
|
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
|
2020-04-10 20:05:01 +02:00
|
|
|
|
the read timeout from the server (instead of the one specified during creation of
|
|
|
|
|
the connection pool).
|
2017-07-23 22:33:08 +02:00
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2017-05-12 17:40:57 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-05-12 17:40:57 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/deleteMessage'.format(self.base_url)
|
2017-05-12 17:40:57 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'message_id': message_id}
|
|
|
|
|
|
2017-06-18 12:14:24 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
2017-05-12 17:40:57 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def forward_message(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
from_chat_id,
|
|
|
|
|
message_id,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to forward messages of any kind.
|
2015-07-08 00:54:00 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
|
|
|
|
from_chat_id (:obj:`int` | :obj:`str`): Unique identifier for the chat where the
|
|
|
|
|
original message was sent (or channel username in the format @channelusername).
|
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
message_id (:obj:`int`): Message identifier in the chat specified in from_chat_id.
|
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
|
2020-04-10 20:05:01 +02:00
|
|
|
|
the read timeout from the server (instead of the one specified during creation of
|
|
|
|
|
the connection pool).
|
2017-07-23 22:33:08 +02:00
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 21:58:18 +02:00
|
|
|
|
|
2015-07-08 00:54:00 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/forwardMessage'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
|
|
|
|
data = {}
|
2016-04-19 14:04:25 +02:00
|
|
|
|
|
2015-07-07 21:50:36 +02:00
|
|
|
|
if chat_id:
|
|
|
|
|
data['chat_id'] = chat_id
|
|
|
|
|
if from_chat_id:
|
|
|
|
|
data['from_chat_id'] = from_chat_id
|
|
|
|
|
if message_id:
|
|
|
|
|
data['message_id'] = message_id
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, disable_notification=disable_notification,
|
|
|
|
|
timeout=timeout, **kwargs)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_photo(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
photo,
|
|
|
|
|
caption=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
2017-12-08 22:38:59 +01:00
|
|
|
|
timeout=20,
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
**kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to send photos.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
|
|
Note:
|
2017-12-06 13:24:34 +01:00
|
|
|
|
The photo argument can be either a file_id, an URL or a file from disk
|
2017-07-23 22:33:08 +02:00
|
|
|
|
``open(filename, 'rb')``
|
2015-07-08 00:54:00 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-25 00:35:22 +02:00
|
|
|
|
photo (:obj:`str` | `filelike object` | :class:`telegram.PhotoSize`): Photo to send.
|
|
|
|
|
Pass a file_id as String to send a photo that exists on the Telegram servers
|
|
|
|
|
(recommended), pass an HTTP URL as a String for Telegram to get a photo from the
|
|
|
|
|
Internet, or upload a new photo using multipart/form-data. Lastly you can pass
|
|
|
|
|
an existing :class:`telegram.PhotoSize` object to send.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
caption (:obj:`str`, optional): Photo caption (may also be used when resending photos
|
2020-03-28 11:49:47 +01:00
|
|
|
|
by file_id), 0-1024 characters after entities parsing.
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to
|
|
|
|
|
show bold, italic, fixed-width text or inline URLs in the media caption. See the
|
|
|
|
|
constants in :class:`telegram.ParseMode` for the available modes.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
2016-10-17 00:11:20 +02:00
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
2016-12-11 22:44:52 +01:00
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 21:58:18 +02:00
|
|
|
|
|
2015-07-08 00:54:00 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendPhoto'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
if isinstance(photo, PhotoSize):
|
|
|
|
|
photo = photo.file_id
|
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
|
|
|
|
elif InputFile.is_file(photo):
|
|
|
|
|
photo = InputFile(photo)
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'photo': photo}
|
2015-07-07 23:46:32 +02:00
|
|
|
|
|
2015-07-07 21:50:36 +02:00
|
|
|
|
if caption:
|
|
|
|
|
data['caption'] = caption
|
2018-02-18 16:11:04 +01:00
|
|
|
|
if parse_mode:
|
|
|
|
|
data['parse_mode'] = parse_mode
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_audio(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
audio,
|
|
|
|
|
duration=None,
|
|
|
|
|
performer=None,
|
|
|
|
|
title=None,
|
|
|
|
|
caption=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
2017-12-08 22:38:59 +01:00
|
|
|
|
timeout=20,
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode=None,
|
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
|
|
|
|
thumb=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to send audio files, if you want Telegram clients to display them in the
|
2020-04-10 20:05:01 +02:00
|
|
|
|
music player. Your audio must be in the .mp3 or .m4a format.
|
|
|
|
|
|
|
|
|
|
Bots can currently send audio files of up to 50 MB in size, this limit may be changed in
|
|
|
|
|
the future.
|
2015-08-17 16:34:42 +02:00
|
|
|
|
|
2017-07-23 22:33:08 +02:00
|
|
|
|
For sending voice messages, use the sendVoice method instead.
|
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
The audio argument can be either a file_id, an URL or a file from disk
|
|
|
|
|
``open(filename, 'rb')``
|
2015-07-08 01:10:43 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-25 00:35:22 +02:00
|
|
|
|
audio (:obj:`str` | `filelike object` | :class:`telegram.Audio`): Audio file to send.
|
|
|
|
|
Pass a file_id as String to send an audio file that exists on the Telegram servers
|
|
|
|
|
(recommended), pass an HTTP URL as a String for Telegram to get an audio file from
|
|
|
|
|
the Internet, or upload a new one using multipart/form-data. Lastly you can pass
|
|
|
|
|
an existing :class:`telegram.Audio` object to send.
|
2020-03-28 11:49:47 +01:00
|
|
|
|
caption (:obj:`str`, optional): Audio caption, 0-1024 characters after entities
|
|
|
|
|
parsing.
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to
|
|
|
|
|
show bold, italic, fixed-width text or inline URLs in the media caption. See the
|
|
|
|
|
constants in :class:`telegram.ParseMode` for the available modes.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
duration (:obj:`int`, optional): Duration of sent audio in seconds.
|
|
|
|
|
performer (:obj:`str`, optional): Performer.
|
|
|
|
|
title (:obj:`str`, optional): Track name.
|
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
2016-10-17 00:11:20 +02:00
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
2016-12-11 22:44:52 +01:00
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
thumb (`filelike object`, optional): Thumbnail of the file sent; can be ignored if
|
2020-05-15 15:59:41 +02:00
|
|
|
|
thumbnail generation for the file is supported server-side. The thumbnail should be
|
|
|
|
|
in JPEG format and less than 200 kB in size. A thumbnail's width and height should
|
|
|
|
|
not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
|
|
|
|
|
Thumbnails can't be reused and can be only uploaded as a new file.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 21:58:18 +02:00
|
|
|
|
|
2015-07-08 01:10:43 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendAudio'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
if isinstance(audio, Audio):
|
|
|
|
|
audio = audio.file_id
|
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
|
|
|
|
elif InputFile.is_file(audio):
|
|
|
|
|
audio = InputFile(audio)
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'audio': audio}
|
2015-07-08 01:10:43 +02:00
|
|
|
|
|
2015-08-17 16:34:42 +02:00
|
|
|
|
if duration:
|
|
|
|
|
data['duration'] = duration
|
|
|
|
|
if performer:
|
|
|
|
|
data['performer'] = performer
|
|
|
|
|
if title:
|
|
|
|
|
data['title'] = title
|
2016-10-03 15:05:49 +02:00
|
|
|
|
if caption:
|
|
|
|
|
data['caption'] = caption
|
2018-02-18 16:11:04 +01:00
|
|
|
|
if parse_mode:
|
|
|
|
|
data['parse_mode'] = parse_mode
|
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 thumb:
|
|
|
|
|
if InputFile.is_file(thumb):
|
|
|
|
|
thumb = InputFile(thumb, attach=True)
|
|
|
|
|
data['thumb'] = thumb
|
2015-08-17 16:34:42 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2015-07-08 01:10:43 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_document(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
document,
|
|
|
|
|
filename=None,
|
|
|
|
|
caption=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
2017-12-08 22:38:59 +01:00
|
|
|
|
timeout=20,
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode=None,
|
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
|
|
|
|
thumb=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
**kwargs):
|
2020-04-10 20:05:01 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to send general files.
|
|
|
|
|
|
|
|
|
|
Bots can currently send files of any type of up to 50 MB in size, this limit may be
|
|
|
|
|
changed in the future.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
The document argument can be either a file_id, an URL or a file from disk
|
|
|
|
|
``open(filename, 'rb')``
|
2015-07-08 02:12:51 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-25 00:35:22 +02:00
|
|
|
|
document (:obj:`str` | `filelike object` | :class:`telegram.Document`): File to send.
|
|
|
|
|
Pass a file_id as String to send a file that exists on the Telegram servers
|
|
|
|
|
(recommended), pass an HTTP URL as a String for Telegram to get a file from the
|
|
|
|
|
Internet, or upload a new one using multipart/form-data. Lastly you can pass
|
|
|
|
|
an existing :class:`telegram.Document` object to send.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
filename (:obj:`str`, optional): File name that shows in telegram message (it is useful
|
|
|
|
|
when you send file generated by temp module, for example). Undocumented.
|
|
|
|
|
caption (:obj:`str`, optional): Document caption (may also be used when resending
|
2020-03-28 11:49:47 +01:00
|
|
|
|
documents by file_id), 0-1024 characters after entities parsing.
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to
|
|
|
|
|
show bold, italic, fixed-width text or inline URLs in the media caption. See the
|
|
|
|
|
constants in :class:`telegram.ParseMode` for the available modes.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
2016-10-17 00:11:20 +02:00
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
2016-12-11 22:44:52 +01:00
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
thumb (`filelike object`, optional): Thumbnail of the file sent; can be ignored if
|
2020-05-15 15:59:41 +02:00
|
|
|
|
thumbnail generation for the file is supported server-side. The thumbnail should be
|
|
|
|
|
in JPEG format and less than 200 kB in size. A thumbnail's width and height should
|
|
|
|
|
not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
|
|
|
|
|
Thumbnails can't be reused and can be only uploaded as a new file.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 21:58:18 +02:00
|
|
|
|
|
2015-07-08 02:12:51 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendDocument'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
if isinstance(document, Document):
|
|
|
|
|
document = document.file_id
|
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
|
|
|
|
elif InputFile.is_file(document):
|
|
|
|
|
document = InputFile(document, filename=filename)
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'document': document}
|
2015-07-08 02:12:51 +02:00
|
|
|
|
|
2016-04-24 17:51:15 +02:00
|
|
|
|
if caption:
|
|
|
|
|
data['caption'] = caption
|
2018-02-18 16:11:04 +01:00
|
|
|
|
if parse_mode:
|
|
|
|
|
data['parse_mode'] = parse_mode
|
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 thumb:
|
|
|
|
|
if InputFile.is_file(thumb):
|
|
|
|
|
thumb = InputFile(thumb, attach=True)
|
|
|
|
|
data['thumb'] = thumb
|
2015-09-11 01:08:24 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2015-07-08 02:12:51 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_sticker(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
sticker,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
2018-05-01 21:48:31 +02:00
|
|
|
|
timeout=20,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
**kwargs):
|
2020-04-10 20:05:01 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to send static .WEBP or animated .TGS stickers.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
The sticker argument can be either a file_id, an URL or a file from disk
|
|
|
|
|
``open(filename, 'rb')``
|
2015-07-08 14:17:18 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-25 00:35:22 +02:00
|
|
|
|
sticker (:obj:`str` | `filelike object` :class:`telegram.Sticker`): Sticker to send.
|
|
|
|
|
Pass a file_id as String to send a file that exists on the Telegram servers
|
|
|
|
|
(recommended), pass an HTTP URL as a String for Telegram to get a .webp file from
|
|
|
|
|
the Internet, or upload a new one using multipart/form-data. Lastly you can pass
|
|
|
|
|
an existing :class:`telegram.Sticker` object to send.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
2016-10-17 00:11:20 +02:00
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
2016-12-11 22:44:52 +01:00
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 21:58:18 +02:00
|
|
|
|
|
2015-07-08 14:17:18 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendSticker'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
if isinstance(sticker, Sticker):
|
|
|
|
|
sticker = sticker.file_id
|
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
|
|
|
|
elif InputFile.is_file(sticker):
|
|
|
|
|
sticker = InputFile(sticker)
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'sticker': sticker}
|
2015-09-11 01:08:24 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2015-07-08 04:52:12 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_video(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
video,
|
|
|
|
|
duration=None,
|
|
|
|
|
caption=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
2017-12-08 22:38:59 +01:00
|
|
|
|
timeout=20,
|
2017-06-14 13:48:45 +02:00
|
|
|
|
width=None,
|
|
|
|
|
height=None,
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode=None,
|
|
|
|
|
supports_streaming=None,
|
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
|
|
|
|
thumb=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to send video files, Telegram clients support mp4 videos
|
|
|
|
|
(other formats may be sent as Document).
|
|
|
|
|
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Bots can currently send video files of up to 50 MB in size, this limit may be changed in
|
|
|
|
|
the future.
|
|
|
|
|
|
2017-07-23 22:33:08 +02:00
|
|
|
|
Note:
|
|
|
|
|
The video argument can be either a file_id, an URL or a file from disk
|
|
|
|
|
``open(filename, 'rb')``
|
2015-07-08 14:17:18 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-25 00:35:22 +02:00
|
|
|
|
video (:obj:`str` | `filelike object` | :class:`telegram.Video`): Video file to send.
|
|
|
|
|
Pass a file_id as String to send an video file that exists on the Telegram servers
|
|
|
|
|
(recommended), pass an HTTP URL as a String for Telegram to get an video file from
|
|
|
|
|
the Internet, or upload a new one using multipart/form-data. Lastly you can pass
|
|
|
|
|
an existing :class:`telegram.Video` object to send.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
duration (:obj:`int`, optional): Duration of sent video in seconds.
|
2017-08-02 04:56:07 +02:00
|
|
|
|
width (:obj:`int`, optional): Video width.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
height (:obj:`int`, optional): Video height.
|
|
|
|
|
caption (:obj:`str`, optional): Video caption (may also be used when resending videos
|
2020-03-28 11:49:47 +01:00
|
|
|
|
by file_id), 0-1024 characters after entities parsing.
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to
|
|
|
|
|
show bold, italic, fixed-width text or inline URLs in the media caption. See the
|
|
|
|
|
constants in :class:`telegram.ParseMode` for the available modes.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
supports_streaming (:obj:`bool`, optional): Pass :obj:`True`, if the uploaded video is
|
2018-02-18 16:11:04 +01:00
|
|
|
|
suitable for streaming.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
2016-10-17 00:11:20 +02:00
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
2016-12-11 22:44:52 +01:00
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
thumb (`filelike object`, optional): Thumbnail of the file sent; can be ignored if
|
2020-05-15 15:59:41 +02:00
|
|
|
|
thumbnail generation for the file is supported server-side. The thumbnail should be
|
|
|
|
|
in JPEG format and less than 200 kB in size. A thumbnail's width and height should
|
|
|
|
|
not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
|
|
|
|
|
Thumbnails can't be reused and can be only uploaded as a new file.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 21:58:18 +02:00
|
|
|
|
|
2015-07-08 14:17:18 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendVideo'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
if isinstance(video, Video):
|
|
|
|
|
video = video.file_id
|
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
|
|
|
|
elif InputFile.is_file(video):
|
|
|
|
|
video = InputFile(video)
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'video': video}
|
2015-07-08 14:17:18 +02:00
|
|
|
|
|
2015-08-11 22:32:06 +02:00
|
|
|
|
if duration:
|
|
|
|
|
data['duration'] = duration
|
|
|
|
|
if caption:
|
|
|
|
|
data['caption'] = caption
|
2018-02-18 16:11:04 +01:00
|
|
|
|
if parse_mode:
|
|
|
|
|
data['parse_mode'] = parse_mode
|
|
|
|
|
if supports_streaming:
|
|
|
|
|
data['supports_streaming'] = supports_streaming
|
2017-06-14 13:48:45 +02:00
|
|
|
|
if width:
|
|
|
|
|
data['width'] = width
|
|
|
|
|
if height:
|
|
|
|
|
data['height'] = height
|
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 thumb:
|
|
|
|
|
if InputFile.is_file(thumb):
|
|
|
|
|
thumb = InputFile(thumb, attach=True)
|
|
|
|
|
data['thumb'] = thumb
|
2015-08-11 22:32:06 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2015-07-08 14:17:18 +02:00
|
|
|
|
|
2015-08-17 16:34:42 +02:00
|
|
|
|
@log
|
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 send_video_note(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
video_note,
|
|
|
|
|
duration=None,
|
|
|
|
|
length=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=20,
|
|
|
|
|
thumb=None,
|
|
|
|
|
**kwargs):
|
2020-04-10 20:05:01 +02:00
|
|
|
|
"""
|
|
|
|
|
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long.
|
|
|
|
|
Use this method to send video messages.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
|
|
Note:
|
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
|
|
|
|
The video_note argument can be either a file_id or a file from disk
|
2017-07-23 22:33:08 +02:00
|
|
|
|
``open(filename, 'rb')``
|
2015-08-17 16:34:42 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
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
|
|
|
|
video_note (:obj:`str` | `filelike object` | :class:`telegram.VideoNote`): Video note
|
|
|
|
|
to send. Pass a file_id as String to send a video note that exists on the Telegram
|
|
|
|
|
servers (recommended) or upload a new video using multipart/form-data. Or you can
|
|
|
|
|
pass an existing :class:`telegram.VideoNote` object to send. Sending video notes by
|
|
|
|
|
a URL is currently unsupported.
|
|
|
|
|
duration (:obj:`int`, optional): Duration of sent video in seconds.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
length (:obj:`int`, optional): Video width and height, i.e. diameter of the video
|
|
|
|
|
message.
|
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
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard,
|
|
|
|
|
instructions to remove reply keyboard or to force a reply from the user.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
thumb (`filelike object`, optional): Thumbnail of the file sent; can be ignored if
|
2020-05-15 15:59:41 +02:00
|
|
|
|
thumbnail generation for the file is supported server-side. The thumbnail should be
|
|
|
|
|
in JPEG format and less than 200 kB in size. A thumbnail's width and height should
|
|
|
|
|
not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
|
|
|
|
|
Thumbnails can't be reused and can be only uploaded as a new file.
|
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
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendVideoNote'.format(self.base_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 isinstance(video_note, VideoNote):
|
|
|
|
|
video_note = video_note.file_id
|
|
|
|
|
elif InputFile.is_file(video_note):
|
|
|
|
|
video_note = InputFile(video_note)
|
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'video_note': video_note}
|
|
|
|
|
|
|
|
|
|
if duration is not None:
|
|
|
|
|
data['duration'] = duration
|
|
|
|
|
if length is not None:
|
|
|
|
|
data['length'] = length
|
|
|
|
|
if thumb:
|
|
|
|
|
if InputFile.is_file(thumb):
|
|
|
|
|
thumb = InputFile(thumb, attach=True)
|
|
|
|
|
data['thumb'] = thumb
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
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
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def send_animation(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
animation,
|
|
|
|
|
duration=None,
|
|
|
|
|
width=None,
|
|
|
|
|
height=None,
|
|
|
|
|
thumb=None,
|
|
|
|
|
caption=None,
|
|
|
|
|
parse_mode=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=20,
|
|
|
|
|
**kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Bots can currently send animation files of up to 50 MB in size, this limit may be changed
|
|
|
|
|
in the future.
|
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
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
|
|
|
|
animation (:obj:`str` | `filelike object` | :class:`telegram.Animation`): Animation to
|
|
|
|
|
send. Pass a file_id as String to send an animation that exists on the Telegram
|
|
|
|
|
servers (recommended), pass an HTTP URL as a String for Telegram to get an
|
|
|
|
|
animation from the Internet, or upload a new animation using multipart/form-data.
|
|
|
|
|
Lastly you can pass an existing :class:`telegram.Animation` object to send.
|
|
|
|
|
duration (:obj:`int`, optional): Duration of sent animation in seconds.
|
|
|
|
|
width (:obj:`int`, optional): Animation width.
|
|
|
|
|
height (:obj:`int`, optional): Animation height.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
thumb (`filelike object`, optional): Thumbnail of the file sent; can be ignored if
|
2020-05-15 15:59:41 +02:00
|
|
|
|
thumbnail generation for the file is supported server-side. The thumbnail should be
|
|
|
|
|
in JPEG format and less than 200 kB in size. A thumbnail's width and height should
|
|
|
|
|
not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
|
|
|
|
|
Thumbnails can't be reused and can be only uploaded as a new file.
|
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
|
|
|
|
caption (:obj:`str`, optional): Animation caption (may also be used when resending
|
2020-03-28 11:49:47 +01:00
|
|
|
|
animations by file_id), 0-1024 characters after entities parsing.
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to
|
|
|
|
|
show bold, italic, fixed-width text or inline URLs in the media caption. See the
|
|
|
|
|
constants in :class:`telegram.ParseMode` for the available modes.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
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
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-08-17 16:34:42 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendAnimation'.format(self.base_url)
|
2015-08-17 16:34:42 +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
|
|
|
|
if isinstance(animation, Animation):
|
|
|
|
|
animation = animation.file_id
|
|
|
|
|
elif InputFile.is_file(animation):
|
|
|
|
|
animation = InputFile(animation)
|
2017-07-25 00:35:22 +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
|
|
|
|
data = {'chat_id': chat_id, 'animation': animation}
|
2015-08-17 16:34:42 +02:00
|
|
|
|
|
|
|
|
|
if duration:
|
|
|
|
|
data['duration'] = duration
|
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 width:
|
|
|
|
|
data['width'] = width
|
|
|
|
|
if height:
|
|
|
|
|
data['height'] = height
|
|
|
|
|
if thumb:
|
|
|
|
|
if InputFile.is_file(thumb):
|
|
|
|
|
thumb = InputFile(thumb, attach=True)
|
|
|
|
|
data['thumb'] = thumb
|
2016-10-03 15:05:49 +02:00
|
|
|
|
if caption:
|
|
|
|
|
data['caption'] = caption
|
2018-02-18 16:11:04 +01:00
|
|
|
|
if parse_mode:
|
|
|
|
|
data['parse_mode'] = parse_mode
|
2015-08-17 16:34:42 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2015-08-17 16:34:42 +02:00
|
|
|
|
|
2017-05-20 19:35:55 +02:00
|
|
|
|
@log
|
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 send_voice(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
voice,
|
|
|
|
|
duration=None,
|
|
|
|
|
caption=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=20,
|
|
|
|
|
parse_mode=None,
|
|
|
|
|
**kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Use this method to send audio files, if you want Telegram clients to display the file
|
|
|
|
|
as a playable voice message. For this to work, your audio must be in an .ogg file
|
2020-04-10 20:05:01 +02:00
|
|
|
|
encoded with OPUS (other formats may be sent as Audio or Document). Bots can currently
|
|
|
|
|
send voice messages of up to 50 MB in size, this limit may be changed in the future.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
|
|
Note:
|
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
|
|
|
|
The voice argument can be either a file_id, an URL or a file from disk
|
2017-07-23 22:33:08 +02:00
|
|
|
|
``open(filename, 'rb')``
|
2017-05-20 19:35:55 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
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
|
|
|
|
voice (:obj:`str` | `filelike object` | :class:`telegram.Voice`): Voice file to send.
|
|
|
|
|
Pass a file_id as String to send an voice file that exists on the Telegram servers
|
|
|
|
|
(recommended), pass an HTTP URL as a String for Telegram to get an voice file from
|
|
|
|
|
the Internet, or upload a new one using multipart/form-data. Lastly you can pass
|
|
|
|
|
an existing :class:`telegram.Voice` object to send.
|
2020-03-28 11:49:47 +01:00
|
|
|
|
caption (:obj:`str`, optional): Voice message caption, 0-1024 characters after entities
|
|
|
|
|
parsing.
|
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
|
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to
|
|
|
|
|
show bold, italic, fixed-width text or inline URLs in the media caption. See the
|
|
|
|
|
constants in :class:`telegram.ParseMode` for the available modes.
|
|
|
|
|
duration (:obj:`int`, optional): Duration of the voice message in seconds.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard,
|
|
|
|
|
instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2017-05-20 19:35:55 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2017-05-20 19:35:55 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendVoice'.format(self.base_url)
|
2017-05-20 19:35:55 +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
|
|
|
|
if isinstance(voice, Voice):
|
|
|
|
|
voice = voice.file_id
|
|
|
|
|
elif InputFile.is_file(voice):
|
|
|
|
|
voice = InputFile(voice)
|
2017-07-25 00:35:22 +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
|
|
|
|
data = {'chat_id': chat_id, 'voice': voice}
|
2017-05-20 19:35:55 +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
|
|
|
|
if duration:
|
2017-05-20 19:35:55 +02:00
|
|
|
|
data['duration'] = duration
|
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 caption:
|
|
|
|
|
data['caption'] = caption
|
|
|
|
|
if parse_mode:
|
|
|
|
|
data['parse_mode'] = parse_mode
|
2017-05-20 19:35:55 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2017-05-20 19:35:55 +02:00
|
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
|
@log
|
|
|
|
|
def send_media_group(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
media,
|
|
|
|
|
disable_notification=None,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
timeout=20,
|
|
|
|
|
**kwargs):
|
|
|
|
|
"""Use this method to send a group of photos or videos as an album.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
|
|
|
|
media (List[:class:`telegram.InputMedia`]): An array describing photos and videos to be
|
|
|
|
|
sent, must include 2–10 items.
|
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
List[:class:`telegram.Message`]: An array of the sent Messages.
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
"""
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendMediaGroup'.format(self.base_url)
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'media': media}
|
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
for m in data['media']:
|
|
|
|
|
if m.parse_mode == DEFAULT_NONE:
|
|
|
|
|
if self.defaults:
|
|
|
|
|
m.parse_mode = self.defaults.parse_mode
|
|
|
|
|
else:
|
|
|
|
|
m.parse_mode = None
|
|
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
|
if reply_to_message_id:
|
|
|
|
|
data['reply_to_message_id'] = reply_to_message_id
|
|
|
|
|
if disable_notification:
|
|
|
|
|
data['disable_notification'] = disable_notification
|
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
if self.defaults:
|
|
|
|
|
for res in result:
|
|
|
|
|
res['default_quote'] = self.defaults.quote
|
|
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
|
return [Message.de_json(res, self) for res in result]
|
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_location(self,
|
|
|
|
|
chat_id,
|
2017-07-25 00:35:22 +02:00
|
|
|
|
latitude=None,
|
|
|
|
|
longitude=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
2017-07-25 00:35:22 +02:00
|
|
|
|
location=None,
|
2017-10-14 20:03:02 +02:00
|
|
|
|
live_period=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
**kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to send point on the map.
|
2015-07-08 14:37:25 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
Note:
|
|
|
|
|
You can either supply a :obj:`latitude` and :obj:`longitude` or a :obj:`location`.
|
|
|
|
|
|
2015-07-08 14:37:25 +02:00
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-25 00:35:22 +02:00
|
|
|
|
latitude (:obj:`float`, optional): Latitude of location.
|
|
|
|
|
longitude (:obj:`float`, optional): Longitude of location.
|
|
|
|
|
location (:class:`telegram.Location`, optional): The location to send.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
live_period (:obj:`int`, optional): Period in seconds for which the location will be
|
|
|
|
|
updated, should be between 60 and 86400.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard,
|
|
|
|
|
instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 21:58:18 +02:00
|
|
|
|
|
2015-07-08 14:37:25 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendLocation'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2019-08-23 21:13:29 +02:00
|
|
|
|
if not ((latitude is not None and longitude is not None) or location):
|
2017-07-25 00:35:22 +02:00
|
|
|
|
raise ValueError("Either location or latitude and longitude must be passed as"
|
2017-10-14 20:03:02 +02:00
|
|
|
|
"argument.")
|
|
|
|
|
|
|
|
|
|
if not ((latitude is not None or longitude is not None) ^ bool(location)):
|
|
|
|
|
raise ValueError("Either location or latitude and longitude must be passed as"
|
|
|
|
|
"argument. Not both.")
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
|
|
|
|
if isinstance(location, Location):
|
|
|
|
|
latitude = location.latitude
|
|
|
|
|
longitude = location.longitude
|
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude}
|
2015-07-08 14:37:25 +02:00
|
|
|
|
|
2017-10-14 20:03:02 +02:00
|
|
|
|
if live_period:
|
|
|
|
|
data['live_period'] = live_period
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def edit_message_live_location(self,
|
|
|
|
|
chat_id=None,
|
|
|
|
|
message_id=None,
|
|
|
|
|
inline_message_id=None,
|
|
|
|
|
latitude=None,
|
|
|
|
|
longitude=None,
|
|
|
|
|
location=None,
|
|
|
|
|
reply_markup=None,
|
2019-02-13 11:37:13 +01:00
|
|
|
|
timeout=None,
|
2017-10-14 20:03:02 +02:00
|
|
|
|
**kwargs):
|
|
|
|
|
"""Use this method to edit live location messages sent by the bot or via the bot
|
|
|
|
|
(for inline bots). A location can be edited until its :attr:`live_period` expires or
|
|
|
|
|
editing is explicitly disabled by a call to :attr:`stop_message_live_location`.
|
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
You can either supply a :obj:`latitude` and :obj:`longitude` or a :obj:`location`.
|
|
|
|
|
|
|
|
|
|
Args:
|
2020-02-02 20:20:54 +01:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
|
|
|
|
|
specified. Unique identifier for the target chat or username of the target channel
|
|
|
|
|
(in the format @channelusername).
|
2017-10-14 20:03:02 +02:00
|
|
|
|
message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Identifier of the message to edit.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
|
|
|
|
|
specified. Identifier of the inline message.
|
|
|
|
|
latitude (:obj:`float`, optional): Latitude of location.
|
|
|
|
|
longitude (:obj:`float`, optional): Longitude of location.
|
|
|
|
|
location (:class:`telegram.Location`, optional): The location to send.
|
2020-02-02 20:20:54 +01:00
|
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): A JSON-serialized
|
2020-04-10 20:05:01 +02:00
|
|
|
|
object for a new inline keyboard.
|
2017-10-14 20:03:02 +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).
|
|
|
|
|
|
|
|
|
|
Returns:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
edited Message is returned, otherwise :obj:`True` is returned.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
"""
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/editMessageLiveLocation'.format(self.base_url)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
|
|
if not (all([latitude, longitude]) or location):
|
|
|
|
|
raise ValueError("Either location or latitude and longitude must be passed as"
|
|
|
|
|
"argument.")
|
|
|
|
|
if not ((latitude is not None or longitude is not None) ^ bool(location)):
|
|
|
|
|
raise ValueError("Either location or latitude and longitude must be passed as"
|
|
|
|
|
"argument. Not both.")
|
|
|
|
|
|
|
|
|
|
if isinstance(location, Location):
|
|
|
|
|
latitude = location.latitude
|
|
|
|
|
longitude = location.longitude
|
|
|
|
|
|
|
|
|
|
data = {'latitude': latitude, 'longitude': longitude}
|
|
|
|
|
|
|
|
|
|
if chat_id:
|
|
|
|
|
data['chat_id'] = chat_id
|
|
|
|
|
if message_id:
|
|
|
|
|
data['message_id'] = message_id
|
|
|
|
|
if inline_message_id:
|
|
|
|
|
data['inline_message_id'] = inline_message_id
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, reply_markup=reply_markup, **kwargs)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def stop_message_live_location(self,
|
|
|
|
|
chat_id=None,
|
|
|
|
|
message_id=None,
|
|
|
|
|
inline_message_id=None,
|
|
|
|
|
reply_markup=None,
|
2019-02-13 11:37:13 +01:00
|
|
|
|
timeout=None,
|
2017-10-14 20:03:02 +02:00
|
|
|
|
**kwargs):
|
|
|
|
|
"""Use this method to stop updating a live location message sent by the bot or via the bot
|
|
|
|
|
(for inline bots) before live_period expires.
|
|
|
|
|
|
|
|
|
|
Args:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Required if inline_message_id is not specified.
|
|
|
|
|
Unique identifier for the target chat or username of the target channel
|
|
|
|
|
(in the format @channelusername).
|
2017-10-14 20:03:02 +02:00
|
|
|
|
message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Identifier of the sent message with live location to stop.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
|
|
|
|
|
specified. Identifier of the inline message.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): A JSON-serialized
|
|
|
|
|
object for a new inline keyboard.
|
2017-10-14 20:03:02 +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).
|
|
|
|
|
|
|
|
|
|
Returns:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
edited Message is returned, otherwise :obj:`True` is returned.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
"""
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/stopMessageLiveLocation'.format(self.base_url)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
|
|
data = {}
|
|
|
|
|
|
|
|
|
|
if chat_id:
|
|
|
|
|
data['chat_id'] = chat_id
|
|
|
|
|
if message_id:
|
|
|
|
|
data['message_id'] = message_id
|
|
|
|
|
if inline_message_id:
|
|
|
|
|
data['inline_message_id'] = inline_message_id
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, reply_markup=reply_markup, **kwargs)
|
2015-07-08 14:37:25 +02:00
|
|
|
|
|
2016-04-16 16:48:36 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_venue(self,
|
|
|
|
|
chat_id,
|
2017-07-25 00:35:22 +02:00
|
|
|
|
latitude=None,
|
|
|
|
|
longitude=None,
|
|
|
|
|
title=None,
|
|
|
|
|
address=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
foursquare_id=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
2017-07-25 00:35:22 +02:00
|
|
|
|
venue=None,
|
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
|
|
|
|
foursquare_type=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
**kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to send information about a venue.
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
Note:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
You can either supply :obj:`venue`, or :obj:`latitude`, :obj:`longitude`,
|
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
|
|
|
|
:obj:`title` and :obj:`address` and optionally :obj:`foursquare_id` and optionally
|
|
|
|
|
:obj:`foursquare_type`.
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
2016-04-16 16:48:36 +02:00
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-25 00:35:22 +02:00
|
|
|
|
latitude (:obj:`float`, optional): Latitude of venue.
|
|
|
|
|
longitude (:obj:`float`, optional): Longitude of venue.
|
|
|
|
|
title (:obj:`str`, optional): Name of the venue.
|
|
|
|
|
address (:obj:`str`, optional): Address of the venue.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
foursquare_id (:obj:`str`, optional): Foursquare identifier of the venue.
|
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
|
|
|
|
foursquare_type (:obj:`str`, optional): Foursquare type of the venue, if known.
|
|
|
|
|
(For example, "arts_entertainment/default", "arts_entertainment/aquarium" or
|
|
|
|
|
"food/icecream".)
|
2017-07-25 00:35:22 +02:00
|
|
|
|
venue (:class:`telegram.Venue`, optional): The venue to send.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
2016-10-17 00:11:20 +02:00
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
2016-12-11 22:44:52 +01:00
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendVenue'.format(self.base_url)
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
if not (venue or all([latitude, longitude, address, title])):
|
|
|
|
|
raise ValueError("Either venue or latitude, longitude, address and title must be"
|
|
|
|
|
"passed as arguments.")
|
|
|
|
|
|
|
|
|
|
if isinstance(venue, Venue):
|
|
|
|
|
latitude = venue.location.latitude
|
|
|
|
|
longitude = venue.location.longitude
|
|
|
|
|
address = venue.address
|
|
|
|
|
title = venue.title
|
|
|
|
|
foursquare_id = venue.foursquare_id
|
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
|
|
|
|
foursquare_type = venue.foursquare_type
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
2016-10-12 22:56:57 +02:00
|
|
|
|
data = {
|
|
|
|
|
'chat_id': chat_id,
|
|
|
|
|
'latitude': latitude,
|
|
|
|
|
'longitude': longitude,
|
|
|
|
|
'address': address,
|
|
|
|
|
'title': title
|
|
|
|
|
}
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
|
|
|
|
if foursquare_id:
|
|
|
|
|
data['foursquare_id'] = foursquare_id
|
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 foursquare_type:
|
|
|
|
|
data['foursquare_type'] = foursquare_type
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_contact(self,
|
|
|
|
|
chat_id,
|
2017-07-25 00:35:22 +02:00
|
|
|
|
phone_number=None,
|
|
|
|
|
first_name=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
last_name=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
2017-07-25 00:35:22 +02:00
|
|
|
|
contact=None,
|
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
|
|
|
|
vcard=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
**kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to send phone contacts.
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
Note:
|
|
|
|
|
You can either supply :obj:`contact` or :obj:`phone_number` and :obj:`first_name`
|
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 optionally :obj:`last_name` and optionally :obj:`vcard`.
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
2016-04-16 16:48:36 +02:00
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-25 00:35:22 +02:00
|
|
|
|
phone_number (:obj:`str`, optional): Contact's phone number.
|
|
|
|
|
first_name (:obj:`str`, optional): Contact's first name.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
last_name (:obj:`str`, optional): Contact's last name.
|
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
|
|
|
|
vcard (:obj:`str`, optional): Additional data about the contact in the form of a vCard,
|
|
|
|
|
0-2048 bytes.
|
2017-07-25 00:35:22 +02:00
|
|
|
|
contact (:class:`telegram.Contact`, optional): The contact to send.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
2016-10-17 00:11:20 +02:00
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
2016-12-11 22:44:52 +01:00
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendContact'.format(self.base_url)
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
2017-07-25 00:35:22 +02:00
|
|
|
|
if (not contact) and (not all([phone_number, first_name])):
|
|
|
|
|
raise ValueError("Either contact or phone_number and first_name must be passed as"
|
|
|
|
|
"arguments.")
|
|
|
|
|
|
|
|
|
|
if isinstance(contact, Contact):
|
|
|
|
|
phone_number = contact.phone_number
|
|
|
|
|
first_name = contact.first_name
|
|
|
|
|
last_name = contact.last_name
|
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
|
|
|
|
vcard = contact.vcard
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'phone_number': phone_number, 'first_name': first_name}
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
|
|
|
|
if last_name:
|
|
|
|
|
data['last_name'] = last_name
|
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 vcard:
|
|
|
|
|
data['vcard'] = vcard
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2016-04-16 16:48:36 +02:00
|
|
|
|
|
2016-10-03 20:22:57 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_game(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
game_short_name,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to send a game.
|
2016-10-03 20:22:57 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
|
|
|
|
game_short_name (:obj:`str`): Short name of the game, serves as the unique identifier
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
for the game. Set up your games via `@BotFather <https://t.me/BotFather>`_.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): A JSON-serialized
|
|
|
|
|
object for a new inline keyboard. If empty, one ‘Play game_title’ button will be
|
|
|
|
|
shown. If not empty, the first button must launch the game.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-10-03 20:22:57 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2016-10-03 20:22:57 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendGame'.format(self.base_url)
|
2016-10-03 20:22:57 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'game_short_name': game_short_name}
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2016-10-03 20:22:57 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def send_chat_action(self, chat_id, action, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method when you need to tell the user that something is happening on the bot's
|
2016-10-17 00:11:20 +02:00
|
|
|
|
side. The status is set for 5 seconds or less (when a message arrives from your bot,
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Telegram clients clear its typing status). Telegram only recommends using this method when
|
|
|
|
|
a response from the bot will take a noticeable amount of time to arrive.
|
2015-07-08 14:55:06 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
|
|
|
|
action(:class:`telegram.ChatAction` | :obj:`str`): Type of action to broadcast. Choose
|
|
|
|
|
one, depending on what the user is about to receive. For convenience look at the
|
|
|
|
|
constants in :class:`telegram.ChatAction`
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 14:55:06 +02:00
|
|
|
|
|
2017-07-23 22:33:08 +02:00
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendChatAction'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'action': action}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2015-07-08 14:55:06 +02:00
|
|
|
|
|
2017-06-18 12:14:24 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
2015-07-08 14:55:06 +02:00
|
|
|
|
|
2016-01-04 17:31:06 +01:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def answer_inline_query(self,
|
|
|
|
|
inline_query_id,
|
|
|
|
|
results,
|
|
|
|
|
cache_time=300,
|
|
|
|
|
is_personal=None,
|
|
|
|
|
next_offset=None,
|
|
|
|
|
switch_pm_text=None,
|
|
|
|
|
switch_pm_parameter=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to send answers to an inline query. No more than 50 results per query are
|
|
|
|
|
allowed.
|
2016-01-04 17:31:06 +01:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
inline_query_id (:obj:`str`): Unique identifier for the answered query.
|
|
|
|
|
results (List[:class:`telegram.InlineQueryResult`)]: A list of results for the inline
|
2016-10-17 00:11:20 +02:00
|
|
|
|
query.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
cache_time (:obj:`int`, optional): The maximum amount of time in seconds that the
|
|
|
|
|
result of the inline query may be cached on the server. Defaults to 300.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
is_personal (:obj:`bool`, optional): Pass :obj:`True`, if results may be cached on
|
|
|
|
|
the server side only for the user that sent the query. By default,
|
|
|
|
|
results may be returned to any user who sends the same query.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
next_offset (:obj:`str`, optional): Pass the offset that a client should send in the
|
|
|
|
|
next query with the same text to receive more results. Pass an empty string if
|
|
|
|
|
there are no more results or if you don't support pagination. Offset length can't
|
|
|
|
|
exceed 64 bytes.
|
|
|
|
|
switch_pm_text (:obj:`str`, optional): If passed, clients will display a button with
|
|
|
|
|
specified text that switches the user to a private chat with the bot and sends the
|
|
|
|
|
bot a start message with the parameter switch_pm_parameter.
|
|
|
|
|
switch_pm_parameter (:obj:`str`, optional): Deep-linking parameter for the /start
|
|
|
|
|
message sent to the bot when user presses the switch button. 1-64 characters,
|
|
|
|
|
only A-Z, a-z, 0-9, _ and - are allowed.
|
|
|
|
|
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
the read timeout from the server (instead of the one specified during creation of
|
2017-07-23 22:33:08 +02:00
|
|
|
|
the connection pool).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
An inline bot that sends YouTube videos can ask the user to connect the bot to their
|
|
|
|
|
YouTube account to adapt search results accordingly. To do this, it displays a
|
|
|
|
|
'Connect your YouTube account' button above the results, or even before showing any.
|
|
|
|
|
The user presses the button, switches to a private chat with the bot and, in doing so,
|
|
|
|
|
passes a start parameter that instructs the bot to return an oauth link. Once done, the
|
|
|
|
|
bot can offer a switch_inline button so that the user can easily return to the chat
|
|
|
|
|
where they wanted to use the bot's inline capabilities.
|
2016-04-24 15:06:59 +02:00
|
|
|
|
|
2016-04-19 14:04:25 +02:00
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2016-04-14 07:34:29 +02:00
|
|
|
|
|
2016-04-19 14:04:25 +02:00
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/answerInlineQuery'.format(self.base_url)
|
2016-01-04 17:31:06 +01:00
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
for res in results:
|
|
|
|
|
if res._has_parse_mode and res.parse_mode == DEFAULT_NONE:
|
2020-02-08 17:52:23 +01:00
|
|
|
|
if self.defaults:
|
|
|
|
|
res.parse_mode = self.defaults.parse_mode
|
|
|
|
|
else:
|
|
|
|
|
res.parse_mode = None
|
2020-02-06 11:22:56 +01:00
|
|
|
|
if res._has_input_message_content and res.input_message_content:
|
|
|
|
|
if (res.input_message_content._has_parse_mode
|
|
|
|
|
and res.input_message_content.parse_mode == DEFAULT_NONE):
|
|
|
|
|
if self.defaults:
|
|
|
|
|
res.input_message_content.parse_mode = self.defaults.parse_mode
|
|
|
|
|
else:
|
|
|
|
|
res.input_message_content.parse_mode = None
|
|
|
|
|
if (res.input_message_content._has_disable_web_page_preview
|
|
|
|
|
and res.input_message_content.disable_web_page_preview == DEFAULT_NONE):
|
|
|
|
|
if self.defaults:
|
|
|
|
|
res.input_message_content.disable_web_page_preview = \
|
|
|
|
|
self.defaults.disable_web_page_preview
|
|
|
|
|
else:
|
|
|
|
|
res.input_message_content.disable_web_page_preview = None
|
|
|
|
|
|
2016-01-04 17:31:06 +01:00
|
|
|
|
results = [res.to_dict() for res in results]
|
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'inline_query_id': inline_query_id, 'results': results}
|
2016-01-04 17:31:06 +01:00
|
|
|
|
|
2016-04-19 00:08:47 +02:00
|
|
|
|
if cache_time or cache_time == 0:
|
2016-04-21 13:15:38 +02:00
|
|
|
|
data['cache_time'] = cache_time
|
2016-04-14 07:38:51 +02:00
|
|
|
|
if is_personal:
|
2016-04-21 13:15:38 +02:00
|
|
|
|
data['is_personal'] = is_personal
|
2016-04-25 16:26:36 +02:00
|
|
|
|
if next_offset is not None:
|
2016-01-04 17:31:06 +01:00
|
|
|
|
data['next_offset'] = next_offset
|
2016-04-14 07:34:29 +02:00
|
|
|
|
if switch_pm_text:
|
|
|
|
|
data['switch_pm_text'] = switch_pm_text
|
|
|
|
|
if switch_pm_parameter:
|
|
|
|
|
data['switch_pm_parameter'] = switch_pm_parameter
|
2016-01-04 17:31:06 +01:00
|
|
|
|
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-01-04 17:31:06 +01:00
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_user_profile_photos(self, user_id, offset=None, limit=100, timeout=None, **kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to get a list of profile pictures for a user.
|
2015-07-08 15:14:07 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
|
|
|
|
offset (:obj:`int`, optional): Sequential number of the first photo to be returned.
|
|
|
|
|
By default, all photos are returned.
|
|
|
|
|
limit (:obj:`int`, optional): Limits the number of photos to be retrieved. Values
|
|
|
|
|
between 1-100 are accepted. Defaults to 100.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-24 15:06:59 +02:00
|
|
|
|
|
2015-07-08 15:14:07 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.UserProfilePhotos`
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getUserProfilePhotos'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2015-07-08 15:10:08 +02:00
|
|
|
|
data = {'user_id': user_id}
|
|
|
|
|
|
2017-08-07 23:13:32 +02:00
|
|
|
|
if offset is not None:
|
2015-07-08 15:10:08 +02:00
|
|
|
|
data['offset'] = offset
|
|
|
|
|
if limit:
|
|
|
|
|
data['limit'] = limit
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2015-07-08 15:10:08 +02:00
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2015-07-08 15:10:08 +02:00
|
|
|
|
|
2016-09-20 06:36:55 +02:00
|
|
|
|
return UserProfilePhotos.de_json(result, self)
|
2015-07-08 15:10:08 +02:00
|
|
|
|
|
2015-09-20 17:28:10 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_file(self, file_id, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to get basic info about a file and prepare it for downloading. For the
|
|
|
|
|
moment, bots can download files of up to 20MB in size. The file can then be downloaded
|
|
|
|
|
with :attr:`telegram.File.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
|
2018-02-18 16:49:52 +01:00
|
|
|
|
calling get_file again.
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Note:
|
|
|
|
|
This function may not preserve the original file name and MIME type.
|
|
|
|
|
You should save the file's MIME type and name (if available) when the File object
|
|
|
|
|
is received.
|
|
|
|
|
|
2015-09-20 17:28:10 +02:00
|
|
|
|
Args:
|
2019-09-13 21:07:56 +02:00
|
|
|
|
file_id (:obj:`str` | :class:`telegram.Animation` | :class:`telegram.Audio` | \
|
|
|
|
|
:class:`telegram.ChatPhoto` | :class:`telegram.Document` | \
|
2018-02-18 16:49:52 +01:00
|
|
|
|
:class:`telegram.PhotoSize` | :class:`telegram.Sticker` | \
|
|
|
|
|
:class:`telegram.Video` | :class:`telegram.VideoNote` | \
|
|
|
|
|
:class:`telegram.Voice`):
|
|
|
|
|
Either the file identifier or an object that has a file_id attribute
|
|
|
|
|
to get file information about.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-24 15:06:59 +02:00
|
|
|
|
|
2015-09-20 17:28:10 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.File`
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getFile'.format(self.base_url)
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
2018-02-18 16:49:52 +01:00
|
|
|
|
try:
|
|
|
|
|
file_id = file_id.file_id
|
|
|
|
|
except AttributeError:
|
|
|
|
|
pass
|
|
|
|
|
|
2015-09-20 17:28:10 +02:00
|
|
|
|
data = {'file_id': file_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
|
|
|
|
if result.get('file_path'):
|
2020-06-15 18:20:51 +02:00
|
|
|
|
result['file_path'] = '{}/{}'.format(self.base_file_url, result['file_path'])
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
2016-09-20 06:36:55 +02:00
|
|
|
|
return File.de_json(result, self)
|
2015-09-20 17:28:10 +02:00
|
|
|
|
|
2016-04-12 05:46:50 +02:00
|
|
|
|
@log
|
2017-07-01 17:08:45 +02:00
|
|
|
|
def kick_chat_member(self, chat_id, user_id, timeout=None, until_date=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Use this method to kick a user from a group or a supergroup or a channel. In the case of
|
|
|
|
|
supergroups and channels, the user will not be able to return to the group on their own
|
|
|
|
|
using invite links, etc., unless unbanned first. The bot must be an administrator in the
|
|
|
|
|
group for this to work.
|
2016-04-12 05:46:50 +02:00
|
|
|
|
|
2016-10-17 00:11:20 +02:00
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
|
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
|
|
|
|
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).
|
|
|
|
|
until_date (:obj:`int` | :obj:`datetime.datetime`, optional): Date when the user will
|
|
|
|
|
be unbanned, unix time. If user is banned for more than 366 days or less than 30
|
|
|
|
|
seconds from the current time they are considered to be banned forever.
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-24 15:06:59 +02:00
|
|
|
|
|
2016-04-12 05:46:50 +02:00
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool` On success, :obj:`True` is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/kickChatMember'.format(self.base_url)
|
2016-04-12 05:46:50 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'user_id': user_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-04-12 05:46:50 +02:00
|
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
|
if until_date is not None:
|
|
|
|
|
if isinstance(until_date, datetime):
|
|
|
|
|
until_date = to_timestamp(until_date)
|
|
|
|
|
data['until_date'] = until_date
|
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-04-12 05:46:50 +02:00
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def unban_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
|
2020-04-10 20:05:01 +02:00
|
|
|
|
"""Use this method to unban a previously kicked user in a supergroup or channel.
|
2017-09-01 08:43:08 +02:00
|
|
|
|
|
2016-10-17 00:11:20 +02:00
|
|
|
|
The user will not return to the group automatically, but will be able to join via link,
|
|
|
|
|
etc. The bot must be an administrator in the group for this to work.
|
2016-04-12 05:46:50 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
|
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-24 15:06:59 +02:00
|
|
|
|
|
2016-04-12 05:46:50 +02:00
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool` On success, :obj:`True` is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/unbanChatMember'.format(self.base_url)
|
2016-04-12 05:46:50 +02:00
|
|
|
|
|
2016-05-15 03:46:40 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'user_id': user_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-04-12 05:46:50 +02:00
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-04-12 05:46:50 +02:00
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2016-04-14 02:25:26 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def answer_callback_query(self,
|
|
|
|
|
callback_query_id,
|
|
|
|
|
text=None,
|
|
|
|
|
show_alert=False,
|
|
|
|
|
url=None,
|
|
|
|
|
cache_time=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to send answers to callback queries sent from inline keyboards. The answer
|
|
|
|
|
will be displayed to the user as a notification at the top of the chat screen or as an
|
|
|
|
|
alert.
|
|
|
|
|
Alternatively, the user can be redirected to the specified Game URL. For this option to
|
|
|
|
|
work, you must first create a game for your bot via BotFather and accept the terms.
|
|
|
|
|
Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with
|
|
|
|
|
a parameter.
|
2016-04-14 02:25:26 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
callback_query_id (:obj:`str`): Unique identifier for the query to be answered.
|
|
|
|
|
text (:obj:`str`, optional): Text of the notification. If not specified, nothing will
|
|
|
|
|
be shown to the user, 0-200 characters.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
show_alert (:obj:`bool`, optional): If :obj:`True`, an alert will be shown by the
|
|
|
|
|
client instead of a notification at the top of the chat screen. Defaults to
|
|
|
|
|
:obj:`False`.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
url (:obj:`str`, optional): URL that will be opened by the user's client. If you have
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
created a Game and accepted the conditions via
|
|
|
|
|
`@BotFather <https://t.me/BotFather>`_, specify the URL that
|
2017-07-23 22:33:08 +02:00
|
|
|
|
opens your game - note that this will only work if the query comes from a callback
|
|
|
|
|
game button. Otherwise, you may use links like t.me/your_bot?start=XXXX that open
|
|
|
|
|
your bot with a parameter.
|
|
|
|
|
cache_time (:obj:`int`, optional): The maximum amount of time in seconds that the
|
|
|
|
|
result of the callback query may be cached client-side. Defaults to 0.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-24 15:06:59 +02:00
|
|
|
|
|
2016-04-14 02:25:26 +02:00
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool` On success, :obj:`True` is returned.
|
2016-04-19 14:04:25 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url_ = '{}/answerCallbackQuery'.format(self.base_url)
|
2016-04-14 02:25:26 +02:00
|
|
|
|
|
|
|
|
|
data = {'callback_query_id': callback_query_id}
|
|
|
|
|
|
|
|
|
|
if text:
|
|
|
|
|
data['text'] = text
|
|
|
|
|
if show_alert:
|
|
|
|
|
data['show_alert'] = show_alert
|
2016-10-03 15:25:07 +02:00
|
|
|
|
if url:
|
2016-10-03 23:55:29 +02:00
|
|
|
|
data['url'] = url
|
2016-12-11 22:44:52 +01:00
|
|
|
|
if cache_time is not None:
|
|
|
|
|
data['cache_time'] = cache_time
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-04-14 02:25:26 +02:00
|
|
|
|
|
2016-10-19 12:35:50 +02:00
|
|
|
|
result = self._request.post(url_, data, timeout=timeout)
|
2016-04-14 02:25:26 +02:00
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2016-04-14 05:28:06 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def edit_message_text(self,
|
|
|
|
|
text,
|
|
|
|
|
chat_id=None,
|
|
|
|
|
message_id=None,
|
|
|
|
|
inline_message_id=None,
|
|
|
|
|
parse_mode=None,
|
|
|
|
|
disable_web_page_preview=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to edit text and game messages sent by the bot or via the bot (for inline
|
|
|
|
|
bots).
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2020-02-02 20:20:54 +01:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
|
|
|
|
|
specified. Unique identifier for the target chat or username of the target channel
|
|
|
|
|
(in the format @channelusername)
|
2017-07-23 22:33:08 +02:00
|
|
|
|
message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Identifier of the message to edit.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
|
2017-05-17 18:41:08 +02:00
|
|
|
|
specified. Identifier of the inline message.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
text (:obj:`str`): New text of the message, 1-4096 characters after entities parsing.
|
2020-02-02 20:20:54 +01:00
|
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to
|
|
|
|
|
show bold, italic, fixed-width text or inline URLs in your bot's message. See the
|
|
|
|
|
constants in :class:`telegram.ParseMode` for the available modes.
|
2018-02-18 16:11:04 +01:00
|
|
|
|
disable_web_page_preview (:obj:`bool`, optional): Disables link previews for links in
|
|
|
|
|
this message.
|
2020-02-02 20:20:54 +01:00
|
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): A JSON-serialized
|
|
|
|
|
object for an inline keyboard.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-24 15:06:59 +02:00
|
|
|
|
|
2016-04-14 05:28:06 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
edited Message is returned, otherwise :obj:`True` is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/editMessageText'.format(self.base_url)
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
2016-04-16 20:57:50 +02:00
|
|
|
|
data = {'text': text}
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
|
|
|
|
if chat_id:
|
|
|
|
|
data['chat_id'] = chat_id
|
|
|
|
|
if message_id:
|
|
|
|
|
data['message_id'] = message_id
|
|
|
|
|
if inline_message_id:
|
|
|
|
|
data['inline_message_id'] = inline_message_id
|
2016-04-19 14:04:25 +02:00
|
|
|
|
if parse_mode:
|
2016-04-16 20:57:50 +02:00
|
|
|
|
data['parse_mode'] = parse_mode
|
2016-04-19 14:04:25 +02:00
|
|
|
|
if disable_web_page_preview:
|
2016-04-16 20:57:50 +02:00
|
|
|
|
data['disable_web_page_preview'] = disable_web_page_preview
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, reply_markup=reply_markup, **kwargs)
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def edit_message_caption(self,
|
|
|
|
|
chat_id=None,
|
|
|
|
|
message_id=None,
|
|
|
|
|
inline_message_id=None,
|
|
|
|
|
caption=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode=None,
|
2017-05-07 16:09:58 +02:00
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to edit captions of messages sent by the bot or via the bot
|
|
|
|
|
(for inline bots).
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2020-02-02 20:20:54 +01:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
|
|
|
|
|
specified. Unique identifier for the target chat or username of the target channel
|
|
|
|
|
(in the format @channelusername)
|
2017-07-23 22:33:08 +02:00
|
|
|
|
message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Identifier of the message to edit.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
|
2016-10-17 00:11:20 +02:00
|
|
|
|
specified. Identifier of the inline message.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
caption (:obj:`str`, optional): New caption of the message, 0-1024 characters after
|
|
|
|
|
entities parsing.
|
2018-02-18 16:11:04 +01:00
|
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to
|
|
|
|
|
show bold, italic, fixed-width text or inline URLs in the media caption. See the
|
|
|
|
|
constants in :class:`telegram.ParseMode` for the available modes.
|
2020-02-02 20:20:54 +01:00
|
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): A JSON-serialized
|
|
|
|
|
object for an inline keyboard.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
edited Message is returned, otherwise :obj:`True` is returned.
|
2016-04-19 14:04:25 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2016-10-17 00:09:44 +02:00
|
|
|
|
if inline_message_id is None and (chat_id is None or message_id is None):
|
2017-08-07 23:13:32 +02:00
|
|
|
|
raise ValueError(
|
|
|
|
|
'edit_message_caption: Both chat_id and message_id are required when '
|
2016-10-17 00:09:44 +02:00
|
|
|
|
'inline_message_id is not specified')
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/editMessageCaption'.format(self.base_url)
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
2016-04-19 14:04:25 +02:00
|
|
|
|
data = {}
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
2016-04-19 14:04:25 +02:00
|
|
|
|
if caption:
|
|
|
|
|
data['caption'] = caption
|
2018-02-18 16:11:04 +01:00
|
|
|
|
if parse_mode:
|
|
|
|
|
data['parse_mode'] = parse_mode
|
2016-04-14 05:28:06 +02:00
|
|
|
|
if chat_id:
|
|
|
|
|
data['chat_id'] = chat_id
|
|
|
|
|
if message_id:
|
|
|
|
|
data['message_id'] = message_id
|
|
|
|
|
if inline_message_id:
|
|
|
|
|
data['inline_message_id'] = inline_message_id
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, reply_markup=reply_markup, **kwargs)
|
2016-04-14 05:28:06 +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
|
|
|
|
@log
|
|
|
|
|
def edit_message_media(self,
|
|
|
|
|
chat_id=None,
|
|
|
|
|
message_id=None,
|
|
|
|
|
inline_message_id=None,
|
|
|
|
|
media=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2020-04-10 20:05:01 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to edit animation, audio, document, photo, or video messages. If a
|
|
|
|
|
message is a part of a message album, then it can be edited only to a photo or a video.
|
|
|
|
|
Otherwise, message type can be changed arbitrarily. When inline message is edited,
|
|
|
|
|
new file can't be uploaded. Use previously uploaded file via its file_id or specify a 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
|
|
|
|
|
|
|
|
|
Args:
|
2020-02-02 20:20:54 +01:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
|
|
|
|
|
specified. Unique identifier for the target chat or username of the target channel
|
|
|
|
|
(in the format @channelusername).
|
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
|
|
|
|
message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Identifier of the message to edit.
|
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
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
|
|
|
|
|
specified. Identifier of the inline message.
|
|
|
|
|
media (:class:`telegram.InputMedia`): An object for a new media content
|
|
|
|
|
of the message.
|
2020-02-02 20:20:54 +01:00
|
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): A JSON-serialized
|
|
|
|
|
object for an inline keyboard.
|
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
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
edited Message is returned, otherwise :obj:`True` is returned.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
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 inline_message_id is None and (chat_id is None or message_id is None):
|
|
|
|
|
raise ValueError(
|
2020-03-28 12:01:06 +01:00
|
|
|
|
'edit_message_media: Both chat_id and message_id are required when '
|
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
|
|
|
|
'inline_message_id is not specified')
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/editMessageMedia'.format(self.base_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
|
|
|
|
|
|
|
|
|
data = {'media': media}
|
|
|
|
|
|
|
|
|
|
if chat_id:
|
|
|
|
|
data['chat_id'] = chat_id
|
|
|
|
|
if message_id:
|
|
|
|
|
data['message_id'] = message_id
|
|
|
|
|
if inline_message_id:
|
|
|
|
|
data['inline_message_id'] = inline_message_id
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, reply_markup=reply_markup, **kwargs)
|
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
|
|
|
|
|
2016-04-14 05:28:06 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def edit_message_reply_markup(self,
|
|
|
|
|
chat_id=None,
|
|
|
|
|
message_id=None,
|
|
|
|
|
inline_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to edit only the reply markup of messages sent by the bot or via the bot
|
2016-10-17 00:11:20 +02:00
|
|
|
|
(for inline bots).
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2020-02-02 20:20:54 +01:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
|
|
|
|
|
specified. Unique identifier for the target chat or username of the target channel
|
|
|
|
|
(in the format @channelusername).
|
2017-07-23 22:33:08 +02:00
|
|
|
|
message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Identifier of the message to edit.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
|
2016-10-17 00:11:20 +02:00
|
|
|
|
specified. Identifier of the inline message.
|
2020-02-02 20:20:54 +01:00
|
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): A JSON-serialized
|
|
|
|
|
object for an inline keyboard.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
edited Message is returned, otherwise :obj:`True` is returned.
|
2016-04-19 14:04:25 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2016-10-17 00:09:44 +02:00
|
|
|
|
if inline_message_id is None and (chat_id is None or message_id is None):
|
2017-08-07 23:13:32 +02:00
|
|
|
|
raise ValueError(
|
|
|
|
|
'edit_message_reply_markup: Both chat_id and message_id are required when '
|
2016-10-17 00:09:44 +02:00
|
|
|
|
'inline_message_id is not specified')
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/editMessageReplyMarkup'.format(self.base_url)
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
2016-04-19 14:04:25 +02:00
|
|
|
|
data = {}
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
|
|
|
|
if chat_id:
|
|
|
|
|
data['chat_id'] = chat_id
|
|
|
|
|
if message_id:
|
|
|
|
|
data['message_id'] = message_id
|
|
|
|
|
if inline_message_id:
|
|
|
|
|
data['inline_message_id'] = inline_message_id
|
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, reply_markup=reply_markup, **kwargs)
|
2016-04-14 05:28:06 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_updates(self,
|
|
|
|
|
offset=None,
|
|
|
|
|
limit=100,
|
|
|
|
|
timeout=0,
|
|
|
|
|
read_latency=2.,
|
|
|
|
|
allowed_updates=None,
|
|
|
|
|
**kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to receive incoming updates using long polling.
|
2015-07-08 14:22:31 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
offset (:obj:`int`, optional): Identifier of the first update to be returned. Must be
|
|
|
|
|
greater by one than the highest among the identifiers of previously received
|
|
|
|
|
updates. By default, updates starting with the earliest unconfirmed update are
|
|
|
|
|
returned. An update is considered confirmed as soon as getUpdates is called with an
|
|
|
|
|
offset higher than its update_id. The negative offset can be specified to retrieve
|
|
|
|
|
updates starting from -offset update from the end of the updates queue. All
|
|
|
|
|
previous updates will forgotten.
|
|
|
|
|
limit (:obj:`int`, optional): Limits the number of updates to be retrieved. Values
|
|
|
|
|
between 1-100 are accepted. Defaults to 100.
|
|
|
|
|
timeout (:obj:`int`, optional): Timeout in seconds for long polling. Defaults to 0,
|
|
|
|
|
i.e. usual short polling. Should be positive, short polling should be used for
|
|
|
|
|
testing purposes only.
|
2020-02-02 20:20:54 +01:00
|
|
|
|
allowed_updates (List[:obj:`str`]), optional): A JSON-serialized list the types of
|
|
|
|
|
updates you want your bot to receive. For example, specify ["message",
|
|
|
|
|
"edited_channel_post", "callback_query"] to only receive updates of these types.
|
|
|
|
|
See :class:`telegram.Update` for a complete list of available update types.
|
2016-12-14 00:50:34 +01:00
|
|
|
|
Specify an empty list to receive all updates regardless of type (default). If not
|
2017-07-23 22:33:08 +02:00
|
|
|
|
specified, the previous setting will be used. Please note that this parameter
|
|
|
|
|
doesn't affect updates created before the call to the get_updates, so unwanted
|
|
|
|
|
updates may be received for a short period of time.
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2015-07-08 21:58:18 +02:00
|
|
|
|
|
2020-04-25 12:34:13 +02:00
|
|
|
|
Note:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
1. This method will not work if an outgoing webhook is set up.
|
|
|
|
|
2. In order to avoid getting duplicate updates, recalculate offset after each
|
|
|
|
|
server response.
|
|
|
|
|
3. To take full advantage of this library take a look at :class:`telegram.ext.Updater`
|
2017-01-06 22:48:34 +01:00
|
|
|
|
|
2015-07-08 14:22:31 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
List[:class:`telegram.Update`]
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getUpdates'.format(self.base_url)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2016-04-27 23:31:36 +02:00
|
|
|
|
data = {'timeout': timeout}
|
2016-04-19 14:04:25 +02:00
|
|
|
|
|
2015-07-07 21:50:36 +02:00
|
|
|
|
if offset:
|
|
|
|
|
data['offset'] = offset
|
|
|
|
|
if limit:
|
|
|
|
|
data['limit'] = limit
|
2016-12-14 00:50:34 +01:00
|
|
|
|
if allowed_updates is not None:
|
|
|
|
|
data['allowed_updates'] = allowed_updates
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2017-01-06 22:48:34 +01:00
|
|
|
|
# Ideally we'd use an aggressive read timeout for the polling. However,
|
|
|
|
|
# * Short polling should return within 2 seconds.
|
|
|
|
|
# * Long polling poses a different problem: the connection might have been dropped while
|
|
|
|
|
# waiting for the server to return and there's no way of knowing the connection had been
|
|
|
|
|
# dropped in real time.
|
|
|
|
|
result = self._request.post(url, data, timeout=float(read_latency) + float(timeout))
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2015-09-05 16:55:55 +02:00
|
|
|
|
if result:
|
2016-05-15 03:46:40 +02:00
|
|
|
|
self.logger.debug('Getting updates: %s', [u['update_id'] for u in result])
|
2015-07-20 13:59:41 +02:00
|
|
|
|
else:
|
2016-01-31 10:32:34 +01:00
|
|
|
|
self.logger.debug('No new updates found.')
|
2015-07-20 13:59:41 +02:00
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
if self.defaults:
|
|
|
|
|
for u in result:
|
|
|
|
|
u['default_quote'] = self.defaults.quote
|
|
|
|
|
|
2016-09-20 06:36:55 +02:00
|
|
|
|
return [Update.de_json(u, self) for u in result]
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def set_webhook(self,
|
|
|
|
|
url=None,
|
|
|
|
|
certificate=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
max_connections=40,
|
|
|
|
|
allowed_updates=None,
|
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to specify a url and receive incoming updates via an outgoing webhook.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Whenever there is an update for the bot, Telegram will send an HTTPS POST request to the
|
2017-07-23 22:33:08 +02:00
|
|
|
|
specified url, containing a JSON-serialized Update. In case of an unsuccessful request,
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Telegram will give up after a reasonable amount of attempts.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2020-04-10 20:05:01 +02:00
|
|
|
|
If you'd like to make sure that the Webhook request comes from Telegram, Telegram
|
|
|
|
|
recommends using a secret path in the URL, e.g. https://www.example.com/<token>. Since
|
|
|
|
|
nobody else knows your bot's token, you can be pretty sure it's us.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
The certificate argument should be a file from disk ``open(filename, 'rb')``.
|
2015-07-09 18:19:58 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
url (:obj:`str`): HTTPS url to send updates to. Use an empty string to remove webhook
|
2017-05-17 18:41:08 +02:00
|
|
|
|
integration.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
certificate (:obj:`filelike`): Upload your public key certificate so that the root
|
|
|
|
|
certificate in use can be checked. See our self-signed guide for details.
|
|
|
|
|
(https://goo.gl/rw7w6Y)
|
|
|
|
|
max_connections (:obj:`int`, optional): Maximum allowed number of simultaneous HTTPS
|
2016-12-14 00:50:34 +01:00
|
|
|
|
connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower
|
|
|
|
|
values to limit the load on your bot's server, and higher values to increase your
|
|
|
|
|
bot's throughput.
|
2020-02-02 20:20:54 +01:00
|
|
|
|
allowed_updates (List[:obj:`str`], optional): A JSON-serialized list the types of
|
|
|
|
|
updates you want your bot to receive. For example, specify ["message",
|
|
|
|
|
"edited_channel_post", "callback_query"] to only receive updates of these types.
|
|
|
|
|
See :class:`telegram.Update` for a complete list of available update types.
|
|
|
|
|
Specify an empty list to receive all updates regardless of type (default). If not
|
|
|
|
|
specified, the previous setting will be used. Please note that this parameter
|
|
|
|
|
doesn't affect updates created before the call to the set_webhook, so unwanted
|
|
|
|
|
updates may be received for a short period of time.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
1. You will not be able to receive updates using get_updates for as long as an outgoing
|
|
|
|
|
webhook is set up.
|
|
|
|
|
2. To use a self-signed certificate, you need to upload your public key certificate
|
|
|
|
|
using certificate parameter. Please upload as InputFile, sending a String will not
|
|
|
|
|
work.
|
|
|
|
|
3. Ports currently supported for Webhooks: 443, 80, 88, 8443.
|
2016-04-24 15:06:59 +02:00
|
|
|
|
|
2020-02-02 20:20:54 +01:00
|
|
|
|
If you're having any trouble setting up webhooks, please check out this `guide to
|
|
|
|
|
Webhooks`_.
|
|
|
|
|
|
2015-07-09 18:19:58 +02:00
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool` On success, :obj:`True` is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2020-02-02 20:20:54 +01:00
|
|
|
|
.. _`guide to Webhooks`: https://core.telegram.org/bots/webhooks
|
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url_ = '{}/setWebhook'.format(self.base_url)
|
2016-12-14 00:50:34 +01:00
|
|
|
|
|
|
|
|
|
# Backwards-compatibility: 'url' used to be named 'webhook_url'
|
2017-08-11 23:58:41 +02:00
|
|
|
|
if 'webhook_url' in kwargs: # pragma: no cover
|
2016-12-14 00:50:34 +01:00
|
|
|
|
warnings.warn("The 'webhook_url' parameter has been renamed to 'url' in accordance "
|
|
|
|
|
"with the API")
|
2016-12-14 17:38:06 +01:00
|
|
|
|
|
|
|
|
|
if url is not None:
|
|
|
|
|
raise ValueError("The parameters 'url' and 'webhook_url' are mutually exclusive")
|
|
|
|
|
|
2016-12-14 00:50:34 +01:00
|
|
|
|
url = kwargs['webhook_url']
|
|
|
|
|
del kwargs['webhook_url']
|
2015-07-07 21:50:36 +02:00
|
|
|
|
|
2015-09-04 22:53:39 +02:00
|
|
|
|
data = {}
|
2016-04-19 14:04:25 +02:00
|
|
|
|
|
2016-12-14 00:50:34 +01:00
|
|
|
|
if url is not None:
|
|
|
|
|
data['url'] = url
|
2015-09-04 22:53:39 +02:00
|
|
|
|
if certificate:
|
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 InputFile.is_file(certificate):
|
|
|
|
|
certificate = InputFile(certificate)
|
2015-09-04 22:53:39 +02:00
|
|
|
|
data['certificate'] = certificate
|
2016-12-14 00:50:34 +01:00
|
|
|
|
if max_connections is not None:
|
|
|
|
|
data['max_connections'] = max_connections
|
|
|
|
|
if allowed_updates is not None:
|
|
|
|
|
data['allowed_updates'] = allowed_updates
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-12-14 00:50:34 +01:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url_, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def delete_webhook(self, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to remove webhook integration if you decide to switch back to
|
|
|
|
|
getUpdates. Requires no parameters.
|
2016-12-14 00:50:34 +01:00
|
|
|
|
|
|
|
|
|
Args:
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-12-14 00:50:34 +01:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool` On success, :obj:`True` is returned.
|
2016-12-14 00:50:34 +01:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/deleteWebhook'.format(self.base_url)
|
2016-12-14 00:50:34 +01:00
|
|
|
|
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data = kwargs
|
2015-07-09 18:19:58 +02:00
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2015-07-09 18:19:58 +02:00
|
|
|
|
|
2015-09-05 16:55:55 +02:00
|
|
|
|
return result
|
2015-07-20 12:53:58 +02:00
|
|
|
|
|
2016-05-24 01:22:31 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def leave_chat(self, chat_id, timeout=None, **kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method for your bot to leave a group, supergroup or channel.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool` On success, :obj:`True` is returned.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/leaveChat'.format(self.base_url)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_chat(self, chat_id, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to get up to date information about the chat (current name of the user for
|
|
|
|
|
one-on-one conversations, current username of a user, group or channel, etc.).
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Chat`
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getChat'.format(self.base_url)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
|
if self.defaults:
|
|
|
|
|
result['default_quote'] = self.defaults.quote
|
|
|
|
|
|
2016-09-20 06:36:55 +02:00
|
|
|
|
return Chat.de_json(result, self)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_chat_administrators(self, chat_id, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Use this method to get a list of administrators in a chat.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
List[:class:`telegram.ChatMember`]: On success, returns a list of ``ChatMember``
|
|
|
|
|
objects that contains information about all chat administrators except
|
|
|
|
|
other bots. If the chat is a group or a supergroup and no administrators were
|
|
|
|
|
appointed, only the creator will be returned.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getChatAdministrators'.format(self.base_url)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
2016-09-20 06:36:55 +02:00
|
|
|
|
return [ChatMember.de_json(x, self) for x in result]
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_chat_members_count(self, chat_id, timeout=None, **kwargs):
|
2020-04-10 20:05:01 +02:00
|
|
|
|
"""Use this method to get the number of members in a chat.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
:obj:`int`: Number of members in the chat.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getChatMembersCount'.format(self.base_url)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to get information about a member of a chat.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-23 22:33:08 +02:00
|
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.ChatMember`
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getChatMember'.format(self.base_url)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'user_id': user_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
2016-10-16 15:54:48 +02:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
2016-09-20 06:36:55 +02:00
|
|
|
|
return ChatMember.de_json(result, self)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
2017-10-14 20:03:02 +02:00
|
|
|
|
@log
|
|
|
|
|
def set_chat_sticker_set(self, chat_id, sticker_set_name, timeout=None, **kwargs):
|
|
|
|
|
"""Use this method to set a new group sticker set for a supergroup.
|
|
|
|
|
The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
|
|
|
admin rights. Use the field :attr:`telegram.Chat.can_set_sticker_set` optionally returned
|
|
|
|
|
in :attr:`get_chat` requests to check if the bot can use this method.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target supergroup (in the format @supergroupusername).
|
|
|
|
|
sticker_set_name (:obj:`str`): Name of the sticker set to be set as the group
|
|
|
|
|
sticker set.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
"""
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/setChatStickerSet'.format(self.base_url)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'sticker_set_name': sticker_set_name}
|
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def delete_chat_sticker_set(self, chat_id, timeout=None, **kwargs):
|
|
|
|
|
"""Use this method to delete a group sticker set from a supergroup. The bot must be an
|
|
|
|
|
administrator in the chat for this to work and must have the appropriate admin rights.
|
|
|
|
|
Use the field :attr:`telegram.Chat.can_set_sticker_set` optionally returned in
|
|
|
|
|
:attr:`get_chat` requests to check if the bot can use this method.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target supergroup (in the format @supergroupusername).
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
"""
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/deleteChatStickerSet'.format(self.base_url)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id}
|
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_webhook_info(self, timeout=None, **kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to get current webhook status. Requires no parameters.
|
|
|
|
|
|
2016-10-03 19:43:10 +02:00
|
|
|
|
If the bot is using getUpdates, will return an object with the url field empty.
|
|
|
|
|
|
2017-01-06 22:48:34 +01:00
|
|
|
|
Args:
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2017-01-06 22:48:34 +01:00
|
|
|
|
|
2016-10-03 19:43:10 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.WebhookInfo`
|
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getWebhookInfo'.format(self.base_url)
|
2016-10-03 15:16:43 +02:00
|
|
|
|
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data = kwargs
|
2016-10-03 15:16:43 +02:00
|
|
|
|
|
2017-01-06 22:48:34 +01:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-10-03 15:16:43 +02:00
|
|
|
|
|
|
|
|
|
return WebhookInfo.de_json(result, self)
|
|
|
|
|
|
2017-06-18 12:14:24 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def set_game_score(self,
|
|
|
|
|
user_id,
|
|
|
|
|
score,
|
|
|
|
|
chat_id=None,
|
|
|
|
|
message_id=None,
|
|
|
|
|
inline_message_id=None,
|
|
|
|
|
force=None,
|
|
|
|
|
disable_edit_message=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Use this method to set the score of the specified user in a game.
|
2016-10-04 00:50:46 +02:00
|
|
|
|
|
2016-12-11 22:44:52 +01:00
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
user_id (:obj:`int`): User identifier.
|
|
|
|
|
score (:obj:`int`): New score, must be non-negative.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
force (:obj:`bool`, optional): Pass :obj:`True`, if the high score is allowed to
|
|
|
|
|
decrease. This can be useful when fixing mistakes or banning cheaters.
|
|
|
|
|
disable_edit_message (:obj:`bool`, optional): Pass :obj:`True`, if the game message
|
|
|
|
|
should not be automatically edited to include the current scoreboard.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
|
|
|
|
|
specified. Unique identifier for the target chat.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
|
|
|
|
|
Identifier of the sent message.
|
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
|
2016-12-11 22:44:52 +01:00
|
|
|
|
specified. Identifier of the inline message.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2016-12-11 22:44:52 +01:00
|
|
|
|
|
2016-10-04 00:50:46 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: The edited message, or if the message wasn't sent by the bot
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
, :obj:`True`.
|
2016-10-04 00:50:46 +02:00
|
|
|
|
|
2017-07-23 22:33:08 +02:00
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`: If the new score is not greater than the user's
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
current score in the chat and force is :obj:`False`.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/setGameScore'.format(self.base_url)
|
2016-10-03 20:43:02 +02:00
|
|
|
|
|
|
|
|
|
data = {'user_id': user_id, 'score': score}
|
|
|
|
|
|
|
|
|
|
if chat_id:
|
|
|
|
|
data['chat_id'] = chat_id
|
|
|
|
|
if message_id:
|
2016-10-04 00:50:46 +02:00
|
|
|
|
data['message_id'] = message_id
|
2016-10-03 20:43:02 +02:00
|
|
|
|
if inline_message_id:
|
2016-10-04 00:50:46 +02:00
|
|
|
|
data['inline_message_id'] = inline_message_id
|
2016-12-11 22:44:52 +01:00
|
|
|
|
if force is not None:
|
|
|
|
|
data['force'] = force
|
|
|
|
|
if disable_edit_message is not None:
|
|
|
|
|
data['disable_edit_message'] = disable_edit_message
|
2016-10-03 20:43:02 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, **kwargs)
|
2016-10-03 20:43:02 +02:00
|
|
|
|
|
2017-06-18 12:14:24 +02:00
|
|
|
|
@log
|
2017-05-07 16:09:58 +02:00
|
|
|
|
def get_game_high_scores(self,
|
|
|
|
|
user_id,
|
|
|
|
|
chat_id=None,
|
|
|
|
|
message_id=None,
|
|
|
|
|
inline_message_id=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to get data for high score tables. Will return the score of the specified
|
2020-04-10 20:05:01 +02:00
|
|
|
|
user and several of his neighbors in a game.
|
2016-10-04 00:57:19 +02:00
|
|
|
|
|
2017-01-06 22:48:34 +01:00
|
|
|
|
Args:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
user_id (:obj:`int`): Target user id.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
|
|
|
|
|
specified. Unique identifier for the target chat.
|
|
|
|
|
message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
|
|
|
|
|
Identifier of the sent message.
|
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
|
2017-05-17 18:41:08 +02:00
|
|
|
|
specified. Identifier of the inline message.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2017-01-06 22:48:34 +01:00
|
|
|
|
|
2016-10-04 00:57:19 +02:00
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
List[:class:`telegram.GameHighScore`]
|
2016-10-04 00:57:19 +02:00
|
|
|
|
|
2017-07-23 22:33:08 +02:00
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getGameHighScores'.format(self.base_url)
|
2016-10-03 20:43:02 +02:00
|
|
|
|
|
|
|
|
|
data = {'user_id': user_id}
|
|
|
|
|
|
|
|
|
|
if chat_id:
|
|
|
|
|
data['chat_id'] = chat_id
|
|
|
|
|
if message_id:
|
2016-10-04 00:57:19 +02:00
|
|
|
|
data['message_id'] = message_id
|
2016-10-03 20:43:02 +02:00
|
|
|
|
if inline_message_id:
|
2016-10-04 00:57:19 +02:00
|
|
|
|
data['inline_message_id'] = inline_message_id
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2016-10-03 20:43:02 +02:00
|
|
|
|
|
2017-01-06 22:48:34 +01:00
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
2016-10-03 20:43:02 +02:00
|
|
|
|
|
|
|
|
|
return [GameHighScore.de_json(hs, self) for hs in result]
|
|
|
|
|
|
2017-05-19 19:46:42 +02:00
|
|
|
|
@log
|
|
|
|
|
def send_invoice(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
title,
|
|
|
|
|
description,
|
|
|
|
|
payload,
|
|
|
|
|
provider_token,
|
|
|
|
|
start_parameter,
|
|
|
|
|
currency,
|
|
|
|
|
prices,
|
|
|
|
|
photo_url=None,
|
|
|
|
|
photo_size=None,
|
|
|
|
|
photo_width=None,
|
|
|
|
|
photo_height=None,
|
|
|
|
|
need_name=None,
|
|
|
|
|
need_phone_number=None,
|
2017-05-23 10:26:04 +02:00
|
|
|
|
need_email=None,
|
2017-05-19 19:46:42 +02:00
|
|
|
|
need_shipping_address=None,
|
|
|
|
|
is_flexible=None,
|
|
|
|
|
disable_notification=False,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
2017-12-08 22:38:59 +01:00
|
|
|
|
provider_data=None,
|
2018-02-10 16:54:09 +01:00
|
|
|
|
send_phone_number_to_provider=None,
|
|
|
|
|
send_email_to_provider=None,
|
2017-05-19 19:46:42 +02:00
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to send invoices.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target private chat.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
title (:obj:`str`): Product name, 1-32 characters.
|
|
|
|
|
description (:obj:`str`): Product description, 1-255 characters.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
payload (:obj:`str`): Bot-defined invoice payload, 1-128 bytes. This will not be
|
|
|
|
|
displayed to the user, use for your internal processes.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
provider_token (:obj:`str`): Payments provider token, obtained via
|
|
|
|
|
`@BotFather <https://t.me/BotFather>`_.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
start_parameter (:obj:`str`): Unique deep-linking parameter that can be used to
|
|
|
|
|
generate this invoice when used as a start parameter.
|
|
|
|
|
currency (:obj:`str`): Three-letter ISO 4217 currency code.
|
2020-02-02 20:20:54 +01:00
|
|
|
|
prices (List[:class:`telegram.LabeledPrice`)]: Price breakdown, a JSON-serialized list
|
|
|
|
|
of components (e.g. product price, tax, discount, delivery cost, delivery tax,
|
|
|
|
|
bonus, etc.).
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
provider_data (:obj:`str` | :obj:`object`, optional): JSON-serialized data about the
|
2017-12-08 22:38:59 +01:00
|
|
|
|
invoice, which will be shared with the payment provider. A detailed description of
|
|
|
|
|
required fields should be provided by the payment provider. When an object is
|
|
|
|
|
passed, it will be encoded as JSON.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
photo_url (:obj:`str`, optional): URL of the product photo for the invoice. Can be a
|
|
|
|
|
photo of the goods or a marketing image for a service. People like it better when
|
|
|
|
|
they see what they are paying for.
|
|
|
|
|
photo_size (:obj:`str`, optional): Photo size.
|
|
|
|
|
photo_width (:obj:`int`, optional): Photo width.
|
|
|
|
|
photo_height (:obj:`int`, optional): Photo height.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
need_name (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's full
|
|
|
|
|
name to complete the order.
|
|
|
|
|
need_phone_number (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's
|
2017-07-23 22:33:08 +02:00
|
|
|
|
phone number to complete the order.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
need_email (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's email
|
|
|
|
|
to complete the order.
|
|
|
|
|
need_shipping_address (:obj:`bool`, optional): Pass :obj:`True`, if you require the
|
|
|
|
|
user's shipping address to complete the order.
|
|
|
|
|
send_phone_number_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's
|
|
|
|
|
phone number should be sent to provider.
|
|
|
|
|
send_email_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's email
|
|
|
|
|
address should be sent to provider.
|
|
|
|
|
is_flexible (:obj:`bool`, optional): Pass :obj:`True`, if the final price depends on
|
|
|
|
|
the shipping method.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): A JSON-serialized
|
|
|
|
|
object for an inline keyboard. If empty, one 'Pay total price' button will be
|
|
|
|
|
shown. If not empty, the first button must be a Pay button.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendInvoice'.format(self.base_url)
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
|
'chat_id': chat_id,
|
|
|
|
|
'title': title,
|
|
|
|
|
'description': description,
|
|
|
|
|
'payload': payload,
|
|
|
|
|
'provider_token': provider_token,
|
|
|
|
|
'start_parameter': start_parameter,
|
|
|
|
|
'currency': currency,
|
2017-05-20 18:46:39 +02:00
|
|
|
|
'prices': [p.to_dict() for p in prices]
|
2017-05-19 19:46:42 +02:00
|
|
|
|
}
|
2017-12-08 22:38:59 +01:00
|
|
|
|
if provider_data is not None:
|
2020-06-15 18:20:51 +02:00
|
|
|
|
if isinstance(provider_data, str):
|
2017-12-08 22:38:59 +01:00
|
|
|
|
data['provider_data'] = provider_data
|
|
|
|
|
else:
|
|
|
|
|
data['provider_data'] = json.dumps(provider_data)
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if photo_url is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['photo_url'] = photo_url
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if photo_size is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['photo_size'] = photo_size
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if photo_width is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['photo_width'] = photo_width
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if photo_height is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['photo_height'] = photo_height
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if need_name is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['need_name'] = need_name
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if need_phone_number is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['need_phone_number'] = need_phone_number
|
2017-06-08 03:47:19 +02:00
|
|
|
|
if need_email is not None:
|
2017-05-23 10:21:45 +02:00
|
|
|
|
data['need_email'] = need_email
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if need_shipping_address is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['need_shipping_address'] = need_shipping_address
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if is_flexible is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['is_flexible'] = is_flexible
|
2018-02-10 16:54:09 +01:00
|
|
|
|
if send_phone_number_to_provider is not None:
|
|
|
|
|
data['send_phone_number_to_provider'] = send_email_to_provider
|
|
|
|
|
if send_email_to_provider is not None:
|
|
|
|
|
data['send_email_to_provider'] = send_email_to_provider
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
2017-06-18 12:14:24 +02:00
|
|
|
|
@log
|
2017-05-19 19:46:42 +02:00
|
|
|
|
def answer_shipping_query(self,
|
|
|
|
|
shipping_query_id,
|
|
|
|
|
ok,
|
|
|
|
|
shipping_options=None,
|
2017-05-22 15:37:15 +02:00
|
|
|
|
error_message=None,
|
2017-05-22 16:55:19 +02:00
|
|
|
|
timeout=None,
|
2017-05-22 15:37:15 +02:00
|
|
|
|
**kwargs):
|
2017-05-19 19:46:42 +02:00
|
|
|
|
"""
|
|
|
|
|
If you sent an invoice requesting a shipping address and the parameter is_flexible was
|
|
|
|
|
specified, the Bot API will send an Update with a shipping_query field to the bot. Use
|
|
|
|
|
this method to reply to shipping queries.
|
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
shipping_query_id (:obj:`str`): Unique identifier for the query to be answered.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
ok (:obj:`bool`): Specify :obj:`True` if delivery to the specified address is possible
|
|
|
|
|
and :obj:`False` if there are any problems (for example, if delivery to the
|
|
|
|
|
specified address is not possible).
|
2017-07-23 22:33:08 +02:00
|
|
|
|
shipping_options (List[:class:`telegram.ShippingOption`]), optional]: Required if ok is
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`True`. A JSON-serialized array of available shipping options.
|
|
|
|
|
error_message (:obj:`str`, optional): Required if ok is :obj:`False`. Error message in
|
2017-07-23 22:33:08 +02:00
|
|
|
|
human readable form that explains why it is impossible to complete the order (e.g.
|
|
|
|
|
"Sorry, delivery to your desired address is unavailable"). Telegram will display
|
|
|
|
|
this message to the user.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-05-22 16:47:35 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2017-06-18 12:09:32 +02:00
|
|
|
|
ok = bool(ok)
|
|
|
|
|
|
|
|
|
|
if ok and (shipping_options is None or error_message is not None):
|
2017-05-22 16:47:35 +02:00
|
|
|
|
raise TelegramError(
|
|
|
|
|
'answerShippingQuery: If ok is True, shipping_options '
|
|
|
|
|
'should not be empty and there should not be error_message')
|
|
|
|
|
|
2017-06-18 12:09:32 +02:00
|
|
|
|
if not ok and (shipping_options is not None or error_message is None):
|
2017-05-22 16:47:35 +02:00
|
|
|
|
raise TelegramError(
|
|
|
|
|
'answerShippingQuery: If ok is False, error_message '
|
|
|
|
|
'should not be empty and there should not be shipping_options')
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url_ = '{}/answerShippingQuery'.format(self.base_url)
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
data = {'shipping_query_id': shipping_query_id, 'ok': ok}
|
|
|
|
|
|
2017-06-18 12:09:32 +02:00
|
|
|
|
if ok:
|
2017-06-10 21:45:48 +02:00
|
|
|
|
data['shipping_options'] = [option.to_dict() for option in shipping_options]
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if error_message is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['error_message'] = error_message
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
2017-05-22 16:55:19 +02:00
|
|
|
|
result = self._request.post(url_, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
2017-06-18 12:14:24 +02:00
|
|
|
|
@log
|
2017-05-22 15:37:15 +02:00
|
|
|
|
def answer_pre_checkout_query(self, pre_checkout_query_id, ok,
|
2017-05-22 16:55:19 +02:00
|
|
|
|
error_message=None, timeout=None, **kwargs):
|
2017-05-19 19:46:42 +02:00
|
|
|
|
"""
|
2017-07-23 22:33:08 +02:00
|
|
|
|
Once the user has confirmed their payment and shipping details, the Bot API sends the final
|
|
|
|
|
confirmation in the form of an Update with the field pre_checkout_query. Use this method to
|
|
|
|
|
respond to such pre-checkout queries.
|
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
The Bot API must receive an answer within 10 seconds after the pre-checkout
|
|
|
|
|
query was sent.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
pre_checkout_query_id (:obj:`str`): Unique identifier for the query to be answered.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
ok (:obj:`bool`): Specify :obj:`True` if everything is alright
|
|
|
|
|
(goods are available, etc.) and the bot is ready to proceed with the order. Use
|
|
|
|
|
:obj:`False` if there are any problems.
|
|
|
|
|
error_message (:obj:`str`, optional): Required if ok is :obj:`False`. Error message
|
|
|
|
|
in human readable form that explains the reason for failure to proceed with
|
|
|
|
|
the checkout (e.g. "Sorry, somebody just bought the last of our amazing black
|
|
|
|
|
T-shirts while you were busy filling out your payment details. Please choose a
|
|
|
|
|
different color or garment!"). Telegram will display this message to the user.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-05-22 16:47:35 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2017-06-18 12:09:32 +02:00
|
|
|
|
ok = bool(ok)
|
|
|
|
|
|
2017-06-10 21:45:48 +02:00
|
|
|
|
if not (ok ^ (error_message is not None)):
|
2017-05-22 16:47:35 +02:00
|
|
|
|
raise TelegramError(
|
|
|
|
|
'answerPreCheckoutQuery: If ok is True, there should '
|
|
|
|
|
'not be error_message; if ok is False, error_message '
|
|
|
|
|
'should not be empty')
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url_ = '{}/answerPreCheckoutQuery'.format(self.base_url)
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
|
|
data = {'pre_checkout_query_id': pre_checkout_query_id, 'ok': ok}
|
|
|
|
|
|
2017-05-26 19:02:18 +02:00
|
|
|
|
if error_message is not None:
|
2017-05-19 19:46:42 +02:00
|
|
|
|
data['error_message'] = error_message
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
2017-05-22 16:55:19 +02:00
|
|
|
|
result = self._request.post(url_, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
|
@log
|
2019-09-06 21:41:43 +02:00
|
|
|
|
def restrict_chat_member(self, chat_id, user_id, permissions, until_date=None,
|
|
|
|
|
timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to restrict a user in a supergroup. The bot must be an administrator in
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
the supergroup for this to work and must have the appropriate admin rights. Pass
|
|
|
|
|
:obj:`True` for all boolean parameters to lift restrictions from a user.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
2019-09-06 21:41:43 +02:00
|
|
|
|
Note:
|
|
|
|
|
Since Bot API 4.4, :attr:`restrict_chat_member` takes the new user permissions in a
|
|
|
|
|
single argument of type :class:`telegram.ChatPermissions`. The old way of passing
|
|
|
|
|
parameters will not keep working forever.
|
|
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target supergroup (in the format @supergroupusername).
|
|
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
|
|
|
|
until_date (:obj:`int` | :obj:`datetime.datetime`, optional): Date when restrictions
|
|
|
|
|
will be lifted for the user, unix time. If user is restricted for more than 366
|
|
|
|
|
days or less than 30 seconds from the current time, they are considered to be
|
|
|
|
|
restricted forever.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
permissions (:class:`telegram.ChatPermissions`): A JSON-serialized object for new user
|
|
|
|
|
permissions.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/restrictChatMember'.format(self.base_url)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
2019-09-06 21:41:43 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'user_id': user_id, 'permissions': permissions.to_dict()}
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
if until_date is not None:
|
|
|
|
|
if isinstance(until_date, datetime):
|
|
|
|
|
until_date = to_timestamp(until_date)
|
|
|
|
|
data['until_date'] = until_date
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def promote_chat_member(self, chat_id, user_id, can_change_info=None,
|
|
|
|
|
can_post_messages=None, can_edit_messages=None,
|
|
|
|
|
can_delete_messages=None, can_invite_users=None,
|
|
|
|
|
can_restrict_members=None, can_pin_messages=None,
|
|
|
|
|
can_promote_members=None, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to promote or demote a user in a supergroup or a channel. The bot must be
|
|
|
|
|
an administrator in the chat for this to work and must have the appropriate admin rights.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
Pass :obj:`False` for all boolean parameters to demote a user.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target supergroup (in the format @supergroupusername).
|
|
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
can_change_info (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
|
|
|
|
change chat title, photo and other settings.
|
|
|
|
|
can_post_messages (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
2017-07-23 22:33:08 +02:00
|
|
|
|
create channel posts, channels only.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
can_edit_messages (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
|
|
|
|
edit messages of other users, channels only.
|
|
|
|
|
can_delete_messages (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
2017-07-23 22:33:08 +02:00
|
|
|
|
delete messages of other users.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
can_invite_users (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
|
|
|
|
invite new users to the chat.
|
|
|
|
|
can_restrict_members (:obj:`bool`, optional): Pass :obj:`True`, if the administrator
|
|
|
|
|
can restrict, ban or unban chat members.
|
|
|
|
|
can_pin_messages (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
|
|
|
|
pin messages, supergroups only.
|
|
|
|
|
can_promote_members (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
|
|
|
|
add new administrators with a subset of his own privileges or demote administrators
|
2017-07-23 22:33:08 +02:00
|
|
|
|
that he has promoted, directly or indirectly (promoted by administrators that were
|
|
|
|
|
appointed by him).
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/promoteChatMember'.format(self.base_url)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'user_id': user_id}
|
|
|
|
|
|
|
|
|
|
if can_change_info is not None:
|
|
|
|
|
data['can_change_info'] = can_change_info
|
|
|
|
|
if can_post_messages is not None:
|
|
|
|
|
data['can_post_messages'] = can_post_messages
|
|
|
|
|
if can_edit_messages is not None:
|
|
|
|
|
data['can_edit_messages'] = can_edit_messages
|
|
|
|
|
if can_delete_messages is not None:
|
|
|
|
|
data['can_delete_messages'] = can_delete_messages
|
|
|
|
|
if can_invite_users is not None:
|
|
|
|
|
data['can_invite_users'] = can_invite_users
|
|
|
|
|
if can_restrict_members is not None:
|
|
|
|
|
data['can_restrict_members'] = can_restrict_members
|
|
|
|
|
if can_pin_messages is not None:
|
|
|
|
|
data['can_pin_messages'] = can_pin_messages
|
|
|
|
|
if can_promote_members is not None:
|
|
|
|
|
data['can_promote_members'] = can_promote_members
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2019-09-06 21:41:43 +02:00
|
|
|
|
@log
|
|
|
|
|
def set_chat_permissions(self, chat_id, permissions, timeout=None, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Use this method to set default chat permissions for all members. The bot must be an
|
|
|
|
|
administrator in the group or a supergroup for this to work and must have the
|
2020-04-10 20:05:01 +02:00
|
|
|
|
:attr:`can_restrict_members` admin rights.
|
2019-09-06 21:41:43 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username of
|
|
|
|
|
the target supergroup (in the format `@supergroupusername`).
|
|
|
|
|
permissions (:class:`telegram.ChatPermissions`): New default chat permissions.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2019-09-06 21:41:43 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/setChatPermissions'.format(self.base_url)
|
2019-09-06 21:41:43 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'permissions': permissions.to_dict()}
|
|
|
|
|
data.update(kwargs)
|
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2020-03-28 16:37:26 +01:00
|
|
|
|
@log
|
|
|
|
|
def set_chat_administrator_custom_title(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
user_id,
|
|
|
|
|
custom_title,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Use this method to set a custom title for administrators promoted by the bot in a
|
2020-04-10 20:05:01 +02:00
|
|
|
|
supergroup. The bot must be an administrator for this to work.
|
2020-03-28 16:37:26 +01:00
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username of
|
|
|
|
|
the target supergroup (in the format `@supergroupusername`).
|
|
|
|
|
user_id (:obj:`int`): Unique identifier of the target administrator.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
custom_title (:obj:`str`) New custom title for the administrator; 0-16 characters,
|
|
|
|
|
emoji are not allowed.
|
2020-03-28 16:37:26 +01: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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2020-03-28 16:37:26 +01:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/setChatAdministratorCustomTitle'.format(self.base_url)
|
2020-03-28 16:37:26 +01:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'user_id': user_id, 'custom_title': custom_title}
|
|
|
|
|
data.update(kwargs)
|
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
|
@log
|
|
|
|
|
def export_chat_invite_link(self, chat_id, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Use this method to generate a new invite link for a chat; any previously generated link
|
|
|
|
|
is revoked. The bot must be an administrator in the chat for this to work and must have
|
|
|
|
|
the appropriate admin rights.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
:obj:`str`: New invite link on success.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/exportChatInviteLink'.format(self.base_url)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
2019-02-13 11:37:13 +01:00
|
|
|
|
def set_chat_photo(self, chat_id, photo, timeout=20, **kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to set a new profile photo for the chat.
|
|
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
|
Photos can't be changed for private chats. The bot must be an administrator in the chat
|
|
|
|
|
for this to work and must have the appropriate admin rights.
|
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
2018-03-05 12:17:56 +01:00
|
|
|
|
photo (`filelike object`): New chat photo.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/setChatPhoto'.format(self.base_url)
|
2017-07-01 17:08:45 +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
|
|
|
|
if InputFile.is_file(photo):
|
|
|
|
|
photo = InputFile(photo)
|
|
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
|
data = {'chat_id': chat_id, 'photo': photo}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def delete_chat_photo(self, chat_id, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot
|
|
|
|
|
must be an administrator in the chat for this to work and must have the appropriate admin
|
|
|
|
|
rights.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/deleteChatPhoto'.format(self.base_url)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def set_chat_title(self, chat_id, title, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to change the title of a chat. Titles can't be changed for private chats.
|
|
|
|
|
The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
|
|
|
admin rights.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-23 22:33:08 +02:00
|
|
|
|
title (:obj:`str`): New chat title, 1-255 characters.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/setChatTitle'.format(self.base_url)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'title': title}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def set_chat_description(self, chat_id, description, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
2019-09-06 21:41:43 +02:00
|
|
|
|
Use this method to change the description of a group, a supergroup or a channel. The bot
|
|
|
|
|
must be an administrator in the chat for this to work and must have the appropriate admin
|
|
|
|
|
rights.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
2020-04-10 20:05:01 +02:00
|
|
|
|
description (:obj:`str`): New chat description, 0-255 characters.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/setChatDescription'.format(self.base_url)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'description': description}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def pin_chat_message(self, chat_id, message_id, disable_notification=None, timeout=None,
|
|
|
|
|
**kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Use this method to pin a message in a group, a supergroup, or a channel.
|
|
|
|
|
The bot must be an administrator in the chat for this to work and must have the
|
|
|
|
|
‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right
|
|
|
|
|
in the channel.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
2017-07-23 22:33:08 +02:00
|
|
|
|
message_id (:obj:`int`): Identifier of a message to pin.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Pass :obj:`True`, if it is not necessary
|
|
|
|
|
to send a notification to all group members about the new pinned message.
|
|
|
|
|
Notifications are always disabled in channels.
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/pinChatMessage'.format(self.base_url)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id, 'message_id': message_id}
|
|
|
|
|
|
|
|
|
|
if disable_notification is not None:
|
|
|
|
|
data['disable_notification'] = disable_notification
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def unpin_chat_message(self, chat_id, timeout=None, **kwargs):
|
2017-07-23 22:33:08 +02:00
|
|
|
|
"""
|
2020-04-10 20:05:01 +02:00
|
|
|
|
Use this method to unpin a message in a group, a supergroup, or a channel.
|
|
|
|
|
The bot must be an administrator in the chat for this to work and must have the
|
|
|
|
|
``can_pin_messages`` admin right in the supergroup or ``can_edit_messages`` admin right
|
|
|
|
|
in the channel.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
2018-12-04 15:06:48 +01:00
|
|
|
|
of the target channel (in the format @channelusername).
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/unpinChatMessage'.format(self.base_url)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
data = {'chat_id': chat_id}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2017-07-25 00:19:09 +02:00
|
|
|
|
@log
|
2017-07-22 13:34:51 +02:00
|
|
|
|
def get_sticker_set(self, name, timeout=None, **kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to get a sticker set.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
name (:obj:`str`): Name of the sticker set.
|
2017-07-22 13:34:51 +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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:class:`telegram.StickerSet`
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getStickerSet'.format(self.base_url)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
data = {'name': name}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return StickerSet.de_json(result, self)
|
|
|
|
|
|
2017-07-25 00:19:09 +02:00
|
|
|
|
@log
|
2019-02-13 11:37:13 +01:00
|
|
|
|
def upload_sticker_file(self, user_id, png_sticker, timeout=20, **kwargs):
|
2017-07-22 13:34:51 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to upload a .png file with a sticker for later use in
|
|
|
|
|
:attr:`create_new_sticker_set` and :attr:`add_sticker_to_set` methods (can be used multiple
|
|
|
|
|
times).
|
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
The png_sticker argument can be either a file_id, an URL or a file from disk
|
|
|
|
|
``open(filename, 'rb')``
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
user_id (:obj:`int`): User identifier of sticker file owner.
|
|
|
|
|
png_sticker (:obj:`str` | `filelike object`): Png image with the sticker,
|
|
|
|
|
must be up to 512 kilobytes in size, dimensions must not exceed 512px,
|
|
|
|
|
and either width or height must be exactly 512px.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:class:`telegram.File`: On success, the uploaded File is returned.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/uploadStickerFile'.format(self.base_url)
|
2017-07-22 13:34:51 +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
|
|
|
|
if InputFile.is_file(png_sticker):
|
|
|
|
|
png_sticker = InputFile(png_sticker)
|
|
|
|
|
|
2017-07-22 13:34:51 +02:00
|
|
|
|
data = {'user_id': user_id, 'png_sticker': png_sticker}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return File.de_json(result, self)
|
|
|
|
|
|
2017-07-25 00:19:09 +02:00
|
|
|
|
@log
|
2020-04-10 19:22:45 +02:00
|
|
|
|
def create_new_sticker_set(self, user_id, name, title, emojis, png_sticker=None,
|
|
|
|
|
contains_masks=None, mask_position=None, timeout=20,
|
|
|
|
|
tgs_sticker=None, **kwargs):
|
2020-04-10 20:05:01 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to create new sticker set owned by a user.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
The bot will be able to edit the created sticker set.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
You must use exactly one of the fields png_sticker or tgs_sticker.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
|
|
Warning:
|
|
|
|
|
As of API 4.7 ``png_sticker`` is an optional argument and therefore the order of the
|
|
|
|
|
arguments had to be changed. Use keyword arguments to make sure that the arguments are
|
|
|
|
|
passed correctly.
|
|
|
|
|
|
2017-07-22 13:34:51 +02:00
|
|
|
|
Note:
|
2020-04-10 19:22:45 +02:00
|
|
|
|
The png_sticker and tgs_sticker argument can be either a file_id, an URL or a file from
|
|
|
|
|
disk ``open(filename, 'rb')``
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
user_id (:obj:`int`): User identifier of created sticker set owner.
|
|
|
|
|
name (:obj:`str`): Short name of sticker set, to be used in t.me/addstickers/ URLs
|
|
|
|
|
(e.g., animals). Can contain only english letters, digits and underscores.
|
|
|
|
|
Must begin with a letter, can't contain consecutive underscores and
|
|
|
|
|
must end in "_by_<bot username>". <bot_username> is case insensitive.
|
|
|
|
|
1-64 characters.
|
|
|
|
|
title (:obj:`str`): Sticker set title, 1-64 characters.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
png_sticker (:obj:`str` | `filelike object`, optional): Png image with the sticker,
|
|
|
|
|
must be up to 512 kilobytes in size, dimensions must not exceed 512px,
|
2017-07-22 13:34:51 +02:00
|
|
|
|
and either width or height must be exactly 512px. Pass a file_id as a String to
|
|
|
|
|
send a file that already exists on the Telegram servers, pass an HTTP URL as a
|
|
|
|
|
String for Telegram to get a file from the Internet, or upload a new one
|
|
|
|
|
using multipart/form-data.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
tgs_sticker (:obj:`str` | `filelike object`, optional): TGS animation with the sticker,
|
|
|
|
|
uploaded using multipart/form-data. See
|
|
|
|
|
https://core.telegram.org/animated_stickers#technical-requirements for technical
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
requirements.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
emojis (:obj:`str`): One or more emoji corresponding to the sticker.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
contains_masks (:obj:`bool`, optional): Pass :obj:`True`, if a set of mask stickers
|
|
|
|
|
should be created.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
mask_position (:class:`telegram.MaskPosition`, optional): Position where the mask
|
|
|
|
|
should be placed on faces.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/createNewStickerSet'.format(self.base_url)
|
2017-07-22 13:34:51 +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
|
|
|
|
if InputFile.is_file(png_sticker):
|
|
|
|
|
png_sticker = InputFile(png_sticker)
|
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
if InputFile.is_file(tgs_sticker):
|
|
|
|
|
tgs_sticker = InputFile(tgs_sticker)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
data = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis}
|
|
|
|
|
|
|
|
|
|
if png_sticker is not None:
|
|
|
|
|
data['png_sticker'] = png_sticker
|
|
|
|
|
if tgs_sticker is not None:
|
|
|
|
|
data['tgs_sticker'] = tgs_sticker
|
2017-07-23 22:33:08 +02:00
|
|
|
|
if contains_masks is not None:
|
|
|
|
|
data['contains_masks'] = contains_masks
|
2017-07-22 13:34:51 +02:00
|
|
|
|
if mask_position is not None:
|
2020-04-11 09:44:40 +02:00
|
|
|
|
# We need to_json() instead of to_dict() here, because we're sending a media
|
|
|
|
|
# message here, which isn't json dumped by utils.request
|
2020-04-10 19:22:45 +02:00
|
|
|
|
data['mask_position'] = mask_position.to_json()
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2017-07-25 00:19:09 +02:00
|
|
|
|
@log
|
2020-04-10 19:22:45 +02:00
|
|
|
|
def add_sticker_to_set(self, user_id, name, emojis, png_sticker=None, mask_position=None,
|
|
|
|
|
timeout=20, tgs_sticker=None, **kwargs):
|
2020-04-10 20:05:01 +02:00
|
|
|
|
"""
|
|
|
|
|
Use this method to add a new sticker to a set created by the bot.
|
|
|
|
|
You must use exactly one of the fields png_sticker or tgs_sticker. Animated stickers
|
|
|
|
|
can be added to animated sticker sets and only to them. Animated sticker sets can have up
|
|
|
|
|
to 50 stickers. Static sticker sets can have up to 120 stickers.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
|
|
Warning:
|
|
|
|
|
As of API 4.7 ``png_sticker`` is an optional argument and therefore the order of the
|
|
|
|
|
arguments had to be changed. Use keyword arguments to make sure that the arguments are
|
|
|
|
|
passed correctly.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Note:
|
2020-04-10 19:22:45 +02:00
|
|
|
|
The png_sticker and tgs_sticker argument can be either a file_id, an URL or a file from
|
|
|
|
|
disk ``open(filename, 'rb')``
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
user_id (:obj:`int`): User identifier of created sticker set owner.
|
|
|
|
|
name (:obj:`str`): Sticker set name.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
png_sticker (:obj:`str` | `filelike object`, optional): PNG image with the sticker,
|
2020-04-10 19:22:45 +02:00
|
|
|
|
must be up to 512 kilobytes in size, dimensions must not exceed 512px,
|
2017-07-22 13:34:51 +02:00
|
|
|
|
and either width or height must be exactly 512px. Pass a file_id as a String to
|
|
|
|
|
send a file that already exists on the Telegram servers, pass an HTTP URL as a
|
|
|
|
|
String for Telegram to get a file from the Internet, or upload a new one
|
|
|
|
|
using multipart/form-data.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
tgs_sticker (:obj:`str` | `filelike object`, optional): TGS animation with the sticker,
|
|
|
|
|
uploaded using multipart/form-data. See
|
|
|
|
|
https://core.telegram.org/animated_stickers#technical-requirements for technical
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
requirements.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
emojis (:obj:`str`): One or more emoji corresponding to the sticker.
|
|
|
|
|
mask_position (:class:`telegram.MaskPosition`, optional): Position where the mask
|
2020-04-10 20:05:01 +02:00
|
|
|
|
should be placed on faces.
|
2017-07-22 13:34:51 +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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/addStickerToSet'.format(self.base_url)
|
2017-07-22 13:34:51 +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
|
|
|
|
if InputFile.is_file(png_sticker):
|
|
|
|
|
png_sticker = InputFile(png_sticker)
|
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
if InputFile.is_file(tgs_sticker):
|
|
|
|
|
tgs_sticker = InputFile(tgs_sticker)
|
|
|
|
|
|
|
|
|
|
data = {'user_id': user_id, 'name': name, 'emojis': emojis}
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
if png_sticker is not None:
|
|
|
|
|
data['png_sticker'] = png_sticker
|
|
|
|
|
if tgs_sticker is not None:
|
|
|
|
|
data['tgs_sticker'] = tgs_sticker
|
2017-07-22 13:34:51 +02:00
|
|
|
|
if mask_position is not None:
|
2020-04-11 09:44:40 +02:00
|
|
|
|
# We need to_json() instead of to_dict() here, because we're sending a media
|
|
|
|
|
# message here, which isn't json dumped by utils.request
|
2020-04-10 19:22:45 +02:00
|
|
|
|
data['mask_position'] = mask_position.to_json()
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2017-07-25 00:19:09 +02:00
|
|
|
|
@log
|
2017-07-22 13:34:51 +02:00
|
|
|
|
def set_sticker_position_in_set(self, sticker, position, timeout=None, **kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to move a sticker in a set created by the bot to a specific position.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
sticker (:obj:`str`): File identifier of the sticker.
|
|
|
|
|
position (:obj:`int`): New sticker position in the set, zero-based.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-09-01 08:43:08 +02:00
|
|
|
|
|
2017-07-22 13:34:51 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/setStickerPositionInSet'.format(self.base_url)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
data = {'sticker': sticker, 'position': position}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2017-07-25 00:19:09 +02:00
|
|
|
|
@log
|
2017-07-22 13:34:51 +02:00
|
|
|
|
def delete_sticker_from_set(self, sticker, timeout=None, **kwargs):
|
2017-09-01 08:43:08 +02:00
|
|
|
|
"""Use this method to delete a sticker from a set created by the bot.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
sticker (:obj:`str`): File identifier of the sticker.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
2017-09-01 08:43:08 +02:00
|
|
|
|
|
2017-07-22 13:34:51 +02:00
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/deleteStickerFromSet'.format(self.base_url)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
data = {'sticker': sticker}
|
2017-07-25 00:19:09 +02:00
|
|
|
|
data.update(kwargs)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
@log
|
|
|
|
|
def set_sticker_set_thumb(self, name, user_id, thumb=None, timeout=None, **kwargs):
|
|
|
|
|
"""Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set
|
|
|
|
|
for animated sticker sets only.
|
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
The thumb can be either a file_id, an URL or a file from disk ``open(filename, 'rb')``
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
name (:obj:`str`): Sticker set name
|
|
|
|
|
user_id (:obj:`int`): User identifier of created sticker set owner.
|
|
|
|
|
thumb (:obj:`str` | `filelike object`, optional): A PNG image with the thumbnail, must
|
|
|
|
|
be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS
|
|
|
|
|
animation with the thumbnail up to 32 kilobytes in size; see
|
|
|
|
|
https://core.telegram.org/animated_stickers#technical-requirements for animated sticker
|
|
|
|
|
technical requirements. Pass a file_id as a String to send a file that already exists
|
|
|
|
|
on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
the Internet, or upload a new one using multipart/form-data. Animated sticker set
|
|
|
|
|
thumbnail can't be uploaded via HTTP URL.
|
2020-04-10 19:22:45 +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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
url = '{}/setStickerSetThumb'.format(self.base_url)
|
|
|
|
|
|
|
|
|
|
if InputFile.is_file(thumb):
|
|
|
|
|
thumb = InputFile(thumb)
|
|
|
|
|
|
|
|
|
|
data = {'name': name, 'user_id': user_id, 'thumb': thumb}
|
|
|
|
|
data.update(kwargs)
|
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
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
|
|
|
|
@log
|
|
|
|
|
def set_passport_data_errors(self, user_id, errors, timeout=None, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Informs a user that some of the Telegram Passport elements they provided contains errors.
|
|
|
|
|
The user will not be able to re-submit their Passport to you until the errors are fixed
|
2020-04-10 20:05:01 +02:00
|
|
|
|
(the contents of the field for which you returned the error must change).
|
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
|
|
|
|
|
|
|
|
|
Use this if the data submitted by the user doesn't satisfy the standards your service
|
|
|
|
|
requires for any reason. For example, if a birthday date seems invalid, a submitted
|
|
|
|
|
document is blurry, a scan shows evidence of tampering, etc. Supply some details in the
|
|
|
|
|
error message to make sure the user knows how to correct the issues.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
user_id (:obj:`int`): User identifier
|
|
|
|
|
errors (List[:class:`PassportElementError`]): A JSON-serialized array describing the
|
|
|
|
|
errors.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
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
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url_ = '{}/setPassportDataErrors'.format(self.base_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
|
|
|
|
|
|
|
|
|
data = {'user_id': user_id, 'errors': [error.to_dict() for error in errors]}
|
|
|
|
|
data.update(kwargs)
|
|
|
|
|
|
|
|
|
|
result = self._request.post(url_, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2019-08-23 21:20:41 +02:00
|
|
|
|
@log
|
|
|
|
|
def send_poll(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
question,
|
|
|
|
|
options,
|
2020-03-29 09:52:30 +02:00
|
|
|
|
is_anonymous=True,
|
|
|
|
|
type=Poll.REGULAR,
|
|
|
|
|
allows_multiple_answers=False,
|
|
|
|
|
correct_option_id=None,
|
|
|
|
|
is_closed=None,
|
2019-08-23 21:20:41 +02:00
|
|
|
|
disable_notification=None,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
2020-05-02 11:56:52 +02:00
|
|
|
|
explanation=None,
|
|
|
|
|
explanation_parse_mode=DEFAULT_NONE,
|
|
|
|
|
open_period=None,
|
|
|
|
|
close_date=None,
|
2019-08-23 21:20:41 +02:00
|
|
|
|
**kwargs):
|
|
|
|
|
"""
|
2020-03-29 09:52:30 +02:00
|
|
|
|
Use this method to send a native poll.
|
2019-08-23 21:20:41 +02:00
|
|
|
|
|
|
|
|
|
Args:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
2019-08-23 21:20:41 +02:00
|
|
|
|
question (:obj:`str`): Poll question, 1-255 characters.
|
|
|
|
|
options (List[:obj:`str`]): List of answer options, 2-10 strings 1-100 characters each.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
is_anonymous (:obj:`bool`, optional): :obj:`True`, if the poll needs to be anonymous,
|
|
|
|
|
defaults to :obj:`True`.
|
2020-03-29 09:52:30 +02:00
|
|
|
|
type (:obj:`str`, optional): Poll type, :attr:`telegram.Poll.QUIZ` or
|
|
|
|
|
:attr:`telegram.Poll.REGULAR`, defaults to :attr:`telegram.Poll.REGULAR`.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
allows_multiple_answers (:obj:`bool`, optional): :obj:`True`, if the poll allows
|
|
|
|
|
multiple answers, ignored for polls in quiz mode, defaults to :obj:`False`.
|
2020-03-29 09:52:30 +02:00
|
|
|
|
correct_option_id (:obj:`int`, optional): 0-based identifier of the correct answer
|
2020-04-10 20:05:01 +02:00
|
|
|
|
option, required for polls in quiz mode.
|
2020-05-02 11:56:52 +02:00
|
|
|
|
explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect
|
|
|
|
|
answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most
|
|
|
|
|
2 line feeds after entities parsing.
|
|
|
|
|
explanation_parse_mode (:obj:`str`, optional): Mode for parsing entities in the
|
|
|
|
|
explanation. See the constants in :class:`telegram.ParseMode` for the available
|
|
|
|
|
modes.
|
|
|
|
|
open_period (:obj:`int`, optional): Amount of time in seconds the poll will be active
|
|
|
|
|
after creation, 5-600. Can't be used together with :attr:`close_date`.
|
|
|
|
|
close_date (:obj:`int` | :obj:`datetime.datetime`, optional): Point in time (Unix
|
|
|
|
|
timestamp) when the poll will be automatically closed. Must be at least 5 and no
|
|
|
|
|
more than 600 seconds in the future. Can't be used together with
|
|
|
|
|
:attr:`open_period`.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
|
is_closed (:obj:`bool`, optional): Pass :obj:`True`, if the poll needs to be
|
|
|
|
|
immediately closed. This can be useful for poll preview.
|
2019-08-23 21:20:41 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendPoll'.format(self.base_url)
|
2019-08-23 21:20:41 +02:00
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
|
'chat_id': chat_id,
|
|
|
|
|
'question': question,
|
|
|
|
|
'options': options
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-02 11:56:52 +02:00
|
|
|
|
if explanation_parse_mode == DEFAULT_NONE:
|
|
|
|
|
if self.defaults:
|
|
|
|
|
explanation_parse_mode = self.defaults.parse_mode
|
|
|
|
|
else:
|
|
|
|
|
explanation_parse_mode = None
|
|
|
|
|
|
2020-03-29 09:52:30 +02:00
|
|
|
|
if not is_anonymous:
|
|
|
|
|
data['is_anonymous'] = is_anonymous
|
|
|
|
|
if type:
|
|
|
|
|
data['type'] = type
|
|
|
|
|
if allows_multiple_answers:
|
|
|
|
|
data['allows_multiple_answers'] = allows_multiple_answers
|
|
|
|
|
if correct_option_id is not None:
|
|
|
|
|
data['correct_option_id'] = correct_option_id
|
|
|
|
|
if is_closed:
|
|
|
|
|
data['is_closed'] = is_closed
|
2020-05-02 11:56:52 +02:00
|
|
|
|
if explanation:
|
|
|
|
|
data['explanation'] = explanation
|
|
|
|
|
if explanation_parse_mode:
|
|
|
|
|
data['explanation_parse_mode'] = explanation_parse_mode
|
|
|
|
|
if open_period:
|
|
|
|
|
data['open_period'] = open_period
|
|
|
|
|
if close_date:
|
|
|
|
|
if isinstance(close_date, datetime):
|
|
|
|
|
close_date = to_timestamp(close_date)
|
|
|
|
|
data['close_date'] = close_date
|
2020-03-29 09:52:30 +02:00
|
|
|
|
|
2019-08-23 21:20:41 +02:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def stop_poll(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
message_id,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
|
|
|
|
**kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Use this method to stop a poll which was sent by the bot.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
|
|
|
|
|
of the target channel (in the format @channelusername).
|
|
|
|
|
message_id (:obj:`int`): Identifier of the original message with the poll.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): A JSON-serialized
|
|
|
|
|
object for a new message inline keyboard.
|
2019-08-23 21:20:41 +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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
2020-04-10 20:05:01 +02:00
|
|
|
|
:class:`telegram.Poll`: On success, the stopped Poll with the final results is
|
|
|
|
|
returned.
|
2019-08-23 21:20:41 +02:00
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/stopPoll'.format(self.base_url)
|
2019-08-23 21:20:41 +02:00
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
|
'chat_id': chat_id,
|
|
|
|
|
'message_id': message_id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if reply_markup:
|
|
|
|
|
if isinstance(reply_markup, ReplyMarkup):
|
2020-04-11 09:44:40 +02:00
|
|
|
|
# We need to_json() instead of to_dict() here, because reply_markups may be
|
|
|
|
|
# attached to media messages, which aren't json dumped by utils.request
|
|
|
|
|
data['reply_markup'] = reply_markup.to_json()
|
2019-08-23 21:20:41 +02:00
|
|
|
|
else:
|
|
|
|
|
data['reply_markup'] = reply_markup
|
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
return Poll.de_json(result, self)
|
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
@log
|
|
|
|
|
def send_dice(self,
|
|
|
|
|
chat_id,
|
|
|
|
|
disable_notification=None,
|
|
|
|
|
reply_to_message_id=None,
|
|
|
|
|
reply_markup=None,
|
|
|
|
|
timeout=None,
|
2020-05-02 11:56:52 +02:00
|
|
|
|
emoji=None,
|
2020-04-10 19:22:45 +02:00
|
|
|
|
**kwargs):
|
|
|
|
|
"""
|
2020-06-22 20:09:52 +02:00
|
|
|
|
Use this method to send an animated emoji, which will have a random value. On success, the
|
2020-04-10 19:22:45 +02:00
|
|
|
|
sent Message is returned.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target private chat.
|
2020-05-02 11:56:52 +02:00
|
|
|
|
emoji (:obj:`str`, optional): Emoji on which the dice throw animation is based.
|
2020-06-22 20:09:52 +02:00
|
|
|
|
Currently, must be one of “🎲”, “🎯” or “🏀”. Dice can have values 1-6 for “🎲” and
|
|
|
|
|
“🎯”, and values 1-5 for “🏀” . Defaults to “🎲”
|
2020-04-10 19:22:45 +02:00
|
|
|
|
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
|
|
|
|
|
receive a notification with no sound.
|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
|
|
|
|
|
original message.
|
|
|
|
|
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
|
|
|
|
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
|
|
|
|
to remove reply keyboard or to force a reply from the user.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/sendDice'.format(self.base_url)
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
|
'chat_id': chat_id,
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-02 11:56:52 +02:00
|
|
|
|
if emoji:
|
|
|
|
|
data['emoji'] = emoji
|
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
|
|
|
|
|
reply_to_message_id=reply_to_message_id, reply_markup=reply_markup,
|
|
|
|
|
**kwargs)
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def get_my_commands(self, timeout=None, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Use this method to get the current list of the bot's commands.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
List[:class:`telegram.BotCommand]`: On success, the commands set for the bot
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/getMyCommands'.format(self.base_url)
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
|
|
result = self._request.get(url, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
self._commands = [BotCommand.de_json(c, self) for c in result]
|
|
|
|
|
|
|
|
|
|
return self._commands
|
|
|
|
|
|
|
|
|
|
@log
|
|
|
|
|
def set_my_commands(self, commands, timeout=None, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Use this method to change the list of the bot's commands.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
commands (List[:class:`BotCommand` | (:obj:`str`, :obj:`str`)]): A JSON-serialized list
|
|
|
|
|
of bot commands to be set as the list of the bot's commands. At most 100 commands
|
|
|
|
|
can be specified.
|
|
|
|
|
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).
|
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:obj:`True`: On success
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
:class:`telegram.TelegramError`
|
|
|
|
|
|
|
|
|
|
"""
|
2020-06-15 18:20:51 +02:00
|
|
|
|
url = '{}/setMyCommands'.format(self.base_url)
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
|
|
cmds = [c if isinstance(c, BotCommand) else BotCommand(c[0], c[1]) for c in commands]
|
|
|
|
|
|
|
|
|
|
data = {'commands': [c.to_dict() for c in cmds]}
|
|
|
|
|
data.update(kwargs)
|
|
|
|
|
|
|
|
|
|
result = self._request.post(url, data, timeout=timeout)
|
|
|
|
|
|
|
|
|
|
# Set commands. No need to check for outcome.
|
|
|
|
|
# If request failed, we won't come this far
|
|
|
|
|
self._commands = commands
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2015-07-20 13:36:08 +02:00
|
|
|
|
def to_dict(self):
|
2019-10-11 21:37:28 +02:00
|
|
|
|
data = {'id': self.id, 'username': self.username, 'first_name': self.first_name}
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
if self.last_name:
|
|
|
|
|
data['last_name'] = self.last_name
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
2015-07-20 12:53:58 +02:00
|
|
|
|
return data
|
2015-08-11 17:41:26 +02:00
|
|
|
|
|
|
|
|
|
def __reduce__(self):
|
2016-05-15 03:46:40 +02:00
|
|
|
|
return (self.__class__, (self.token, self.base_url.replace(self.token, ''),
|
2016-04-21 14:21:12 +02:00
|
|
|
|
self.base_file_url.replace(self.token, '')))
|
2016-04-28 12:20:42 +02:00
|
|
|
|
|
2017-05-07 16:09:58 +02:00
|
|
|
|
# camelCase aliases
|
|
|
|
|
getMe = get_me
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_me`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendMessage = send_message
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_message`"""
|
2017-05-12 17:40:57 +02:00
|
|
|
|
deleteMessage = delete_message
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`delete_message`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
forwardMessage = forward_message
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`forward_message`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendPhoto = send_photo
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_photo`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendAudio = send_audio
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_audio`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendDocument = send_document
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_document`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendSticker = send_sticker
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_sticker`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendVideo = send_video
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_video`"""
|
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
|
|
|
|
sendAnimation = send_animation
|
|
|
|
|
"""Alias for :attr:`send_animation`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendVoice = send_voice
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_voice`"""
|
2017-05-20 19:35:55 +02:00
|
|
|
|
sendVideoNote = send_video_note
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_video_note`"""
|
2017-12-08 22:38:59 +01:00
|
|
|
|
sendMediaGroup = send_media_group
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_media_group`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendLocation = send_location
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_location`"""
|
2017-10-14 20:03:02 +02:00
|
|
|
|
editMessageLiveLocation = edit_message_live_location
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`edit_message_live_location`"""
|
2017-10-14 20:03:02 +02:00
|
|
|
|
stopMessageLiveLocation = stop_message_live_location
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`stop_message_live_location`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendVenue = send_venue
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_venue`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendContact = send_contact
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_contact`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendGame = send_game
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_game`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
sendChatAction = send_chat_action
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_chat_action`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
answerInlineQuery = answer_inline_query
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`answer_inline_query`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
getUserProfilePhotos = get_user_profile_photos
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_user_profile_photos`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
getFile = get_file
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_file`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
kickChatMember = kick_chat_member
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`kick_chat_member`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
unbanChatMember = unban_chat_member
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`unban_chat_member`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
answerCallbackQuery = answer_callback_query
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`answer_callback_query`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
editMessageText = edit_message_text
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`edit_message_text`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
editMessageCaption = edit_message_caption
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`edit_message_caption`"""
|
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
|
|
|
|
editMessageMedia = edit_message_media
|
|
|
|
|
"""Alias for :attr:`edit_message_media`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
editMessageReplyMarkup = edit_message_reply_markup
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`edit_message_reply_markup`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
getUpdates = get_updates
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_updates`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
setWebhook = set_webhook
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`set_webhook`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
deleteWebhook = delete_webhook
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`delete_webhook`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
leaveChat = leave_chat
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`leave_chat`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
getChat = get_chat
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_chat`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
getChatAdministrators = get_chat_administrators
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_chat_administrators`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
getChatMember = get_chat_member
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_chat_member`"""
|
2017-10-14 20:03:02 +02:00
|
|
|
|
setChatStickerSet = set_chat_sticker_set
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`set_chat_sticker_set`"""
|
2017-10-14 20:03:02 +02:00
|
|
|
|
deleteChatStickerSet = delete_chat_sticker_set
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`delete_chat_sticker_set`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
getChatMembersCount = get_chat_members_count
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_chat_members_count`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
getWebhookInfo = get_webhook_info
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_webhook_info`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
setGameScore = set_game_score
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`set_game_score`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
|
getGameHighScores = get_game_high_scores
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_game_high_scores`"""
|
2017-05-19 19:46:42 +02:00
|
|
|
|
sendInvoice = send_invoice
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`send_invoice`"""
|
2017-05-19 19:46:42 +02:00
|
|
|
|
answerShippingQuery = answer_shipping_query
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`answer_shipping_query`"""
|
2017-05-19 19:46:42 +02:00
|
|
|
|
answerPreCheckoutQuery = answer_pre_checkout_query
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`answer_pre_checkout_query`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
|
restrictChatMember = restrict_chat_member
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`restrict_chat_member`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
|
promoteChatMember = promote_chat_member
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`promote_chat_member`"""
|
2019-09-06 21:41:43 +02:00
|
|
|
|
setChatPermissions = set_chat_permissions
|
|
|
|
|
"""Alias for :attr:`set_chat_permissions`"""
|
2020-03-28 16:37:26 +01:00
|
|
|
|
setChatAdministratorCustomTitle = set_chat_administrator_custom_title
|
|
|
|
|
"""Alias for :attr:`set_chat_administrator_custom_title`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
|
exportChatInviteLink = export_chat_invite_link
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`export_chat_invite_link`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
|
setChatPhoto = set_chat_photo
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`set_chat_photo`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
|
deleteChatPhoto = delete_chat_photo
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`delete_chat_photo`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
|
setChatTitle = set_chat_title
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`set_chat_title`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
|
setChatDescription = set_chat_description
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`set_chat_description`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
|
pinChatMessage = pin_chat_message
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`pin_chat_message`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
|
unpinChatMessage = unpin_chat_message
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`unpin_chat_message`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
|
getStickerSet = get_sticker_set
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`get_sticker_set`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
|
uploadStickerFile = upload_sticker_file
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`upload_sticker_file`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
|
createNewStickerSet = create_new_sticker_set
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`create_new_sticker_set`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
|
addStickerToSet = add_sticker_to_set
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`add_sticker_to_set`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
|
setStickerPositionInSet = set_sticker_position_in_set
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`set_sticker_position_in_set`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
|
deleteStickerFromSet = delete_sticker_from_set
|
2018-05-03 15:34:50 +02:00
|
|
|
|
"""Alias for :attr:`delete_sticker_from_set`"""
|
2020-04-10 19:22:45 +02:00
|
|
|
|
setStickerSetThumb = set_sticker_set_thumb
|
|
|
|
|
"""Alias for :attr:`set_sticker_set_thumb`"""
|
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
|
|
|
|
setPassportDataErrors = set_passport_data_errors
|
|
|
|
|
"""Alias for :attr:`set_passport_data_errors`"""
|
2019-08-23 21:20:41 +02:00
|
|
|
|
sendPoll = send_poll
|
|
|
|
|
"""Alias for :attr:`send_poll`"""
|
|
|
|
|
stopPoll = stop_poll
|
|
|
|
|
"""Alias for :attr:`stop_poll`"""
|
2020-04-10 19:22:45 +02:00
|
|
|
|
sendDice = send_dice
|
|
|
|
|
"""Alias for :attr:`send_dice`"""
|
|
|
|
|
getMyCommands = get_my_commands
|
|
|
|
|
"""Alias for :attr:`get_my_commands`"""
|
|
|
|
|
setMyCommands = set_my_commands
|
|
|
|
|
"""Alias for :attr:`set_my_commands`"""
|