2015-07-07 21:50:36 +02:00
|
|
|
#!/usr/bin/env python
|
2024-04-12 11:58:25 +02:00
|
|
|
# pylint: disable=too-many-arguments
|
2015-08-11 21:58:17 +02:00
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2024-02-19 20:06:25 +01:00
|
|
|
# Copyright (C) 2015-2024
|
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."""
|
2022-04-24 12:38:09 +02:00
|
|
|
import asyncio
|
2023-03-25 19:18:04 +01:00
|
|
|
import contextlib
|
2022-11-02 08:32:40 +01:00
|
|
|
import copy
|
2022-03-12 12:27:18 +01:00
|
|
|
import pickle
|
2020-10-31 16:33:34 +01:00
|
|
|
from datetime import datetime
|
2022-04-24 12:38:09 +02:00
|
|
|
from types import TracebackType
|
2020-10-31 16:33:34 +01:00
|
|
|
from typing import (
|
|
|
|
TYPE_CHECKING,
|
2022-05-05 09:27:54 +02:00
|
|
|
Any,
|
2023-02-02 18:55:07 +01:00
|
|
|
AsyncContextManager,
|
2020-10-31 16:33:34 +01:00
|
|
|
Callable,
|
2022-05-05 09:27:54 +02:00
|
|
|
Dict,
|
2020-10-31 16:33:34 +01:00
|
|
|
List,
|
2022-05-05 09:27:54 +02:00
|
|
|
NoReturn,
|
2020-10-31 16:33:34 +01:00
|
|
|
Optional,
|
2022-05-05 09:27:54 +02:00
|
|
|
Sequence,
|
2024-02-08 17:12:00 +01:00
|
|
|
Set,
|
2020-10-31 16:33:34 +01:00
|
|
|
Tuple,
|
2022-05-05 09:27:54 +02:00
|
|
|
Type,
|
2020-10-31 16:33:34 +01:00
|
|
|
TypeVar,
|
|
|
|
Union,
|
2021-02-19 19:07:48 +01:00
|
|
|
cast,
|
2022-05-05 09:27:54 +02:00
|
|
|
no_type_check,
|
2020-10-31 16:33:34 +01:00
|
|
|
)
|
2020-10-06 19:28:40 +02:00
|
|
|
|
2021-02-13 22:07:37 +01:00
|
|
|
try:
|
|
|
|
from cryptography.hazmat.backends import default_backend
|
|
|
|
from cryptography.hazmat.primitives import serialization
|
|
|
|
|
|
|
|
CRYPTO_INSTALLED = True
|
|
|
|
except ImportError:
|
|
|
|
default_backend = None # type: ignore[assignment]
|
|
|
|
serialization = None # type: ignore[assignment]
|
|
|
|
CRYPTO_INSTALLED = False
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._botcommand import BotCommand
|
|
|
|
from telegram._botcommandscope import BotCommandScope
|
2023-03-25 11:47:26 +01:00
|
|
|
from telegram._botdescription import BotDescription, BotShortDescription
|
2023-05-07 13:44:34 +02:00
|
|
|
from telegram._botname import BotName
|
2024-04-12 11:58:25 +02:00
|
|
|
from telegram._business import BusinessConnection
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._chat import Chat
|
|
|
|
from telegram._chatadministratorrights import ChatAdministratorRights
|
2024-02-08 17:12:00 +01:00
|
|
|
from telegram._chatboost import UserChatBoosts
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._chatinvitelink import ChatInviteLink
|
|
|
|
from telegram._chatmember import ChatMember
|
|
|
|
from telegram._chatpermissions import ChatPermissions
|
|
|
|
from telegram._files.animation import Animation
|
|
|
|
from telegram._files.audio import Audio
|
|
|
|
from telegram._files.chatphoto import ChatPhoto
|
|
|
|
from telegram._files.contact import Contact
|
|
|
|
from telegram._files.document import Document
|
|
|
|
from telegram._files.file import File
|
|
|
|
from telegram._files.inputmedia import InputMedia
|
|
|
|
from telegram._files.location import Location
|
|
|
|
from telegram._files.photosize import PhotoSize
|
|
|
|
from telegram._files.sticker import MaskPosition, Sticker, StickerSet
|
|
|
|
from telegram._files.venue import Venue
|
|
|
|
from telegram._files.video import Video
|
|
|
|
from telegram._files.videonote import VideoNote
|
|
|
|
from telegram._files.voice import Voice
|
2022-11-22 10:43:50 +01:00
|
|
|
from telegram._forumtopic import ForumTopic
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._games.gamehighscore import GameHighScore
|
2023-05-07 13:44:34 +02:00
|
|
|
from telegram._inline.inlinequeryresultsbutton import InlineQueryResultsButton
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._menubutton import MenuButton
|
|
|
|
from telegram._message import Message
|
|
|
|
from telegram._messageid import MessageId
|
|
|
|
from telegram._poll import Poll
|
2024-02-08 17:12:00 +01:00
|
|
|
from telegram._reaction import ReactionType, ReactionTypeCustomEmoji, ReactionTypeEmoji
|
|
|
|
from telegram._reply import ReplyParameters
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._sentwebappmessage import SentWebAppMessage
|
|
|
|
from telegram._telegramobject import TelegramObject
|
|
|
|
from telegram._update import Update
|
|
|
|
from telegram._user import User
|
|
|
|
from telegram._userprofilephotos import UserProfilePhotos
|
2024-02-25 10:34:47 +01:00
|
|
|
from telegram._utils.argumentparsing import parse_lpo_and_dwpp, parse_sequence_arg
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._utils.defaultvalue import DEFAULT_NONE, DefaultValue
|
|
|
|
from telegram._utils.files import is_local_file, parse_file_input
|
2023-04-10 17:01:35 +02:00
|
|
|
from telegram._utils.logging import get_logger
|
2023-09-15 21:35:45 +02:00
|
|
|
from telegram._utils.repr import build_repr_with_selected_attrs
|
2024-02-07 22:35:09 +01:00
|
|
|
from telegram._utils.strings import to_camel_case
|
2023-10-25 21:53:43 +02:00
|
|
|
from telegram._utils.types import CorrectOptionID, FileInput, JSONDict, ODVInput, ReplyMarkup
|
2023-03-12 16:30:39 +01:00
|
|
|
from telegram._utils.warnings import warn
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._webhookinfo import WebhookInfo
|
2024-02-08 17:12:00 +01:00
|
|
|
from telegram.constants import InlineQueryLimit, ReactionEmoji
|
2024-02-07 22:35:09 +01:00
|
|
|
from telegram.error import EndPointNotFound, InvalidToken
|
2022-04-24 12:38:09 +02:00
|
|
|
from telegram.request import BaseRequest, RequestData
|
|
|
|
from telegram.request._httpxrequest import HTTPXRequest
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram.request._requestparameter import RequestParameter
|
2023-11-27 18:24:21 +01:00
|
|
|
from telegram.warnings import PTBDeprecationWarning, PTBUserWarning
|
2020-10-09 17:22:07 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
if TYPE_CHECKING:
|
2020-12-30 13:41:07 +01:00
|
|
|
from telegram import (
|
2023-09-15 21:33:42 +02:00
|
|
|
InlineKeyboardMarkup,
|
2022-05-05 09:27:54 +02:00
|
|
|
InlineQueryResult,
|
2022-09-19 22:31:23 +02:00
|
|
|
InputFile,
|
2020-12-30 13:41:07 +01:00
|
|
|
InputMediaAudio,
|
|
|
|
InputMediaDocument,
|
|
|
|
InputMediaPhoto,
|
|
|
|
InputMediaVideo,
|
2023-09-15 21:33:42 +02:00
|
|
|
InputSticker,
|
2020-12-30 13:41:07 +01:00
|
|
|
LabeledPrice,
|
2024-02-08 17:12:00 +01:00
|
|
|
LinkPreviewOptions,
|
2020-12-30 13:41:07 +01:00
|
|
|
MessageEntity,
|
2023-09-15 21:33:42 +02:00
|
|
|
PassportElementError,
|
|
|
|
ShippingOption,
|
2020-12-30 13:41:07 +01:00
|
|
|
)
|
2015-08-09 14:41:58 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
BT = TypeVar("BT", bound="Bot")
|
2015-07-20 12:53:58 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
|
2023-02-02 18:55:07 +01:00
|
|
|
class Bot(TelegramObject, AsyncContextManager["Bot"]):
|
2017-09-01 08:43:08 +02:00
|
|
|
"""This object represents a Telegram Bot.
|
2015-08-28 17:19:30 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
Instances of this class can be used as asyncio context managers, where
|
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
|
|
|
async with bot:
|
|
|
|
# code
|
|
|
|
|
|
|
|
is roughly equivalent to
|
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
|
|
|
try:
|
|
|
|
await bot.initialize()
|
|
|
|
# code
|
|
|
|
finally:
|
2023-02-05 18:09:55 +01:00
|
|
|
await bot.shutdown()
|
2021-01-17 09:23:36 +01:00
|
|
|
|
2023-10-09 18:59:52 +02:00
|
|
|
.. seealso:: :meth:`__aenter__` and :meth:`__aexit__`.
|
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Note:
|
2022-03-12 12:27:18 +01:00
|
|
|
* Most bot methods have the argument ``api_kwargs`` which allows passing arbitrary keywords
|
|
|
|
to the Telegram API. This can be used to access new features of the API before they are
|
2024-02-07 22:35:09 +01:00
|
|
|
incorporated into PTB. The limitations to this argument are the same as the ones
|
|
|
|
described in :meth:`do_api_request`.
|
2022-03-12 12:27:18 +01:00
|
|
|
* Bots should not be serialized since if you for e.g. change the bots token, then your
|
|
|
|
serialized instance will not reflect that change. Trying to pickle a bot instance will
|
2022-12-30 10:50:49 +01:00
|
|
|
raise :exc:`pickle.PicklingError`. Trying to deepcopy a bot instance will raise
|
|
|
|
:exc:`TypeError`.
|
2020-12-30 15:59:50 +01:00
|
|
|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
Examples:
|
|
|
|
:any:`Raw API Bot <examples.rawapibot>`
|
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
.. seealso:: :wiki:`Your First Bot <Extensions---Your-first-Bot>`,
|
2023-01-01 16:24:00 +01:00
|
|
|
:wiki:`Builder Pattern <Builder-Pattern>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
.. versionadded:: 13.2
|
|
|
|
Objects of this class are comparable in terms of equality. Two objects of this class are
|
|
|
|
considered equal, if their :attr:`bot` is equal.
|
|
|
|
|
2022-05-06 17:15:23 +02:00
|
|
|
.. versionchanged:: 20.0
|
2021-10-19 18:28:19 +02:00
|
|
|
|
2021-08-30 16:31:19 +02:00
|
|
|
* Removed the deprecated methods ``kick_chat_member``, ``kickChatMember``,
|
|
|
|
``get_chat_members_count`` and ``getChatMembersCount``.
|
|
|
|
* Removed the deprecated property ``commands``.
|
2021-10-03 15:10:13 +02:00
|
|
|
* Removed the deprecated ``defaults`` parameter. If you want to use
|
2021-10-19 18:28:19 +02:00
|
|
|
:class:`telegram.ext.Defaults`, please use the subclass :class:`telegram.ext.ExtBot`
|
|
|
|
instead.
|
2022-03-12 12:27:18 +01:00
|
|
|
* Attempting to pickle a bot instance will now raise :exc:`pickle.PicklingError`.
|
2022-12-30 10:50:49 +01:00
|
|
|
* Attempting to deepcopy a bot instance will now raise :exc:`TypeError`.
|
2022-05-18 17:18:44 +02:00
|
|
|
* The following are now keyword-only arguments in Bot methods:
|
|
|
|
``location``, ``filename``, ``venue``, ``contact``,
|
|
|
|
``{read, write, connect, pool}_timeout``, ``api_kwargs``. Use a named argument for those,
|
|
|
|
and notice that some positional arguments changed position as a result.
|
2022-09-19 22:31:23 +02:00
|
|
|
* For uploading files, file paths are now always accepted. If :paramref:`local_mode` is
|
|
|
|
:obj:`False`, the file contents will be read in binary mode and uploaded. Otherwise,
|
|
|
|
the file path will be passed in the
|
|
|
|
`file URI scheme <https://en.wikipedia.org/wiki/File_URI_scheme>`_.
|
2021-08-30 16:31:19 +02:00
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
Removed deprecated methods ``set_sticker_set_thumb`` and ``setStickerSetThumb``.
|
|
|
|
Use :meth:`set_sticker_set_thumbnail` and :meth:`setStickerSetThumbnail` instead.
|
|
|
|
|
2015-08-28 17:19:30 +02:00
|
|
|
Args:
|
2022-04-24 12:38:09 +02:00
|
|
|
token (:obj:`str`): Bot's unique authentication token.
|
2017-07-23 22:33:08 +02:00
|
|
|
base_url (:obj:`str`, optional): Telegram Bot API service URL.
|
|
|
|
base_file_url (:obj:`str`, optional): Telegram Bot API file URL.
|
2022-04-24 12:38:09 +02:00
|
|
|
request (:class:`telegram.request.BaseRequest`, optional): Pre initialized
|
|
|
|
:class:`telegram.request.BaseRequest` instances. Will be used for all bot methods
|
|
|
|
*except* for :meth:`get_updates`. If not passed, an instance of
|
|
|
|
:class:`telegram.request.HTTPXRequest` will be used.
|
|
|
|
get_updates_request (:class:`telegram.request.BaseRequest`, optional): Pre initialized
|
|
|
|
:class:`telegram.request.BaseRequest` instances. Will be used exclusively for
|
|
|
|
:meth:`get_updates`. If not passed, an instance of
|
|
|
|
:class:`telegram.request.HTTPXRequest` will be used.
|
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.
|
2022-09-19 22:31:23 +02:00
|
|
|
local_mode (:obj:`bool`, optional): Set to :obj:`True`, if the :paramref:`base_url` is
|
|
|
|
the URI of a `Local Bot API Server <https://core.telegram.org/bots/api#using-a-local\
|
|
|
|
-bot-api-server>`_ that runs with the ``--local`` flag. Currently, the only effect of
|
|
|
|
this is that files are uploaded using their local path in the
|
|
|
|
`file URI scheme <https://en.wikipedia.org/wiki/File_URI_scheme>`_.
|
|
|
|
Defaults to :obj:`False`.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0.
|
2021-06-06 11:48:48 +02:00
|
|
|
|
2022-06-29 21:38:03 +02:00
|
|
|
.. include:: inclusions/bot_methods.rst
|
2022-02-09 17:30:16 +01:00
|
|
|
|
2023-09-03 14:23:48 +02:00
|
|
|
.. |removed_thumb_arg| replace:: Removed deprecated argument ``thumb``. Use
|
|
|
|
``thumbnail`` instead.
|
|
|
|
|
2015-08-28 17:19:30 +02:00
|
|
|
"""
|
2015-07-09 18:19:58 +02:00
|
|
|
|
2023-04-10 17:01:35 +02:00
|
|
|
# This is a class variable since we want to override the logger name in ExtBot
|
|
|
|
# without having to change all places where this is used
|
|
|
|
_LOGGER = get_logger(__name__)
|
|
|
|
|
2021-05-29 16:18:16 +02:00
|
|
|
__slots__ = (
|
2022-09-18 15:42:12 +02:00
|
|
|
"_base_file_url",
|
2024-02-05 19:24:00 +01:00
|
|
|
"_base_url",
|
2021-10-21 11:17:12 +02:00
|
|
|
"_bot_user",
|
2022-04-24 12:38:09 +02:00
|
|
|
"_initialized",
|
2022-09-19 22:31:23 +02:00
|
|
|
"_local_mode",
|
2024-02-05 19:24:00 +01:00
|
|
|
"_private_key",
|
|
|
|
"_request",
|
|
|
|
"_token",
|
2021-05-29 16:18:16 +02:00
|
|
|
)
|
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
def __init__(
|
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
token: str,
|
2021-10-09 13:56:50 +02:00
|
|
|
base_url: str = "https://api.telegram.org/bot",
|
|
|
|
base_file_url: str = "https://api.telegram.org/file/bot",
|
2023-05-18 07:57:59 +02:00
|
|
|
request: Optional[BaseRequest] = None,
|
|
|
|
get_updates_request: Optional[BaseRequest] = None,
|
|
|
|
private_key: Optional[bytes] = None,
|
|
|
|
private_key_password: Optional[bytes] = None,
|
2022-09-19 22:31:23 +02:00
|
|
|
local_mode: bool = False,
|
2020-10-06 19:28:40 +02:00
|
|
|
):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(api_kwargs=None)
|
2022-08-03 08:16:48 +02:00
|
|
|
if not token:
|
|
|
|
raise InvalidToken("You must pass the token you received from https://t.me/Botfather!")
|
2023-02-02 18:55:07 +01:00
|
|
|
self._token: str = token
|
2015-07-08 22:23:18 +02:00
|
|
|
|
2023-02-02 18:55:07 +01:00
|
|
|
self._base_url: str = base_url + self._token
|
|
|
|
self._base_file_url: str = base_file_url + self._token
|
|
|
|
self._local_mode: bool = local_mode
|
2021-10-21 11:17:12 +02:00
|
|
|
self._bot_user: Optional[User] = None
|
2023-02-02 18:55:07 +01:00
|
|
|
self._private_key: Optional[bytes] = None
|
2023-05-07 14:10:20 +02:00
|
|
|
self._initialized: bool = False
|
2022-04-24 12:38:09 +02:00
|
|
|
|
|
|
|
self._request: Tuple[BaseRequest, BaseRequest] = (
|
|
|
|
HTTPXRequest() if get_updates_request is None else get_updates_request,
|
|
|
|
HTTPXRequest() if request is None else request,
|
|
|
|
)
|
2015-07-20 13:36:08 +02:00
|
|
|
|
2023-03-12 16:30:39 +01:00
|
|
|
# this section is about issuing a warning when using HTTP/2 and connect to a self hosted
|
|
|
|
# bot api instance, which currently only supports HTTP/1.1. Checking if a custom base url
|
|
|
|
# is set is the best way to do that.
|
|
|
|
|
|
|
|
warning_string = ""
|
|
|
|
|
|
|
|
if (
|
|
|
|
isinstance(self._request[0], HTTPXRequest)
|
|
|
|
and self._request[0].http_version == "2"
|
|
|
|
and not base_url.startswith("https://api.telegram.org/bot")
|
|
|
|
):
|
|
|
|
warning_string = "get_updates_request"
|
|
|
|
|
|
|
|
if (
|
|
|
|
isinstance(self._request[1], HTTPXRequest)
|
|
|
|
and self._request[1].http_version == "2"
|
|
|
|
and not base_url.startswith("https://api.telegram.org/bot")
|
|
|
|
):
|
|
|
|
if warning_string:
|
|
|
|
warning_string += " and request"
|
|
|
|
else:
|
|
|
|
warning_string = "request"
|
|
|
|
|
|
|
|
if warning_string:
|
2023-04-27 22:36:04 +02:00
|
|
|
self._warn(
|
2023-03-12 16:30:39 +01:00
|
|
|
f"You set the HTTP version for the {warning_string} HTTPXRequest instance to "
|
2023-09-22 18:19:21 +02:00
|
|
|
"HTTP/2. The self hosted bot api instances only support HTTP/1.1. You should "
|
|
|
|
"either run a HTTP proxy in front of it which supports HTTP/2 or use HTTP/1.1.",
|
2023-03-12 16:30:39 +01:00
|
|
|
PTBUserWarning,
|
|
|
|
stacklevel=2,
|
|
|
|
)
|
|
|
|
|
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:
|
2021-02-13 22:07:37 +01:00
|
|
|
if not CRYPTO_INSTALLED:
|
|
|
|
raise RuntimeError(
|
|
|
|
"To use Telegram Passports, PTB must be installed via `pip install "
|
2023-06-29 07:46:00 +02:00
|
|
|
'"python-telegram-bot[passport]"`.'
|
2021-02-13 22:07:37 +01:00
|
|
|
)
|
2022-09-18 15:42:12 +02:00
|
|
|
self._private_key = serialization.load_pem_private_key(
|
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, password=private_key_password, backend=default_backend()
|
|
|
|
)
|
2020-10-09 17:22:07 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
|
|
|
|
2023-09-15 22:19:45 +02:00
|
|
|
async def __aenter__(self: BT) -> BT:
|
2023-10-09 18:59:52 +02:00
|
|
|
"""
|
|
|
|
|async_context_manager| :meth:`initializes <initialize>` the Bot.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
The initialized Bot instance.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:exc:`Exception`: If an exception is raised during initialization, :meth:`shutdown`
|
|
|
|
is called in this case.
|
|
|
|
"""
|
2023-09-15 22:19:45 +02:00
|
|
|
try:
|
|
|
|
await self.initialize()
|
|
|
|
return self
|
|
|
|
except Exception as exc:
|
|
|
|
await self.shutdown()
|
|
|
|
raise exc
|
|
|
|
|
|
|
|
async def __aexit__(
|
|
|
|
self,
|
|
|
|
exc_type: Optional[Type[BaseException]],
|
|
|
|
exc_val: Optional[BaseException],
|
|
|
|
exc_tb: Optional[TracebackType],
|
|
|
|
) -> None:
|
2023-10-09 18:59:52 +02:00
|
|
|
"""|async_context_manager| :meth:`shuts down <shutdown>` the Bot."""
|
2023-09-15 22:19:45 +02:00
|
|
|
# Make sure not to return `True` so that exceptions are not suppressed
|
|
|
|
# https://docs.python.org/3/reference/datamodel.html?#object.__aexit__
|
|
|
|
await self.shutdown()
|
|
|
|
|
|
|
|
def __reduce__(self) -> NoReturn:
|
|
|
|
"""Customizes how :func:`copy.deepcopy` processes objects of this type. Bots can not
|
|
|
|
be pickled and this method will always raise an exception.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:exc:`pickle.PicklingError`
|
|
|
|
"""
|
|
|
|
raise pickle.PicklingError("Bot objects cannot be pickled!")
|
|
|
|
|
|
|
|
def __deepcopy__(self, memodict: Dict[int, object]) -> NoReturn:
|
|
|
|
"""Customizes how :func:`copy.deepcopy` processes objects of this type. Bots can not
|
|
|
|
be deepcopied and this method will always raise an exception.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:exc:`TypeError`
|
|
|
|
"""
|
|
|
|
raise TypeError("Bot objects cannot be deepcopied!")
|
|
|
|
|
|
|
|
def __eq__(self, other: object) -> bool:
|
2023-12-10 20:17:11 +01:00
|
|
|
"""Defines equality condition for the :class:`telegram.Bot` object.
|
|
|
|
Two objects of this class are considered to be equal if their attributes
|
|
|
|
:attr:`bot` are equal.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`True` if both attributes :attr:`bot` are equal. :obj:`False` otherwise.
|
|
|
|
"""
|
|
|
|
if isinstance(other, Bot):
|
2023-09-15 22:19:45 +02:00
|
|
|
return self.bot == other.bot
|
2023-12-10 20:17:11 +01:00
|
|
|
return super().__eq__(other)
|
2023-09-15 22:19:45 +02:00
|
|
|
|
|
|
|
def __hash__(self) -> int:
|
2023-12-10 20:17:11 +01:00
|
|
|
"""See :meth:`telegram.TelegramObject.__hash__`"""
|
|
|
|
if self._bot_user is None:
|
|
|
|
return super().__hash__()
|
|
|
|
return hash((self.bot, Bot))
|
2023-09-15 22:19:45 +02:00
|
|
|
|
2023-09-15 21:35:45 +02:00
|
|
|
def __repr__(self) -> str:
|
|
|
|
"""Give a string representation of the bot in the form ``Bot[token=...]``.
|
|
|
|
|
|
|
|
As this class doesn't implement :meth:`object.__str__`, the default implementation
|
|
|
|
will be used, which is equivalent to :meth:`__repr__`.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`str`
|
|
|
|
"""
|
|
|
|
return build_repr_with_selected_attrs(self, token=self.token)
|
|
|
|
|
2022-09-18 15:42:12 +02:00
|
|
|
@property
|
|
|
|
def token(self) -> str:
|
|
|
|
""":obj:`str`: Bot's unique authentication token.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|
|
|
|
return self._token
|
|
|
|
|
|
|
|
@property
|
|
|
|
def base_url(self) -> str:
|
|
|
|
""":obj:`str`: Telegram Bot API service URL, built from :paramref:`Bot.base_url` and
|
|
|
|
:paramref:`Bot.token`.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|
|
|
|
return self._base_url
|
|
|
|
|
|
|
|
@property
|
|
|
|
def base_file_url(self) -> str:
|
|
|
|
""":obj:`str`: Telegram Bot API file URL, built from :paramref:`Bot.base_file_url` and
|
|
|
|
:paramref:`Bot.token`.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|
|
|
|
return self._base_file_url
|
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
@property
|
|
|
|
def local_mode(self) -> bool:
|
|
|
|
""":obj:`bool`: Whether this bot is running in local mode.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|
|
|
|
return self._local_mode
|
|
|
|
|
2022-09-18 15:42:12 +02:00
|
|
|
# Proper type hints are difficult because:
|
|
|
|
# 1. cryptography doesn't have a nice base class, so it would get lengthy
|
|
|
|
# 2. we can't import cryptography if it's not installed
|
|
|
|
@property
|
|
|
|
def private_key(self) -> Optional[Any]:
|
|
|
|
"""Deserialized private key for decryption of telegram passport data.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|
|
|
|
return self._private_key
|
|
|
|
|
2023-09-15 22:19:45 +02:00
|
|
|
@property
|
|
|
|
def request(self) -> BaseRequest:
|
|
|
|
"""The :class:`~telegram.request.BaseRequest` object used by this bot.
|
|
|
|
|
|
|
|
Warning:
|
|
|
|
Requests to the Bot API are made by the various methods of this class. This attribute
|
|
|
|
should *not* be used manually.
|
2023-04-27 22:36:04 +02:00
|
|
|
"""
|
2023-09-15 22:19:45 +02:00
|
|
|
return self._request[1]
|
2023-04-27 22:36:04 +02:00
|
|
|
|
2023-09-15 22:19:45 +02:00
|
|
|
@property
|
|
|
|
def bot(self) -> User:
|
|
|
|
""":class:`telegram.User`: User instance for the bot as returned by :meth:`get_me`.
|
2022-12-30 10:50:49 +01:00
|
|
|
|
2023-09-15 22:19:45 +02:00
|
|
|
Warning:
|
|
|
|
This value is the cached return value of :meth:`get_me`. If the bots profile is
|
|
|
|
changed during runtime, this value won't reflect the changes until :meth:`get_me` is
|
|
|
|
called again.
|
2022-12-30 10:50:49 +01:00
|
|
|
|
2023-09-15 22:19:45 +02:00
|
|
|
.. seealso:: :meth:`initialize`
|
2022-12-30 10:50:49 +01:00
|
|
|
"""
|
2023-09-15 22:19:45 +02:00
|
|
|
if self._bot_user is None:
|
|
|
|
raise RuntimeError(
|
|
|
|
f"{self.__class__.__name__} is not properly initialized. Call "
|
|
|
|
f"`{self.__class__.__name__}.initialize` before accessing this property."
|
|
|
|
)
|
|
|
|
return self._bot_user
|
2022-03-12 12:27:18 +01:00
|
|
|
|
2023-09-15 22:19:45 +02:00
|
|
|
@property
|
|
|
|
def id(self) -> int:
|
|
|
|
""":obj:`int`: Unique identifier for this bot. Shortcut for the corresponding attribute of
|
|
|
|
:attr:`bot`.
|
|
|
|
"""
|
|
|
|
return self.bot.id
|
2022-12-30 10:50:49 +01:00
|
|
|
|
2023-09-15 22:19:45 +02:00
|
|
|
@property
|
|
|
|
def first_name(self) -> str:
|
|
|
|
""":obj:`str`: Bot's first name. Shortcut for the corresponding attribute of
|
|
|
|
:attr:`bot`.
|
|
|
|
"""
|
|
|
|
return self.bot.first_name
|
2022-12-30 10:50:49 +01:00
|
|
|
|
2023-09-15 22:19:45 +02:00
|
|
|
@property
|
|
|
|
def last_name(self) -> str:
|
|
|
|
""":obj:`str`: Optional. Bot's last name. Shortcut for the corresponding attribute of
|
|
|
|
:attr:`bot`.
|
2022-12-30 10:50:49 +01:00
|
|
|
"""
|
2023-09-15 22:19:45 +02:00
|
|
|
return self.bot.last_name # type: ignore
|
|
|
|
|
|
|
|
@property
|
|
|
|
def username(self) -> str:
|
|
|
|
""":obj:`str`: Bot's username. Shortcut for the corresponding attribute of
|
|
|
|
:attr:`bot`.
|
|
|
|
"""
|
|
|
|
return self.bot.username # type: ignore
|
|
|
|
|
|
|
|
@property
|
|
|
|
def link(self) -> str:
|
|
|
|
""":obj:`str`: Convenience property. Returns the t.me link of the bot."""
|
|
|
|
return f"https://t.me/{self.username}"
|
|
|
|
|
|
|
|
@property
|
|
|
|
def can_join_groups(self) -> bool:
|
|
|
|
""":obj:`bool`: Bot's :attr:`telegram.User.can_join_groups` attribute. Shortcut for the
|
|
|
|
corresponding attribute of :attr:`bot`.
|
|
|
|
"""
|
|
|
|
return self.bot.can_join_groups # type: ignore
|
|
|
|
|
|
|
|
@property
|
|
|
|
def can_read_all_group_messages(self) -> bool:
|
|
|
|
""":obj:`bool`: Bot's :attr:`telegram.User.can_read_all_group_messages` attribute.
|
|
|
|
Shortcut for the corresponding attribute of :attr:`bot`.
|
|
|
|
"""
|
|
|
|
return self.bot.can_read_all_group_messages # type: ignore
|
|
|
|
|
|
|
|
@property
|
|
|
|
def supports_inline_queries(self) -> bool:
|
|
|
|
""":obj:`bool`: Bot's :attr:`telegram.User.supports_inline_queries` attribute.
|
|
|
|
Shortcut for the corresponding attribute of :attr:`bot`.
|
|
|
|
"""
|
|
|
|
return self.bot.supports_inline_queries # type: ignore
|
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self) -> str:
|
|
|
|
""":obj:`str`: Bot's @username. Shortcut for the corresponding attribute of :attr:`bot`."""
|
|
|
|
return f"@{self.username}"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _warn(
|
|
|
|
cls, message: str, category: Type[Warning] = PTBUserWarning, stacklevel: int = 0
|
|
|
|
) -> None:
|
|
|
|
"""Convenience method to issue a warning. This method is here mostly to make it easier
|
|
|
|
for ExtBot to add 1 level to all warning calls.
|
|
|
|
"""
|
|
|
|
warn(message=message, category=category, stacklevel=stacklevel + 1)
|
2022-12-30 10:50:49 +01:00
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
def _parse_file_input(
|
|
|
|
self,
|
|
|
|
file_input: Union[FileInput, "TelegramObject"],
|
2023-05-18 07:57:59 +02:00
|
|
|
tg_type: Optional[Type["TelegramObject"]] = None,
|
|
|
|
filename: Optional[str] = None,
|
2022-09-19 22:31:23 +02:00
|
|
|
attach: bool = False,
|
|
|
|
) -> Union[str, "InputFile", Any]:
|
|
|
|
return parse_file_input(
|
|
|
|
file_input=file_input,
|
|
|
|
tg_type=tg_type,
|
|
|
|
filename=filename,
|
|
|
|
attach=attach,
|
|
|
|
local_mode=self._local_mode,
|
|
|
|
)
|
|
|
|
|
2024-02-07 20:45:57 +01:00
|
|
|
def _insert_defaults(self, data: Dict[str, object]) -> None:
|
2021-10-03 15:10:13 +02:00
|
|
|
"""This method is here to make ext.Defaults work. Because we need to be able to tell
|
|
|
|
e.g. `send_message(chat_id, text)` from `send_message(chat_id, text, parse_mode=None)`, the
|
|
|
|
default values for `parse_mode` etc are not `None` but `DEFAULT_NONE`. While this *could*
|
|
|
|
be done in ExtBot instead of Bot, shortcuts like `Message.reply_text` need to work for both
|
|
|
|
Bot and ExtBot, so they also have the `DEFAULT_NONE` default values.
|
|
|
|
|
|
|
|
This makes it necessary to convert `DefaultValue(obj)` to `obj` at some point between
|
|
|
|
`Message.reply_text` and the request to TG. Doing this here in a centralized manner is a
|
|
|
|
rather clean and minimally invasive solution, i.e. the link between tg and tg.ext is as
|
|
|
|
small as possible.
|
|
|
|
See also _insert_defaults_for_ilq
|
|
|
|
ExtBot overrides this method to actually insert default values.
|
|
|
|
|
|
|
|
If in the future we come up with a better way of making `Defaults` work, we can cut this
|
|
|
|
link as well.
|
2021-02-19 19:07:48 +01:00
|
|
|
"""
|
2021-10-03 15:10:13 +02:00
|
|
|
# We
|
|
|
|
# 1) set the correct parse_mode for all InputMedia objects
|
|
|
|
# 2) replace all DefaultValue instances with the corresponding normal value.
|
2021-02-19 19:07:48 +01:00
|
|
|
for key, val in data.items():
|
2021-10-03 15:10:13 +02:00
|
|
|
# 1)
|
|
|
|
if isinstance(val, InputMedia):
|
2022-10-31 09:46:56 +01:00
|
|
|
# Copy object as not to edit it in-place
|
2023-03-25 19:18:04 +01:00
|
|
|
new = copy.copy(val)
|
|
|
|
with new._unfrozen():
|
|
|
|
new.parse_mode = DefaultValue.get_value(new.parse_mode)
|
|
|
|
data[key] = new
|
2023-01-01 14:24:30 +01:00
|
|
|
elif key == "media" and isinstance(val, Sequence):
|
2022-10-31 09:46:56 +01:00
|
|
|
# Copy objects as not to edit them in-place
|
2022-11-02 08:32:40 +01:00
|
|
|
copy_list = [copy.copy(media) for media in val]
|
2022-10-31 09:46:56 +01:00
|
|
|
for media in copy_list:
|
2022-12-15 15:00:36 +01:00
|
|
|
with media._unfrozen():
|
|
|
|
media.parse_mode = DefaultValue.get_value(media.parse_mode)
|
|
|
|
|
2022-10-31 09:46:56 +01:00
|
|
|
data[key] = copy_list
|
2021-10-03 15:10:13 +02:00
|
|
|
# 2)
|
|
|
|
else:
|
|
|
|
data[key] = DefaultValue.get_value(val)
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def _post(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
endpoint: str,
|
2023-05-18 07:57:59 +02:00
|
|
|
data: Optional[JSONDict] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Any:
|
|
|
|
# We know that the return type is Union[bool, JSONDict, List[JSONDict]], but it's hard
|
|
|
|
# to tell mypy which methods expects which of these return values and `Any` saves us a
|
|
|
|
# lot of `type: ignore` comments
|
2020-10-06 19:28:40 +02:00
|
|
|
if data is None:
|
|
|
|
data = {}
|
|
|
|
|
2020-06-30 22:07:38 +02:00
|
|
|
if api_kwargs:
|
2022-04-24 12:38:09 +02:00
|
|
|
data.update(api_kwargs)
|
2020-06-30 22:07:38 +02:00
|
|
|
|
2021-02-19 19:07:48 +01:00
|
|
|
# Insert is in-place, so no return value for data
|
2022-04-24 12:38:09 +02:00
|
|
|
self._insert_defaults(data)
|
2021-10-03 15:10:13 +02:00
|
|
|
|
2021-02-19 19:07:48 +01:00
|
|
|
# Drop any None values because Telegram doesn't handle them well
|
|
|
|
data = {key: value for key, value in data.items() if value is not None}
|
|
|
|
|
2022-08-26 06:50:03 +02:00
|
|
|
return await self._do_post(
|
|
|
|
endpoint=endpoint,
|
|
|
|
data=data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def _do_post(
|
|
|
|
self,
|
|
|
|
endpoint: str,
|
|
|
|
data: JSONDict,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Union[bool, JSONDict, List[JSONDict]]:
|
2022-04-24 12:38:09 +02:00
|
|
|
# This also converts datetimes into timestamps.
|
|
|
|
# We don't do this earlier so that _insert_defaults (see above) has a chance to convert
|
2021-10-03 15:10:13 +02:00
|
|
|
# to the default timezone in case this is called by ExtBot
|
2022-04-24 12:38:09 +02:00
|
|
|
request_data = RequestData(
|
|
|
|
parameters=[RequestParameter.from_input(key, value) for key, value in data.items()],
|
|
|
|
)
|
2021-10-03 15:10:13 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
request = self._request[0] if endpoint == "getUpdates" else self._request[1]
|
2022-04-24 12:38:09 +02:00
|
|
|
|
2024-03-24 12:34:08 +01:00
|
|
|
self._LOGGER.debug("Calling Bot API endpoint `%s` with parameters `%s`", endpoint, data)
|
|
|
|
result = await request.post(
|
2022-09-18 15:42:12 +02:00
|
|
|
url=f"{self._base_url}/{endpoint}",
|
2022-04-24 12:38:09 +02:00
|
|
|
request_data=request_data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2021-02-19 19:07:48 +01:00
|
|
|
)
|
2024-03-24 12:34:08 +01:00
|
|
|
self._LOGGER.debug(
|
|
|
|
"Call to Bot API endpoint `%s` finished with return value `%s`", endpoint, result
|
|
|
|
)
|
|
|
|
|
|
|
|
return result
|
2020-10-09 17:22:07 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def _send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
endpoint: str,
|
|
|
|
data: JSONDict,
|
2021-02-19 19:07:48 +01:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
caption: Optional[str] = None,
|
2022-11-26 19:05:44 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
link_preview_options: ODVInput["LinkPreviewOptions"] = None,
|
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Any:
|
2022-11-26 19:05:44 +01:00
|
|
|
"""Protected method to send or edit messages of any type.
|
2019-02-13 11:37:13 +01:00
|
|
|
|
2022-11-26 19:05:44 +01:00
|
|
|
It is here to reduce repetition of if-else closes in the different bot methods,
|
|
|
|
i.e. this method takes care of adding its parameters to `data` if appropriate.
|
|
|
|
|
|
|
|
Depending on the bot method, returns either `True` or the message.
|
2022-12-15 15:00:36 +01:00
|
|
|
However, it's hard to tell mypy which methods expects which of these return values and
|
|
|
|
using `Any` instead saves us a lot of `type: ignore` comments
|
2022-11-26 19:05:44 +01:00
|
|
|
"""
|
2021-10-03 15:10:13 +02:00
|
|
|
# We don't check if (DEFAULT_)None here, so that _post is able to insert the defaults
|
2024-02-08 17:12:00 +01:00
|
|
|
# correctly, if necessary:
|
|
|
|
if allow_sending_without_reply is not DEFAULT_NONE and reply_parameters is not None:
|
|
|
|
raise ValueError(
|
|
|
|
"`allow_sending_without_reply` and `reply_parameters` are mutually exclusive."
|
|
|
|
)
|
|
|
|
|
|
|
|
if reply_to_message_id is not None and reply_parameters is not None:
|
|
|
|
raise ValueError(
|
|
|
|
"`reply_to_message_id` and `reply_parameters` are mutually exclusive."
|
|
|
|
)
|
|
|
|
|
|
|
|
if reply_to_message_id is not None:
|
|
|
|
reply_parameters = ReplyParameters(
|
|
|
|
message_id=reply_to_message_id,
|
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
|
|
|
)
|
|
|
|
|
2021-02-19 19:07:48 +01:00
|
|
|
data["disable_notification"] = disable_notification
|
2022-01-07 17:02:23 +01:00
|
|
|
data["protect_content"] = protect_content
|
2022-11-26 19:05:44 +01:00
|
|
|
data["parse_mode"] = parse_mode
|
2024-02-08 17:12:00 +01:00
|
|
|
data["reply_parameters"] = reply_parameters
|
2022-11-26 19:05:44 +01:00
|
|
|
|
2024-02-08 17:12:00 +01:00
|
|
|
if link_preview_options is not None:
|
|
|
|
data["link_preview_options"] = link_preview_options
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2019-02-13 11:37:13 +01:00
|
|
|
if reply_markup is not None:
|
2022-04-24 12:38:09 +02:00
|
|
|
data["reply_markup"] = reply_markup
|
2019-02-13 11:37:13 +01:00
|
|
|
|
2022-11-22 10:43:50 +01:00
|
|
|
if message_thread_id is not None:
|
|
|
|
data["message_thread_id"] = message_thread_id
|
|
|
|
|
2022-11-26 19:05:44 +01:00
|
|
|
if caption is not None:
|
|
|
|
data["caption"] = caption
|
|
|
|
|
|
|
|
if caption_entities is not None:
|
|
|
|
data["caption_entities"] = caption_entities
|
|
|
|
|
2024-04-12 11:58:25 +02:00
|
|
|
if business_connection_id is not None:
|
|
|
|
data["business_connection_id"] = business_connection_id
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
endpoint,
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2019-02-13 11:37:13 +01:00
|
|
|
|
|
|
|
if result is True:
|
2020-10-31 16:33:34 +01:00
|
|
|
return result
|
2019-02-13 11:37:13 +01:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return Message.de_json(result, self)
|
2019-02-13 11:37:13 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def initialize(self) -> None:
|
|
|
|
"""Initialize resources used by this class. Currently calls :meth:`get_me` to
|
|
|
|
cache :attr:`bot` and calls :meth:`telegram.request.BaseRequest.initialize` for
|
|
|
|
the request objects used by this bot.
|
|
|
|
|
2022-05-06 17:15:23 +02:00
|
|
|
.. seealso:: :meth:`shutdown`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2022-04-24 12:38:09 +02:00
|
|
|
"""
|
|
|
|
if self._initialized:
|
2023-04-10 17:01:35 +02:00
|
|
|
self._LOGGER.debug("This Bot is already initialized.")
|
2022-04-24 12:38:09 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
await asyncio.gather(self._request[0].initialize(), self._request[1].initialize())
|
2022-08-03 08:16:48 +02:00
|
|
|
# Since the bot is to be initialized only once, we can also use it for
|
|
|
|
# verifying the token passed and raising an exception if it's invalid.
|
|
|
|
try:
|
|
|
|
await self.get_me()
|
|
|
|
except InvalidToken as exc:
|
2022-09-18 15:42:12 +02:00
|
|
|
raise InvalidToken(f"The token `{self._token}` was rejected by the server.") from exc
|
2022-04-24 12:38:09 +02:00
|
|
|
self._initialized = True
|
|
|
|
|
|
|
|
async def shutdown(self) -> None:
|
|
|
|
"""Stop & clear resources used by this class. Currently just calls
|
|
|
|
:meth:`telegram.request.BaseRequest.shutdown` for the request objects used by this bot.
|
|
|
|
|
2022-05-06 17:15:23 +02:00
|
|
|
.. seealso:: :meth:`initialize`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2022-04-24 12:38:09 +02:00
|
|
|
"""
|
|
|
|
if not self._initialized:
|
2023-04-10 17:01:35 +02:00
|
|
|
self._LOGGER.debug("This Bot is already shut down. Returning.")
|
2022-04-24 12:38:09 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
await asyncio.gather(self._request[0].shutdown(), self._request[1].shutdown())
|
|
|
|
self._initialized = False
|
|
|
|
|
2024-02-07 22:35:09 +01:00
|
|
|
async def do_api_request(
|
|
|
|
self,
|
|
|
|
endpoint: str,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
|
|
|
return_type: Optional[Type[TelegramObject]] = None,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
) -> Any:
|
|
|
|
"""Do a request to the Telegram API.
|
|
|
|
|
|
|
|
This method is here to make it easier to use new API methods that are not yet supported
|
|
|
|
by this library.
|
|
|
|
|
|
|
|
Hint:
|
|
|
|
Since PTB does not know which arguments are passed to this method, some caution is
|
|
|
|
necessary in terms of PTBs utility functionalities. In particular
|
|
|
|
|
|
|
|
* passing objects of any class defined in the :mod:`telegram` module is supported
|
|
|
|
* when uploading files, a :class:`telegram.InputFile` must be passed as the value for
|
|
|
|
the corresponding argument. Passing a file path or file-like object will not work.
|
|
|
|
File paths will work only in combination with :paramref:`~Bot.local_mode`.
|
|
|
|
* when uploading files, PTB can still correctly determine that
|
|
|
|
a special write timeout value should be used instead of the default
|
|
|
|
:paramref:`telegram.request.HTTPXRequest.write_timeout`.
|
|
|
|
* insertion of default values specified via :class:`telegram.ext.Defaults` will not
|
|
|
|
work (only relevant for :class:`telegram.ext.ExtBot`).
|
|
|
|
* The only exception is :class:`telegram.ext.Defaults.tzinfo`, which will be correctly
|
|
|
|
applied to :class:`datetime.datetime` objects.
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-07 22:35:09 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
endpoint (:obj:`str`): The API endpoint to use, e.g. ``getMe`` or ``get_me``.
|
|
|
|
api_kwargs (:obj:`dict`, optional): The keyword arguments to pass to the API call.
|
|
|
|
If not specified, no arguments are passed.
|
|
|
|
return_type (:class:`telegram.TelegramObject`, optional): If specified, the result of
|
|
|
|
the API call will be deserialized into an instance of this class or tuple of
|
|
|
|
instances of this class. If not specified, the raw result of the API call will be
|
|
|
|
returned.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
The result of the API call. If :paramref:`return_type` is not specified, this is a
|
|
|
|
:obj:`dict` or :obj:`bool`, otherwise an instance of :paramref:`return_type` or a
|
|
|
|
tuple of :paramref:`return_type`.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
if hasattr(self, endpoint):
|
|
|
|
self._warn(
|
|
|
|
(
|
|
|
|
f"Please use 'Bot.{endpoint}' instead of "
|
|
|
|
f"'Bot.do_api_request(\"{endpoint}\", ...)'"
|
|
|
|
),
|
|
|
|
PTBDeprecationWarning,
|
2024-03-24 12:34:08 +01:00
|
|
|
stacklevel=2,
|
2024-02-07 22:35:09 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
camel_case_endpoint = to_camel_case(endpoint)
|
|
|
|
try:
|
|
|
|
result = await self._post(
|
|
|
|
camel_case_endpoint,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
)
|
|
|
|
except InvalidToken as exc:
|
|
|
|
# TG returns 404 Not found for
|
|
|
|
# 1) malformed tokens
|
|
|
|
# 2) correct tokens but non-existing method, e.g. api.tg.org/botTOKEN/unkonwnMethod
|
|
|
|
# 2) is relevant only for Bot.do_api_request, that's why we have special handling for
|
|
|
|
# that here rather than in BaseRequest._request_wrapper
|
|
|
|
if self._initialized:
|
|
|
|
raise EndPointNotFound(
|
|
|
|
f"Endpoint '{camel_case_endpoint}' not found in Bot API"
|
|
|
|
) from exc
|
|
|
|
|
|
|
|
raise InvalidToken(
|
|
|
|
"Either the bot token was rejected by Telegram or the endpoint "
|
|
|
|
f"'{camel_case_endpoint}' does not exist."
|
|
|
|
) from exc
|
|
|
|
|
|
|
|
if return_type is None or isinstance(result, bool):
|
|
|
|
return result
|
|
|
|
|
|
|
|
if isinstance(result, list):
|
|
|
|
return return_type.de_list(result, self)
|
|
|
|
return return_type.de_json(result, self)
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_me(
|
|
|
|
self,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
) -> User:
|
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
|
|
|
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getMe",
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
self._bot_user = User.de_json(result, self)
|
2021-10-21 11:17:12 +02:00
|
|
|
return self._bot_user # type: ignore[return-value]
|
2015-07-20 12:53:58 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_message(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
|
|
|
text: str,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
entities: Optional[Sequence["MessageEntity"]] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
link_preview_options: ODVInput["LinkPreviewOptions"] = DEFAULT_NONE,
|
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
|
|
|
disable_web_page_preview: Optional[bool] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
2017-09-01 08:43:08 +02:00
|
|
|
"""Use this method to send text messages.
|
2015-07-08 00:54:00 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2021-10-19 18:28:19 +02:00
|
|
|
text (:obj:`str`): Text of the message to be sent. Max
|
2022-11-22 11:07:42 +01:00
|
|
|
:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters after
|
|
|
|
entities parsing.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
parse_mode (:obj:`str`): |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
entities (Sequence[:class:`telegram.MessageEntity`], optional): Sequence of special
|
|
|
|
entities that appear in message text, which can be specified instead of
|
2022-02-09 17:30:16 +01:00
|
|
|
:paramref:`parse_mode`.
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2024-02-08 17:12:00 +01:00
|
|
|
link_preview_options (:obj:`LinkPreviewOptions`, optional): Link preview generation
|
|
|
|
options for the message. Mutually exclusive with
|
|
|
|
:paramref:`disable_web_page_preview`.
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.0
|
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
|
|
|
|
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2022-11-22 10:43:50 +01:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
disable_web_page_preview (:obj:`bool`, optional): Disables link previews for links in
|
|
|
|
this message. Convenience parameter for setting :paramref:`link_preview_options`.
|
|
|
|
Mutually exclusive with :paramref:`link_preview_options`.
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`link_preview_options` replacing this
|
|
|
|
argument. PTB will automatically convert this argument to that one, but
|
|
|
|
for advanced options, please use :paramref:`link_preview_options` directly.
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +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:
|
2024-02-08 17:12:00 +01:00
|
|
|
:exc:`ValueError`: If both :paramref:`disable_web_page_preview` and
|
|
|
|
:paramref:`link_preview_options` are passed.
|
|
|
|
:class:`telegram.error.TelegramError`: For other errors.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "text": text, "entities": entities}
|
2024-02-25 10:34:47 +01:00
|
|
|
link_preview_options = parse_lpo_and_dwpp(disable_web_page_preview, link_preview_options)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendMessage",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2022-11-26 19:05:44 +01:00
|
|
|
parse_mode=parse_mode,
|
2024-02-08 17:12:00 +01:00
|
|
|
link_preview_options=link_preview_options,
|
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def delete_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2021-03-14 16:42:03 +01:00
|
|
|
message_id: int,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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:
|
|
|
|
|
2022-08-27 11:46:51 +02:00
|
|
|
- A message can only be deleted if it was sent less than 48 hours ago.
|
2022-11-22 10:43:50 +01:00
|
|
|
- Service messages about a supergroup, channel, or forum topic creation can't be deleted.
|
2022-08-27 11:46:51 +02:00
|
|
|
- A dice message in a private chat can only be deleted if it was sent more than 24
|
|
|
|
hours ago.
|
|
|
|
- Bots can delete outgoing messages in private chats, groups, and supergroups.
|
|
|
|
- Bots can delete incoming messages in private chats.
|
|
|
|
- Bots granted :attr:`~telegram.ChatMemberAdministrator.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 :attr:`~telegram.ChatMemberAdministrator.can_delete_messages`
|
|
|
|
permission in a supergroup or a channel, it can delete any message there.
|
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
..
|
|
|
|
The method CallbackQuery.delete_message() will not be found when automatically
|
|
|
|
generating "Shortcuts" admonitions for Bot methods because it has no calls
|
|
|
|
to Bot methods in its return statement(s). So it is manually included in "See also".
|
|
|
|
|
|
|
|
.. seealso::
|
|
|
|
:meth:`telegram.CallbackQuery.delete_message` (calls :meth:`delete_message`
|
|
|
|
indirectly, via :meth:`telegram.Message.delete`)
|
2017-05-12 17:40:57 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2017-07-23 22:33:08 +02:00
|
|
|
message_id (:obj:`int`): Identifier of the message to delete.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "message_id": message_id}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"deleteMessage",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-05-12 17:40:57 +02:00
|
|
|
|
2024-02-08 17:12:00 +01:00
|
|
|
async def delete_messages(
|
|
|
|
self,
|
|
|
|
chat_id: Union[int, str],
|
|
|
|
message_ids: Sequence[int],
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to delete multiple messages simultaneously. If some of the specified
|
|
|
|
messages can't be found, they are skipped.
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2024-03-06 14:45:50 +01:00
|
|
|
message_ids (Sequence[:obj:`int`]): A list of
|
2024-02-08 17:12:00 +01:00
|
|
|
:tg-const:`telegram.constants.BulkRequestLimit.MIN_LIMIT`-
|
2024-03-06 14:45:50 +01:00
|
|
|
:tg-const:`telegram.constants.BulkRequestLimit.MAX_LIMIT` identifiers of messages
|
|
|
|
to delete. See :meth:`delete_message` for limitations on which messages can be
|
|
|
|
deleted.
|
2024-02-08 17:12:00 +01:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id, "message_ids": message_ids}
|
|
|
|
return await self._post(
|
|
|
|
"deleteMessages",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def forward_message(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
|
|
|
from_chat_id: Union[str, int],
|
2021-03-14 16:42:03 +01:00
|
|
|
message_id: int,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
2022-05-18 17:18:44 +02:00
|
|
|
"""
|
|
|
|
Use this method to forward messages of any kind. Service messages can't be forwarded.
|
2015-07-08 00:54:00 +02:00
|
|
|
|
2021-12-11 15:21:56 +01:00
|
|
|
Note:
|
|
|
|
Since the release of Bot API 5.5 it can be impossible to forward messages from
|
|
|
|
some chats. Use the attributes :attr:`telegram.Message.has_protected_content` and
|
|
|
|
:attr:`telegram.Chat.has_protected_content` to check this.
|
|
|
|
|
|
|
|
As a workaround, it is still possible to use :meth:`copy_message`. However, this
|
|
|
|
behaviour is undocumented and might be changed by Telegram.
|
|
|
|
|
2015-07-08 00:54:00 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2017-07-23 22:33:08 +02:00
|
|
|
from_chat_id (:obj:`int` | :obj:`str`): Unique identifier for the chat where the
|
2021-04-30 10:47:41 +02:00
|
|
|
original message was sent (or channel username in the format ``@channelusername``).
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
message_id (:obj:`int`): Message identifier in the chat specified in
|
|
|
|
:paramref:`from_chat_id`.
|
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2022-01-03 08:13:33 +01: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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"from_chat_id": from_chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
}
|
2016-04-19 14:04:25 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"forwardMessage",
|
|
|
|
data,
|
|
|
|
disable_notification=disable_notification,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
2024-02-08 17:12:00 +01:00
|
|
|
async def forward_messages(
|
|
|
|
self,
|
|
|
|
chat_id: Union[int, str],
|
|
|
|
from_chat_id: Union[str, int],
|
|
|
|
message_ids: Sequence[int],
|
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
|
|
|
) -> Tuple[MessageId, ...]:
|
|
|
|
"""
|
|
|
|
Use this method to forward messages of any kind. If some of the specified messages can't be
|
|
|
|
found or forwarded, they are skipped. Service messages and messages with protected content
|
|
|
|
can't be forwarded. Album grouping is kept for forwarded messages.
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
|
|
|
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``).
|
2024-03-06 14:45:50 +01:00
|
|
|
message_ids (Sequence[:obj:`int`]): A list of
|
2024-02-08 17:12:00 +01:00
|
|
|
:tg-const:`telegram.constants.BulkRequestLimit.MIN_LIMIT`-
|
2024-03-06 14:45:50 +01:00
|
|
|
:tg-const:`telegram.constants.BulkRequestLimit.MAX_LIMIT` identifiers of messages
|
|
|
|
in the chat :paramref:`from_chat_id` to forward. The identifiers must be specified
|
|
|
|
in a strictly increasing order.
|
2024-02-08 17:12:00 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Tuple[:class:`telegram.Message`]: On success, a tuple of ``MessageId`` of sent messages
|
|
|
|
is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"from_chat_id": from_chat_id,
|
|
|
|
"message_ids": message_ids,
|
|
|
|
"disable_notification": disable_notification,
|
|
|
|
"protect_content": protect_content,
|
|
|
|
"message_thread_id": message_thread_id,
|
|
|
|
}
|
|
|
|
|
|
|
|
result = await self._post(
|
|
|
|
"forwardMessages",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
return MessageId.de_list(result, self)
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_photo(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2021-03-14 16:42:03 +01:00
|
|
|
chat_id: Union[int, str],
|
2020-12-30 13:41:07 +01:00
|
|
|
photo: Union[FileInput, "PhotoSize"],
|
2023-05-18 07:57:59 +02:00
|
|
|
caption: Optional[str] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
has_spoiler: Optional[bool] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
filename: Optional[str] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
2017-09-01 08:43:08 +02:00
|
|
|
"""Use this method to send photos.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2015-07-08 00:54:00 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-02-09 17:30:16 +01:00
|
|
|
photo (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.PhotoSize`): Photo to send.
|
2022-09-19 22:31:23 +02:00
|
|
|
|fileinput|
|
|
|
|
Lastly you can pass an existing :class:`telegram.PhotoSize` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
2023-01-01 16:24:00 +01:00
|
|
|
Caution:
|
|
|
|
* The photo must be at most 10MB in size.
|
|
|
|
* The photo's width and height must not exceed 10000 in total.
|
|
|
|
* Width and height ratio must be at most 20.
|
|
|
|
|
2020-12-18 11:20:03 +01:00
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2022-09-19 22:31:23 +02:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
File paths as input is also accepted for bots *not* running in
|
|
|
|
:paramref:`~telegram.Bot.local_mode`.
|
2017-07-23 22:33:08 +02:00
|
|
|
caption (:obj:`str`, optional): Photo caption (may also be used when resending photos
|
2021-10-19 18:28:19 +02:00
|
|
|
by file_id), 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH`
|
|
|
|
characters after entities parsing.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|
|
|
|
|caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2022-01-19 18:00:21 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
2023-01-01 17:00:49 +01:00
|
|
|
has_spoiler (:obj:`bool`, optional): Pass :obj:`True` if the photo needs to be covered
|
|
|
|
with a spoiler animation.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2022-05-18 17:18:44 +02:00
|
|
|
|
|
|
|
Keyword Args:
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the photo, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
|
|
|
|
|
|
|
.. versionadded:: 13.1
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-12-16 14:28:53 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
2022-09-19 22:31:23 +02:00
|
|
|
"photo": self._parse_file_input(photo, PhotoSize, filename=filename),
|
2023-01-01 17:00:49 +01:00
|
|
|
"has_spoiler": has_spoiler,
|
2020-12-16 14:28:53 +01:00
|
|
|
}
|
2015-07-07 23:46:32 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendPhoto",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2022-11-26 19:05:44 +01:00
|
|
|
caption=caption,
|
|
|
|
parse_mode=parse_mode,
|
|
|
|
caption_entities=caption_entities,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_audio(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2020-12-30 13:41:07 +01:00
|
|
|
audio: Union[FileInput, "Audio"],
|
2023-05-18 07:57:59 +02:00
|
|
|
duration: Optional[int] = None,
|
|
|
|
performer: Optional[str] = None,
|
|
|
|
title: Optional[str] = None,
|
|
|
|
caption: Optional[str] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2022-01-07 17:02:23 +01:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
thumbnail: Optional[FileInput] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
filename: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-05-18 17:18:44 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
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
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
music player. Your audio must be in the ``.mp3`` or ``.m4a`` format.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
2021-10-19 18:28:19 +02:00
|
|
|
Bots can currently send audio files of up to
|
|
|
|
:tg-const:`telegram.constants.FileSizeLimit.FILESIZE_UPLOAD` in size, this limit may be
|
|
|
|
changed in the future.
|
2015-08-17 16:34:42 +02:00
|
|
|
|
2021-04-30 10:47:41 +02:00
|
|
|
For sending voice messages, use the :meth:`send_voice` method instead.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
|removed_thumb_arg|
|
|
|
|
|
2015-07-08 01:10:43 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-02-09 17:30:16 +01:00
|
|
|
audio (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.Audio`): Audio file to send.
|
2022-09-19 22:31:23 +02:00
|
|
|
|fileinput|
|
|
|
|
Lastly you can pass an existing :class:`telegram.Audio` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2022-09-19 22:31:23 +02:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
File paths as input is also accepted for bots *not* running in
|
|
|
|
:paramref:`~telegram.Bot.local_mode`.
|
2021-10-19 18:28:19 +02:00
|
|
|
caption (:obj:`str`, optional): Audio caption,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after
|
|
|
|
entities parsing.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|
|
|
|
|caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
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.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2022-01-19 18:00:21 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstring|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters (:obj:`ReplyParameters`, optional): |reply_parameters|
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2022-05-18 17:18:44 +02:00
|
|
|
Keyword Args:
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the audio, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
|
|
|
|
|
|
|
.. versionadded:: 13.1
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-12-16 14:28:53 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
2022-09-19 22:31:23 +02:00
|
|
|
"audio": self._parse_file_input(audio, Audio, filename=filename),
|
2022-12-01 19:26:01 +01:00
|
|
|
"duration": duration,
|
|
|
|
"performer": performer,
|
|
|
|
"title": title,
|
2023-09-03 14:23:48 +02:00
|
|
|
"thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None,
|
2020-12-16 14:28:53 +01:00
|
|
|
}
|
2015-07-08 01:10:43 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendAudio",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2022-11-26 19:05:44 +01:00
|
|
|
caption=caption,
|
|
|
|
parse_mode=parse_mode,
|
|
|
|
caption_entities=caption_entities,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2015-07-08 01:10:43 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_document(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2020-12-30 13:41:07 +01:00
|
|
|
document: Union[FileInput, "Document"],
|
2023-05-18 07:57:59 +02:00
|
|
|
caption: Optional[str] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
disable_content_type_detection: Optional[bool] = None,
|
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2022-01-07 17:02:23 +01:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
thumbnail: Optional[FileInput] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
filename: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-05-18 17:18:44 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
2020-04-10 20:05:01 +02:00
|
|
|
"""
|
|
|
|
Use this method to send general files.
|
|
|
|
|
2021-10-19 18:28:19 +02:00
|
|
|
Bots can currently send files of any type of up to
|
|
|
|
:tg-const:`telegram.constants.FileSizeLimit.FILESIZE_UPLOAD` in size, this limit may be
|
2020-04-10 20:05:01 +02:00
|
|
|
changed in the future.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
|removed_thumb_arg|
|
|
|
|
|
2015-07-08 02:12:51 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-02-09 17:30:16 +01:00
|
|
|
document (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.Document`): File to send.
|
2022-09-19 22:31:23 +02:00
|
|
|
|fileinput|
|
|
|
|
Lastly you can pass an existing :class:`telegram.Document` object to send.
|
|
|
|
|
|
|
|
Note:
|
|
|
|
Sending by URL will currently only work ``GIF``, ``PDF`` & ``ZIP`` files.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2022-09-19 22:31:23 +02:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
File paths as input is also accepted for bots *not* running in
|
|
|
|
:paramref:`~telegram.Bot.local_mode`.
|
2017-07-23 22:33:08 +02:00
|
|
|
caption (:obj:`str`, optional): Document caption (may also be used when resending
|
2021-10-19 18:28:19 +02:00
|
|
|
documents by file_id), 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH`
|
|
|
|
characters after entities parsing.
|
2020-11-29 16:20:46 +01:00
|
|
|
disable_content_type_detection (:obj:`bool`, optional): Disables automatic server-side
|
|
|
|
content type detection for files uploaded using multipart/form-data.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|
|
|
|
|caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2022-01-19 18:00:21 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstring|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2022-05-18 17:18:44 +02:00
|
|
|
Keyword Args:
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the document, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-11-29 16:20:46 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
2022-09-19 22:31:23 +02:00
|
|
|
"document": self._parse_file_input(document, Document, filename=filename),
|
2022-12-01 19:26:01 +01:00
|
|
|
"disable_content_type_detection": disable_content_type_detection,
|
2023-09-03 14:23:48 +02:00
|
|
|
"thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None,
|
2020-11-29 16:20:46 +01:00
|
|
|
}
|
2015-07-08 02:12:51 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendDocument",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2022-11-26 19:05:44 +01:00
|
|
|
caption=caption,
|
|
|
|
parse_mode=parse_mode,
|
|
|
|
caption_entities=caption_entities,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2015-07-08 02:12:51 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_sticker(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2020-12-30 13:41:07 +01:00
|
|
|
sticker: Union[FileInput, "Sticker"],
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
emoji: Optional[str] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
2020-04-10 20:05:01 +02:00
|
|
|
"""
|
2022-02-02 21:05:46 +01:00
|
|
|
Use this method to send static ``.WEBP``, animated ``.TGS``, or video ``.WEBM`` stickers.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2015-07-08 14:17:18 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-02-09 17:30:16 +01:00
|
|
|
sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.Sticker`): Sticker to send.
|
2024-04-12 11:58:25 +02:00
|
|
|
|fileinput| Video stickers can only be sent by a ``file_id``. Video and animated
|
|
|
|
stickers can't be sent via an HTTP URL.
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
Lastly you can pass an existing :class:`telegram.Sticker` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2022-09-19 22:31:23 +02:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
File paths as input is also accepted for bots *not* running in
|
|
|
|
:paramref:`~telegram.Bot.local_mode`.
|
2023-03-25 11:47:26 +01:00
|
|
|
emoji (:obj:`str`, optional): Emoji associated with the sticker; only for just
|
|
|
|
uploaded stickers
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2023-03-25 11:47:26 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"sticker": self._parse_file_input(sticker, Sticker),
|
|
|
|
"emoji": emoji,
|
|
|
|
}
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendSticker",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2015-07-08 04:52:12 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_video(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2020-12-30 13:41:07 +01:00
|
|
|
video: Union[FileInput, "Video"],
|
2023-05-18 07:57:59 +02:00
|
|
|
duration: Optional[int] = None,
|
|
|
|
caption: Optional[str] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
|
|
|
width: Optional[int] = None,
|
|
|
|
height: Optional[int] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
supports_streaming: Optional[bool] = None,
|
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2022-01-07 17:02:23 +01:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
has_spoiler: Optional[bool] = None,
|
|
|
|
thumbnail: Optional[FileInput] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
filename: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-05-18 17:18:44 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
2023-03-25 11:47:26 +01:00
|
|
|
"""Use this method to send video files, Telegram clients support mp4 videos
|
2017-07-23 22:33:08 +02:00
|
|
|
(other formats may be sent as Document).
|
|
|
|
|
2021-10-19 18:28:19 +02:00
|
|
|
Bots can currently send video files of up to
|
|
|
|
:tg-const:`telegram.constants.FileSizeLimit.FILESIZE_UPLOAD` in size, this limit may be
|
|
|
|
changed in the future.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
2017-07-23 22:33:08 +02:00
|
|
|
Note:
|
2023-09-03 14:23:48 +02:00
|
|
|
:paramref:`thumbnail` will be ignored for small video files, for which Telegram can
|
2022-09-19 22:31:23 +02:00
|
|
|
easily generate thumbnails. However, this behaviour is undocumented and might be
|
|
|
|
changed by Telegram.
|
2015-07-08 14:17:18 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
|removed_thumb_arg|
|
|
|
|
|
2015-07-08 14:17:18 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-02-09 17:30:16 +01:00
|
|
|
video (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.Video`): Video file to send.
|
2022-09-19 22:31:23 +02:00
|
|
|
|fileinput|
|
|
|
|
Lastly you can pass an existing :class:`telegram.Video` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2022-09-19 22:31:23 +02:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
File paths as input is also accepted for bots *not* running in
|
|
|
|
:paramref:`~telegram.Bot.local_mode`.
|
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
|
2021-10-19 18:28:19 +02:00
|
|
|
by file_id), 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH`
|
|
|
|
characters after entities parsing.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|
|
|
|
|caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
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.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
2022-01-19 18:00:21 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
2023-01-01 17:00:49 +01:00
|
|
|
has_spoiler (:obj:`bool`, optional): Pass :obj:`True` if the video needs to be covered
|
|
|
|
with a spoiler animation.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstring|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2022-09-19 22:31:23 +02:00
|
|
|
|
2022-05-18 17:18:44 +02:00
|
|
|
Keyword Args:
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the video, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
|
|
|
|
|
|
|
.. versionadded:: 13.1
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-12-16 14:28:53 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
2022-09-19 22:31:23 +02:00
|
|
|
"video": self._parse_file_input(video, Video, filename=filename),
|
2022-12-01 19:26:01 +01:00
|
|
|
"duration": duration,
|
|
|
|
"width": width,
|
|
|
|
"height": height,
|
|
|
|
"supports_streaming": supports_streaming,
|
2023-09-03 14:23:48 +02:00
|
|
|
"thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None,
|
2023-01-01 17:00:49 +01:00
|
|
|
"has_spoiler": has_spoiler,
|
2020-12-16 14:28:53 +01:00
|
|
|
}
|
2015-07-08 14:17:18 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendVideo",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2022-11-26 19:05:44 +01:00
|
|
|
caption=caption,
|
|
|
|
parse_mode=parse_mode,
|
|
|
|
caption_entities=caption_entities,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2015-07-08 14:17:18 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_video_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
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2020-12-30 13:41:07 +01:00
|
|
|
video_note: Union[FileInput, "VideoNote"],
|
2023-05-18 07:57:59 +02:00
|
|
|
duration: Optional[int] = None,
|
|
|
|
length: Optional[int] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
thumbnail: Optional[FileInput] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
filename: Optional[str] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
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:
|
2023-09-03 14:23:48 +02:00
|
|
|
:paramref:`thumbnail` will be ignored for small video files, for which Telegram can
|
2022-09-19 22:31:23 +02:00
|
|
|
easily generate thumbnails. However, this behaviour is undocumented and might be
|
|
|
|
changed by Telegram.
|
2015-08-17 16:34:42 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
|removed_thumb_arg|
|
|
|
|
|
2015-08-17 16:34:42 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-02-09 17:30:16 +01:00
|
|
|
video_note (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2022-09-19 22:31:23 +02:00
|
|
|
: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.
|
|
|
|
|uploadinput|
|
|
|
|
Lastly you can pass an existing :class:`telegram.VideoNote` object to send.
|
|
|
|
Sending video notes by a URL is currently unsupported.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2022-09-19 22:31:23 +02:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
File paths as input is also accepted for bots *not* running in
|
|
|
|
:paramref:`~telegram.Bot.local_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
|
|
|
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.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2022-01-19 18:00:21 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstring|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2022-05-18 17:18:44 +02:00
|
|
|
Keyword Args:
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the video note, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
|
|
|
|
|
|
|
.. versionadded:: 13.1
|
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
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.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
|
|
|
|
|
|
|
"""
|
2020-11-29 16:20:46 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
2022-09-19 22:31:23 +02:00
|
|
|
"video_note": self._parse_file_input(video_note, VideoNote, filename=filename),
|
2022-12-01 19:26:01 +01:00
|
|
|
"duration": duration,
|
|
|
|
"length": length,
|
2023-09-03 14:23:48 +02:00
|
|
|
"thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None,
|
2020-11-29 16:20:46 +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
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendVideoNote",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +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
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_animation(
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2020-12-30 13:41:07 +01:00
|
|
|
animation: Union[FileInput, "Animation"],
|
2023-05-18 07:57:59 +02:00
|
|
|
duration: Optional[int] = None,
|
|
|
|
width: Optional[int] = None,
|
|
|
|
height: Optional[int] = None,
|
|
|
|
caption: Optional[str] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
has_spoiler: Optional[bool] = None,
|
|
|
|
thumbnail: Optional[FileInput] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
filename: Optional[str] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> 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
|
|
|
"""
|
|
|
|
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
|
2021-10-19 18:28:19 +02:00
|
|
|
Bots can currently send animation files of up to
|
|
|
|
:tg-const:`telegram.constants.FileSizeLimit.FILESIZE_UPLOAD` 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
|
|
|
|
2020-10-07 17:12:05 +02:00
|
|
|
Note:
|
2023-09-03 14:23:48 +02:00
|
|
|
:paramref:`thumbnail` will be ignored for small files, for which Telegram can easily
|
2022-09-19 22:31:23 +02:00
|
|
|
generate thumbnails. However, this behaviour is undocumented and might be changed
|
2020-10-07 17:12:05 +02:00
|
|
|
by Telegram.
|
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
|removed_thumb_arg|
|
|
|
|
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-02-09 17:30:16 +01:00
|
|
|
animation (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2022-09-19 22:31:23 +02:00
|
|
|
:class:`telegram.Animation`): Animation to send.
|
|
|
|
|fileinput|
|
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
|
|
|
Lastly you can pass an existing :class:`telegram.Animation` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
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
|
|
|
duration (:obj:`int`, optional): Duration of sent animation in seconds.
|
|
|
|
width (:obj:`int`, optional): Animation width.
|
|
|
|
height (:obj:`int`, optional): Animation height.
|
|
|
|
caption (:obj:`str`, optional): Animation caption (may also be used when resending
|
2021-10-19 18:28:19 +02:00
|
|
|
animations by file_id),
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after
|
|
|
|
entities parsing.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|
|
|
|
|caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
2022-01-19 18:00:21 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
2023-01-01 17:00:49 +01:00
|
|
|
has_spoiler (:obj:`bool`, optional): Pass :obj:`True` if the animation needs to be
|
|
|
|
covered with a spoiler animation.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstring|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2022-05-18 17:18:44 +02:00
|
|
|
|
|
|
|
Keyword Args:
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the animation, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
|
|
|
|
|
|
|
.. versionadded:: 13.1
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-12-16 14:28:53 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
2022-09-19 22:31:23 +02:00
|
|
|
"animation": self._parse_file_input(animation, Animation, filename=filename),
|
2022-12-01 19:26:01 +01:00
|
|
|
"duration": duration,
|
|
|
|
"width": width,
|
|
|
|
"height": height,
|
2023-09-03 14:23:48 +02:00
|
|
|
"thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None,
|
2023-01-01 17:00:49 +01:00
|
|
|
"has_spoiler": has_spoiler,
|
2020-12-16 14:28:53 +01:00
|
|
|
}
|
2015-08-17 16:34:42 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendAnimation",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2022-11-26 19:05:44 +01:00
|
|
|
caption=caption,
|
|
|
|
parse_mode=parse_mode,
|
|
|
|
caption_entities=caption_entities,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2015-08-17 16:34:42 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_voice(
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2020-12-30 13:41:07 +01:00
|
|
|
voice: Union[FileInput, "Voice"],
|
2023-05-18 07:57:59 +02:00
|
|
|
duration: Optional[int] = None,
|
|
|
|
caption: Optional[str] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
filename: Optional[str] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> 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
|
|
|
"""
|
|
|
|
Use this method to send audio files, if you want Telegram clients to display the file
|
2022-04-24 12:38:09 +02:00
|
|
|
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
|
2021-10-19 18:28:19 +02:00
|
|
|
send voice messages of up to :tg-const:`telegram.constants.FileSizeLimit.FILESIZE_UPLOAD`
|
|
|
|
in size, this limit may be changed in the future.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
Note:
|
2022-09-19 22:31:23 +02:00
|
|
|
To use this method, the file must have the type :mimetype:`audio/ogg` and be no more
|
2022-11-22 11:07:42 +01:00
|
|
|
than :tg-const:`telegram.constants.FileSizeLimit.VOICE_NOTE_FILE_SIZE` in size.
|
|
|
|
:tg-const:`telegram.constants.FileSizeLimit.VOICE_NOTE_FILE_SIZE`-
|
|
|
|
:tg-const:`telegram.constants.FileSizeLimit.FILESIZE_DOWNLOAD` voice notes will be
|
|
|
|
sent as files.
|
2017-05-20 19:35:55 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2017-05-20 19:35:55 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-02-09 17:30:16 +01:00
|
|
|
voice (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.Voice`): Voice file to send.
|
2022-09-19 22:31:23 +02:00
|
|
|
|fileinput|
|
|
|
|
Lastly you can pass an existing :class:`telegram.Voice` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2022-09-19 22:31:23 +02:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
File paths as input is also accepted for bots *not* running in
|
|
|
|
:paramref:`~telegram.Bot.local_mode`.
|
2021-10-19 18:28:19 +02:00
|
|
|
caption (:obj:`str`, optional): Voice message caption,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after
|
|
|
|
entities parsing.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|
|
|
|
|caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
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
|
|
|
duration (:obj:`int`, optional): Duration of the voice message in seconds.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 13.10
|
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2022-01-19 18:00:21 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2022-05-18 17:18:44 +02:00
|
|
|
|
|
|
|
Keyword Args:
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the voice, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
|
|
|
|
|
|
|
.. versionadded:: 13.1
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-12-16 14:28:53 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
2022-09-19 22:31:23 +02:00
|
|
|
"voice": self._parse_file_input(voice, Voice, filename=filename),
|
2022-12-01 19:26:01 +01:00
|
|
|
"duration": duration,
|
2020-12-16 14:28:53 +01:00
|
|
|
}
|
2017-05-20 19:35:55 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendVoice",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2022-11-26 19:05:44 +01:00
|
|
|
caption=caption,
|
|
|
|
parse_mode=parse_mode,
|
|
|
|
caption_entities=caption_entities,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2017-05-20 19:35:55 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_media_group(
|
2017-12-08 22:38:59 +01:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2023-01-01 14:24:30 +01:00
|
|
|
media: Sequence[
|
2020-12-30 13:41:07 +01:00
|
|
|
Union["InputMediaAudio", "InputMediaDocument", "InputMediaPhoto", "InputMediaVideo"]
|
|
|
|
],
|
2021-02-19 19:07:48 +01:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-11-02 08:32:40 +01:00
|
|
|
caption: Optional[str] = None,
|
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Tuple[Message, ...]:
|
2023-01-01 16:24:00 +01:00
|
|
|
"""Use this method to send a group of photos, videos, documents or audios as an album.
|
|
|
|
Documents and audio files can be only grouped in an album with messages of the same type.
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2022-11-02 08:32:40 +01:00
|
|
|
Note:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
If you supply a :paramref:`caption` (along with either :paramref:`parse_mode` or
|
|
|
|
:paramref:`caption_entities`), then items in :paramref:`media` must have no captions,
|
|
|
|
and vice versa.
|
2022-11-02 08:32:40 +01:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
Returns a tuple instead of a list.
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2023-01-01 14:24:30 +01:00
|
|
|
media (Sequence[:class:`telegram.InputMediaAudio`,\
|
|
|
|
:class:`telegram.InputMediaDocument`, :class:`telegram.InputMediaPhoto`,\
|
|
|
|
:class:`telegram.InputMediaVideo`]): An array
|
|
|
|
describing messages to be sent, must include
|
2023-03-25 19:18:04 +01:00
|
|
|
:tg-const:`telegram.constants.MediaGroupLimit.MIN_MEDIA_LENGTH`-
|
2022-12-30 14:09:06 +01:00
|
|
|
:tg-const:`telegram.constants.MediaGroupLimit.MAX_MEDIA_LENGTH` items.
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-11-02 08:32:40 +01:00
|
|
|
caption (:obj:`str`, optional): Caption that will be added to the
|
|
|
|
first element of :paramref:`media`, so that it will be used as caption for the
|
|
|
|
whole media group.
|
|
|
|
Defaults to :obj:`None`.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2022-11-02 08:32:40 +01:00
|
|
|
parse_mode (:obj:`str` | :obj:`None`, optional):
|
|
|
|
Parse mode for :paramref:`caption`.
|
|
|
|
See the constants in :class:`telegram.constants.ParseMode` for the
|
|
|
|
available modes.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|
2022-11-02 08:32:40 +01:00
|
|
|
List of special entities for :paramref:`caption`,
|
|
|
|
which can be specified instead of :paramref:`parse_mode`.
|
|
|
|
Defaults to :obj:`None`.
|
2017-12-08 22:38:59 +01:00
|
|
|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
Returns:
|
2022-12-15 15:00:36 +01:00
|
|
|
Tuple[:class:`telegram.Message`]: An array of the sent Messages.
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-12-08 22:38:59 +01:00
|
|
|
"""
|
2022-11-02 08:32:40 +01:00
|
|
|
if caption and any(
|
|
|
|
[
|
|
|
|
any(item.caption for item in media),
|
|
|
|
any(item.caption_entities for item in media),
|
|
|
|
# if parse_mode was set explicitly, even to None, error must be raised
|
|
|
|
any(item.parse_mode is not DEFAULT_NONE for item in media),
|
|
|
|
]
|
|
|
|
):
|
|
|
|
raise ValueError("You can only supply either group caption or media with captions.")
|
|
|
|
|
|
|
|
if caption:
|
|
|
|
# Copy first item (to avoid mutation of original object), apply group caption to it.
|
|
|
|
# This will lead to the group being shown with this caption.
|
|
|
|
item_to_get_caption = copy.copy(media[0])
|
2022-12-15 15:00:36 +01:00
|
|
|
with item_to_get_caption._unfrozen():
|
|
|
|
item_to_get_caption.caption = caption
|
|
|
|
if parse_mode is not DEFAULT_NONE:
|
|
|
|
item_to_get_caption.parse_mode = parse_mode
|
|
|
|
item_to_get_caption.caption_entities = parse_sequence_arg(caption_entities)
|
2022-11-02 08:32:40 +01:00
|
|
|
|
|
|
|
# copy the list (just the references) to avoid mutating the original list
|
2023-01-01 14:24:30 +01:00
|
|
|
media = list(media)
|
2022-11-02 08:32:40 +01:00
|
|
|
media[0] = item_to_get_caption
|
|
|
|
|
2024-02-08 17:12:00 +01:00
|
|
|
if allow_sending_without_reply is not DEFAULT_NONE and reply_parameters is not None:
|
|
|
|
raise ValueError(
|
|
|
|
"`allow_sending_without_reply` and `reply_parameters` are mutually exclusive."
|
|
|
|
)
|
|
|
|
|
|
|
|
if reply_to_message_id is not None and reply_parameters is not None:
|
|
|
|
raise ValueError(
|
|
|
|
"`reply_to_message_id` and `reply_parameters` are mutually exclusive."
|
|
|
|
)
|
|
|
|
|
|
|
|
if reply_to_message_id is not None:
|
|
|
|
reply_parameters = ReplyParameters(
|
|
|
|
message_id=reply_to_message_id,
|
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
|
|
|
)
|
|
|
|
|
2021-02-19 19:07:48 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"media": media,
|
|
|
|
"disable_notification": disable_notification,
|
2022-01-07 17:02:23 +01:00
|
|
|
"protect_content": protect_content,
|
2022-12-01 19:26:01 +01:00
|
|
|
"message_thread_id": message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
"reply_parameters": reply_parameters,
|
2024-04-12 11:58:25 +02:00
|
|
|
"business_connection_id": business_connection_id,
|
2021-02-19 19:07:48 +01:00
|
|
|
}
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"sendMediaGroup",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return Message.de_list(result, self)
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_location(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2023-05-18 07:57:59 +02:00
|
|
|
latitude: Optional[float] = None,
|
|
|
|
longitude: Optional[float] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
|
|
|
live_period: Optional[int] = None,
|
|
|
|
horizontal_accuracy: Optional[float] = None,
|
|
|
|
heading: Optional[int] = None,
|
|
|
|
proximity_alert_radius: Optional[int] = None,
|
2022-01-07 17:02:23 +01:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
location: Optional[Location] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
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:
|
2022-02-09 17:30:16 +01:00
|
|
|
You can either supply a :paramref:`latitude` and :paramref:`longitude` or a
|
|
|
|
:paramref:`location`.
|
2017-07-25 00:35:22 +02:00
|
|
|
|
2015-07-08 14:37:25 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2017-07-25 00:35:22 +02:00
|
|
|
latitude (:obj:`float`, optional): Latitude of location.
|
|
|
|
longitude (:obj:`float`, optional): Longitude of location.
|
2020-11-29 16:20:46 +01:00
|
|
|
horizontal_accuracy (:obj:`int`, optional): The radius of uncertainty for the location,
|
2021-10-19 18:28:19 +02:00
|
|
|
measured in meters;
|
|
|
|
0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
|
2017-10-14 20:03:02 +02:00
|
|
|
live_period (:obj:`int`, optional): Period in seconds for which the location will be
|
2022-11-22 11:07:42 +01:00
|
|
|
updated, should be between
|
|
|
|
:tg-const:`telegram.constants.LocationLimit.MIN_LIVE_PERIOD` and
|
|
|
|
:tg-const:`telegram.constants.LocationLimit.MAX_LIVE_PERIOD`.
|
2020-11-29 16:20:46 +01:00
|
|
|
heading (:obj:`int`, optional): For live locations, a direction in which the user is
|
2022-11-22 11:07:42 +01:00
|
|
|
moving, in degrees. Must be between
|
|
|
|
:tg-const:`telegram.constants.LocationLimit.MIN_HEADING` and
|
|
|
|
:tg-const:`telegram.constants.LocationLimit.MAX_HEADING` if specified.
|
2020-11-29 16:20:46 +01:00
|
|
|
proximity_alert_radius (:obj:`int`, optional): For live locations, a maximum distance
|
|
|
|
for proximity alerts about approaching another chat member, in meters. Must be
|
2022-11-22 11:07:42 +01:00
|
|
|
between :tg-const:`telegram.constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS`
|
|
|
|
and :tg-const:`telegram.constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS`
|
|
|
|
if specified.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
location (:class:`telegram.Location`, optional): The location to send.
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +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(
|
2021-02-19 19:07:48 +01:00
|
|
|
"Either location or latitude and longitude must be passed as argument."
|
2017-10-14 20:03:02 +02:00
|
|
|
)
|
|
|
|
|
2020-10-31 16:33:34 +01:00
|
|
|
if not (latitude is not None or longitude is not None) ^ bool(location):
|
2017-10-14 20:03:02 +02:00
|
|
|
raise ValueError(
|
2021-02-19 19:07:48 +01:00
|
|
|
"Either location or latitude and longitude must be passed as argument. Not both."
|
2017-10-14 20:03:02 +02:00
|
|
|
)
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
|
|
if isinstance(location, Location):
|
|
|
|
latitude = location.latitude
|
|
|
|
longitude = location.longitude
|
|
|
|
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"latitude": latitude,
|
|
|
|
"longitude": longitude,
|
|
|
|
"horizontal_accuracy": horizontal_accuracy,
|
|
|
|
"live_period": live_period,
|
|
|
|
"heading": heading,
|
|
|
|
"proximity_alert_radius": proximity_alert_radius,
|
|
|
|
}
|
2017-10-14 20:03:02 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendLocation",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def edit_message_live_location(
|
2017-10-14 20:03:02 +02:00
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
chat_id: Optional[Union[str, int]] = None,
|
|
|
|
message_id: Optional[int] = None,
|
|
|
|
inline_message_id: Optional[str] = None,
|
|
|
|
latitude: Optional[float] = None,
|
|
|
|
longitude: Optional[float] = None,
|
2023-09-15 21:33:42 +02:00
|
|
|
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
horizontal_accuracy: Optional[float] = None,
|
|
|
|
heading: Optional[int] = None,
|
|
|
|
proximity_alert_radius: Optional[int] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
location: Optional[Location] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Union[Message, bool]:
|
2017-10-14 20:03:02 +02:00
|
|
|
"""Use this method to edit live location messages sent by the bot or via the bot
|
2021-04-30 10:47:41 +02:00
|
|
|
(for inline bots). A location can be edited until its :attr:`telegram.Location.live_period`
|
|
|
|
expires or editing is explicitly disabled by a call to :meth:`stop_message_live_location`.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
Note:
|
2022-02-09 17:30:16 +01:00
|
|
|
You can either supply a :paramref:`latitude` and :paramref:`longitude` or a
|
|
|
|
:paramref:`location`.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
Args:
|
2022-12-01 19:26:01 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if :paramref:`inline_message_id`
|
|
|
|
is not specified. |chat_id_channel|
|
|
|
|
message_id (:obj:`int`, optional): Required if :paramref:`inline_message_id` is not
|
|
|
|
specified. Identifier of the message to edit.
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if :paramref:`chat_id` and
|
|
|
|
:paramref:`message_id` are not specified. Identifier of the inline message.
|
2017-10-14 20:03:02 +02:00
|
|
|
latitude (:obj:`float`, optional): Latitude of location.
|
|
|
|
longitude (:obj:`float`, optional): Longitude of location.
|
2020-11-29 16:20:46 +01:00
|
|
|
horizontal_accuracy (:obj:`float`, optional): The radius of uncertainty for the
|
2021-10-19 18:28:19 +02:00
|
|
|
location, measured in meters;
|
|
|
|
0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
|
2020-11-29 16:20:46 +01:00
|
|
|
heading (:obj:`int`, optional): Direction in which the user is moving, in degrees. Must
|
2022-11-22 11:07:42 +01:00
|
|
|
be between :tg-const:`telegram.constants.LocationLimit.MIN_HEADING`
|
|
|
|
and :tg-const:`telegram.constants.LocationLimit.MAX_HEADING` if specified.
|
2020-11-29 16:20:46 +01:00
|
|
|
proximity_alert_radius (:obj:`int`, optional): Maximum distance for proximity alerts
|
2022-11-22 11:07:42 +01:00
|
|
|
about approaching another chat member, in meters. Must be between
|
|
|
|
:tg-const:`telegram.constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS`
|
|
|
|
and :tg-const:`telegram.constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS`
|
|
|
|
if specified.
|
2022-01-03 09:09:03 +01:00
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An object for a new
|
|
|
|
inline keyboard.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
|
|
|
Keyword Args:
|
|
|
|
location (:class:`telegram.Location`, optional): The location to send.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
Returns:
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.Message`: On success, if edited message is not an inline message, the
|
|
|
|
edited message is returned, otherwise :obj:`True` is returned.
|
2017-10-14 20:03:02 +02:00
|
|
|
"""
|
2022-05-12 19:20:24 +02:00
|
|
|
# The location parameter is a convenience functionality added by us, so enforcing the
|
|
|
|
# mutual exclusivity here is nothing that Telegram would handle anyway
|
2017-10-14 20:03:02 +02:00
|
|
|
if not (all([latitude, longitude]) or location):
|
|
|
|
raise ValueError(
|
2021-02-19 19:07:48 +01:00
|
|
|
"Either location or latitude and longitude must be passed as argument."
|
2017-10-14 20:03:02 +02:00
|
|
|
)
|
2020-10-31 16:33:34 +01:00
|
|
|
if not (latitude is not None or longitude is not None) ^ bool(location):
|
2017-10-14 20:03:02 +02:00
|
|
|
raise ValueError(
|
2021-02-19 19:07:48 +01:00
|
|
|
"Either location or latitude and longitude must be passed as argument. Not both."
|
2017-10-14 20:03:02 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if isinstance(location, Location):
|
|
|
|
latitude = location.latitude
|
|
|
|
longitude = location.longitude
|
|
|
|
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"latitude": latitude,
|
|
|
|
"longitude": longitude,
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"inline_message_id": inline_message_id,
|
|
|
|
"horizontal_accuracy": horizontal_accuracy,
|
|
|
|
"heading": heading,
|
|
|
|
"proximity_alert_radius": proximity_alert_radius,
|
|
|
|
}
|
2017-10-14 20:03:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
return await self._send_message(
|
2020-06-30 22:07:38 +02:00
|
|
|
"editMessageLiveLocation",
|
|
|
|
data,
|
|
|
|
reply_markup=reply_markup,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def stop_message_live_location(
|
2017-10-14 20:03:02 +02:00
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
chat_id: Optional[Union[str, int]] = None,
|
|
|
|
message_id: Optional[int] = None,
|
|
|
|
inline_message_id: Optional[str] = None,
|
2023-09-15 21:33:42 +02:00
|
|
|
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Union[Message, bool]:
|
2017-10-14 20:03:02 +02:00
|
|
|
"""Use this method to stop updating a live location message sent by the bot or via the bot
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
(for inline bots) before :paramref:`~telegram.Location.live_period` expires.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if :paramref:`inline_message_id`
|
|
|
|
is not specified. |chat_id_channel|
|
|
|
|
message_id (:obj:`int`, optional): Required if :paramref:`inline_message_id` is not
|
|
|
|
specified. Identifier of the sent message with live location to stop.
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if :paramref:`chat_id` and
|
|
|
|
:paramref:`message_id` are not specified. Identifier of the inline message.
|
2022-01-03 09:09:03 +01:00
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An object for a new
|
|
|
|
inline keyboard.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2017-10-14 20:03:02 +02:00
|
|
|
Returns:
|
2021-10-01 16:51:03 +02:00
|
|
|
:class:`telegram.Message`: On success, if edited message is not an inline message, the
|
|
|
|
edited message is returned, otherwise :obj:`True` is returned.
|
2017-10-14 20:03:02 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"inline_message_id": inline_message_id,
|
|
|
|
}
|
2017-10-14 20:03:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
return await self._send_message(
|
2020-06-30 22:07:38 +02:00
|
|
|
"stopMessageLiveLocation",
|
|
|
|
data,
|
|
|
|
reply_markup=reply_markup,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2015-07-08 14:37:25 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_venue(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2023-05-18 07:57:59 +02:00
|
|
|
latitude: Optional[float] = None,
|
|
|
|
longitude: Optional[float] = None,
|
|
|
|
title: Optional[str] = None,
|
|
|
|
address: Optional[str] = None,
|
|
|
|
foursquare_id: Optional[str] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
|
|
|
foursquare_type: Optional[str] = None,
|
|
|
|
google_place_id: Optional[str] = None,
|
|
|
|
google_place_type: Optional[str] = None,
|
2022-01-07 17:02:23 +01:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
venue: Optional[Venue] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
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:
|
2022-02-09 17:30:16 +01:00
|
|
|
* You can either supply :paramref:`venue`, or :paramref:`latitude`,
|
2022-06-09 17:08:54 +02:00
|
|
|
:paramref:`longitude`, :paramref:`title` and :paramref:`address` and optionally
|
|
|
|
:paramref:`foursquare_id` and :paramref:`foursquare_type` or optionally
|
|
|
|
:paramref:`google_place_id` and :paramref:`google_place_type`.
|
2021-08-29 18:17:06 +02:00
|
|
|
* Foursquare details and Google Place details are mutually exclusive. However, this
|
2020-11-29 16:20:46 +01:00
|
|
|
behaviour is undocumented and might be changed by Telegram.
|
2017-07-25 00:35:22 +02:00
|
|
|
|
2016-04-16 16:48:36 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
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".)
|
2020-11-29 16:20:46 +01:00
|
|
|
google_place_id (:obj:`str`, optional): Google Places identifier of the venue.
|
|
|
|
google_place_type (:obj:`str`, optional): Google Places type of the venue. (See
|
|
|
|
`supported types \
|
2022-06-09 17:08:54 +02:00
|
|
|
<https://developers.google.com/maps/documentation/places/web-service/supported_types>`_.)
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
venue (:class:`telegram.Venue`, optional): The venue to send.
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-05-12 19:20:24 +02:00
|
|
|
# The venue parameter is a convenience functionality added by us, so enforcing the
|
|
|
|
# mutual exclusivity here is nothing that Telegram would handle anyway
|
2017-07-25 00:35:22 +02:00
|
|
|
if not (venue or all([latitude, longitude, address, title])):
|
|
|
|
raise ValueError(
|
2022-01-07 17:02:23 +01:00
|
|
|
"Either venue or latitude, longitude, address and title must be "
|
2017-07-25 00:35:22 +02:00
|
|
|
"passed as arguments."
|
|
|
|
)
|
2022-05-15 14:08:40 +02:00
|
|
|
if not bool(venue) ^ any([latitude, longitude, address, title]):
|
2022-05-12 19:20:24 +02:00
|
|
|
raise ValueError(
|
|
|
|
"Either venue or latitude, longitude, address and title must be "
|
|
|
|
"passed as arguments. Not both."
|
|
|
|
)
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
|
|
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
|
2020-11-29 16:20:46 +01:00
|
|
|
google_place_id = venue.google_place_id
|
|
|
|
google_place_type = venue.google_place_type
|
2017-07-25 00:35:22 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {
|
2016-10-12 22:56:57 +02:00
|
|
|
"chat_id": chat_id,
|
|
|
|
"latitude": latitude,
|
|
|
|
"longitude": longitude,
|
|
|
|
"address": address,
|
|
|
|
"title": title,
|
2022-12-01 19:26:01 +01:00
|
|
|
"foursquare_id": foursquare_id,
|
|
|
|
"foursquare_type": foursquare_type,
|
|
|
|
"google_place_id": google_place_id,
|
|
|
|
"google_place_type": google_place_type,
|
2016-10-12 22:56:57 +02:00
|
|
|
}
|
2016-04-16 16:48:36 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendVenue",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2016-04-16 16:48:36 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_contact(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2023-05-18 07:57:59 +02:00
|
|
|
phone_number: Optional[str] = None,
|
|
|
|
first_name: Optional[str] = None,
|
|
|
|
last_name: Optional[str] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
|
|
|
vcard: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
contact: Optional[Contact] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
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:
|
2022-02-09 17:30:16 +01:00
|
|
|
You can either supply :paramref:`contact` or :paramref:`phone_number` and
|
|
|
|
:paramref:`first_name` with optionally :paramref:`last_name` and optionally
|
|
|
|
:paramref:`vcard`.
|
2017-07-25 00:35:22 +02:00
|
|
|
|
2016-04-16 16:48:36 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
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,
|
2022-11-22 11:07:42 +01:00
|
|
|
0-:tg-const:`telegram.constants.ContactLimit.VCARD` bytes.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
contact (:class:`telegram.Contact`, optional): The contact to send.
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-05-12 19:20:24 +02:00
|
|
|
# The contact parameter is a convenience functionality added by us, so enforcing the
|
|
|
|
# mutual exclusivity here is nothing that Telegram would handle anyway
|
2017-07-25 00:35:22 +02:00
|
|
|
if (not contact) and (not all([phone_number, first_name])):
|
|
|
|
raise ValueError(
|
2021-02-19 19:07:48 +01:00
|
|
|
"Either contact or phone_number and first_name must be passed as arguments."
|
2017-07-25 00:35:22 +02:00
|
|
|
)
|
2022-05-15 14:08:40 +02:00
|
|
|
if not bool(contact) ^ any([phone_number, first_name]):
|
2022-05-12 19:20:24 +02:00
|
|
|
raise ValueError(
|
|
|
|
"Either contact or phone_number and first_name must be passed as arguments. "
|
|
|
|
"Not both."
|
|
|
|
)
|
2017-07-25 00:35:22 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"phone_number": phone_number,
|
|
|
|
"first_name": first_name,
|
2022-12-01 19:26:01 +01:00
|
|
|
"last_name": last_name,
|
|
|
|
"vcard": vcard,
|
2020-10-06 19:28:40 +02:00
|
|
|
}
|
2016-04-16 16:48:36 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendContact",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2016-04-16 16:48:36 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_game(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2023-09-15 21:33:42 +02:00
|
|
|
chat_id: int,
|
2020-10-06 19:28:40 +02:00
|
|
|
game_short_name: str,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-09-15 21:33:42 +02:00
|
|
|
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Message:
|
2017-09-01 08:43:08 +02:00
|
|
|
"""Use this method to send a game.
|
2016-10-03 20:22:57 +02:00
|
|
|
|
|
|
|
Args:
|
2023-09-15 21:33:42 +02:00
|
|
|
chat_id (:obj:`int`): Unique identifier for the target chat.
|
2017-07-23 22:33:08 +02:00
|
|
|
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>`_.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An 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.
|
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "game_short_name": game_short_name}
|
2016-10-03 20:22:57 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendGame",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2016-10-03 20:22:57 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_chat_action(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2020-10-09 08:22:44 +02:00
|
|
|
action: str,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2021-10-19 18:28:19 +02:00
|
|
|
action(: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.constants.ChatAction`.
|
2023-01-01 17:00:49 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2022-05-18 17:18:44 +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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2023-01-01 17:00:49 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"action": action,
|
|
|
|
"message_thread_id": message_thread_id,
|
2024-04-12 11:58:25 +02:00
|
|
|
"business_connection_id": business_connection_id,
|
2023-01-01 17:00:49 +01:00
|
|
|
}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"sendChatAction",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2015-07-08 14:55:06 +02:00
|
|
|
|
2024-02-07 20:45:57 +01:00
|
|
|
def _effective_inline_results(
|
2021-06-06 11:48:48 +02:00
|
|
|
self,
|
|
|
|
results: Union[
|
|
|
|
Sequence["InlineQueryResult"], Callable[[int], Optional[Sequence["InlineQueryResult"]]]
|
|
|
|
],
|
2023-05-18 07:57:59 +02:00
|
|
|
next_offset: Optional[str] = None,
|
|
|
|
current_offset: Optional[str] = None,
|
2021-06-06 11:48:48 +02:00
|
|
|
) -> Tuple[Sequence["InlineQueryResult"], Optional[str]]:
|
|
|
|
"""
|
|
|
|
Builds the effective results from the results input.
|
|
|
|
We make this a stand-alone method so tg.ext.ExtBot can wrap it.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Tuple of 1. the effective results and 2. correct the next_offset
|
|
|
|
|
|
|
|
"""
|
|
|
|
if current_offset is not None and next_offset is not None:
|
|
|
|
raise ValueError("`current_offset` and `next_offset` are mutually exclusive!")
|
|
|
|
|
|
|
|
if current_offset is not None:
|
|
|
|
# Convert the string input to integer
|
2023-03-25 19:18:04 +01:00
|
|
|
current_offset_int = 0 if not current_offset else int(current_offset)
|
2021-06-06 11:48:48 +02:00
|
|
|
|
|
|
|
# for now set to empty string, stating that there are no more results
|
|
|
|
# might change later
|
|
|
|
next_offset = ""
|
|
|
|
|
|
|
|
if callable(results):
|
|
|
|
callable_output = results(current_offset_int)
|
|
|
|
if not callable_output:
|
2023-08-02 11:51:17 +02:00
|
|
|
effective_results: Sequence[InlineQueryResult] = []
|
2021-06-06 11:48:48 +02:00
|
|
|
else:
|
|
|
|
effective_results = callable_output
|
|
|
|
# the callback *might* return more results on the next call, so we increment
|
|
|
|
# the page count
|
|
|
|
next_offset = str(current_offset_int + 1)
|
2023-03-25 19:18:04 +01:00
|
|
|
|
|
|
|
elif len(results) > (current_offset_int + 1) * InlineQueryLimit.RESULTS:
|
|
|
|
# we expect more results for the next page
|
|
|
|
next_offset_int = current_offset_int + 1
|
|
|
|
next_offset = str(next_offset_int)
|
|
|
|
effective_results = results[
|
|
|
|
current_offset_int
|
|
|
|
* InlineQueryLimit.RESULTS : next_offset_int
|
|
|
|
* InlineQueryLimit.RESULTS
|
|
|
|
]
|
2021-06-06 11:48:48 +02:00
|
|
|
else:
|
2023-03-25 19:18:04 +01:00
|
|
|
effective_results = results[current_offset_int * InlineQueryLimit.RESULTS :]
|
2021-06-06 11:48:48 +02:00
|
|
|
else:
|
|
|
|
effective_results = results # type: ignore[assignment]
|
|
|
|
|
|
|
|
return effective_results, next_offset
|
|
|
|
|
2021-10-03 15:10:13 +02:00
|
|
|
@no_type_check # mypy doesn't play too well with hasattr
|
2022-10-31 09:46:56 +01:00
|
|
|
def _insert_defaults_for_ilq_results(self, res: "InlineQueryResult") -> "InlineQueryResult":
|
2021-10-03 15:10:13 +02:00
|
|
|
"""The reason why this method exists is similar to the description of _insert_defaults
|
|
|
|
The reason why we do this in rather than in _insert_defaults is because converting
|
|
|
|
DEFAULT_NONE to NONE *before* calling to_dict() makes it way easier to drop None entries
|
|
|
|
from the json data.
|
2022-10-31 09:46:56 +01:00
|
|
|
|
|
|
|
Must return the correct object instead of editing in-place!
|
2021-10-03 15:10:13 +02:00
|
|
|
"""
|
2022-10-31 09:46:56 +01:00
|
|
|
# Copy the objects that need modification to avoid modifying the original object
|
|
|
|
copied = False
|
2021-10-03 15:10:13 +02:00
|
|
|
if hasattr(res, "parse_mode"):
|
2022-11-02 08:32:40 +01:00
|
|
|
res = copy.copy(res)
|
2022-10-31 09:46:56 +01:00
|
|
|
copied = True
|
2022-12-15 15:00:36 +01:00
|
|
|
with res._unfrozen():
|
|
|
|
res.parse_mode = DefaultValue.get_value(res.parse_mode)
|
2021-10-03 15:10:13 +02:00
|
|
|
if hasattr(res, "input_message_content") and res.input_message_content:
|
|
|
|
if hasattr(res.input_message_content, "parse_mode"):
|
2022-10-31 09:46:56 +01:00
|
|
|
if not copied:
|
2022-11-02 08:32:40 +01:00
|
|
|
res = copy.copy(res)
|
2022-10-31 09:46:56 +01:00
|
|
|
copied = True
|
2022-12-15 15:00:36 +01:00
|
|
|
|
|
|
|
with res._unfrozen():
|
|
|
|
res.input_message_content = copy.copy(res.input_message_content)
|
|
|
|
with res.input_message_content._unfrozen():
|
|
|
|
res.input_message_content.parse_mode = DefaultValue.get_value(
|
|
|
|
res.input_message_content.parse_mode
|
|
|
|
)
|
2024-02-08 17:12:00 +01:00
|
|
|
if hasattr(res.input_message_content, "link_preview_options"):
|
2022-10-31 09:46:56 +01:00
|
|
|
if not copied:
|
2022-11-02 08:32:40 +01:00
|
|
|
res = copy.copy(res)
|
2022-12-15 15:00:36 +01:00
|
|
|
|
|
|
|
with res._unfrozen():
|
|
|
|
res.input_message_content = copy.copy(res.input_message_content)
|
|
|
|
with res.input_message_content._unfrozen():
|
2024-02-08 17:12:00 +01:00
|
|
|
res.input_message_content.link_preview_options = DefaultValue.get_value(
|
|
|
|
res.input_message_content.link_preview_options
|
2022-12-15 15:00:36 +01:00
|
|
|
)
|
2021-10-03 15:10:13 +02:00
|
|
|
|
2022-10-31 09:46:56 +01:00
|
|
|
return res
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def answer_inline_query(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
inline_query_id: str,
|
2020-12-30 13:41:07 +01:00
|
|
|
results: Union[
|
2021-03-13 16:21:03 +01:00
|
|
|
Sequence["InlineQueryResult"], Callable[[int], Optional[Sequence["InlineQueryResult"]]]
|
2020-12-30 13:41:07 +01:00
|
|
|
],
|
2023-05-18 07:57:59 +02:00
|
|
|
cache_time: Optional[int] = None,
|
|
|
|
is_personal: Optional[bool] = None,
|
|
|
|
next_offset: Optional[str] = None,
|
|
|
|
button: Optional[InlineQueryResultsButton] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
current_offset: Optional[str] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
2021-10-19 18:28:19 +02:00
|
|
|
Use this method to send answers to an inline query. No more than
|
|
|
|
:tg-const:`telegram.InlineQuery.MAX_RESULTS` results per query are allowed.
|
2016-01-04 17:31:06 +01:00
|
|
|
|
2020-09-27 14:11:49 +02:00
|
|
|
Warning:
|
2022-02-09 17:30:16 +01:00
|
|
|
In most use cases :paramref:`current_offset` should not be passed manually. Instead of
|
2020-09-27 14:11:49 +02:00
|
|
|
calling this method directly, use the shortcut :meth:`telegram.InlineQuery.answer` with
|
2022-02-09 17:30:16 +01:00
|
|
|
:paramref:`telegram.InlineQuery.answer.auto_pagination` set to :obj:`True`, which will
|
|
|
|
take care of passing the correct value.
|
2020-09-27 14:11:49 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2023-09-03 14:23:48 +02:00
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
Removed deprecated arguments ``switch_pm_text`` and ``switch_pm_parameter``.
|
2023-05-07 13:44:34 +02:00
|
|
|
|
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.
|
2020-09-27 14:11:49 +02:00
|
|
|
results (List[:class:`telegram.InlineQueryResult`] | Callable): A list of results for
|
2022-02-09 17:30:16 +01:00
|
|
|
the inline query. In case :paramref:`current_offset` is passed,
|
|
|
|
:paramref:`results` may also be
|
2020-12-30 13:41:07 +01:00
|
|
|
a callable that accepts the current page index starting from 0. It must return
|
2021-02-01 17:59:39 +01:00
|
|
|
either a list of :class:`telegram.InlineQueryResult` instances or :obj:`None` if
|
|
|
|
there are no more results.
|
2017-07-23 22:33:08 +02:00
|
|
|
cache_time (:obj:`int`, optional): The maximum amount of time in seconds that the
|
2021-04-30 10:47:41 +02:00
|
|
|
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
|
2022-11-22 11:07:42 +01:00
|
|
|
exceed :tg-const:`telegram.InlineQuery.MAX_OFFSET_LENGTH` bytes.
|
2023-05-07 13:44:34 +02:00
|
|
|
button (:class:`telegram.InlineQueryResultsButton`, optional): A button to be shown
|
|
|
|
above the inline query results.
|
|
|
|
|
2023-05-07 15:31:23 +02:00
|
|
|
.. versionadded:: 20.3
|
2023-05-07 13:44:34 +02:00
|
|
|
|
2022-05-18 17:18:44 +02:00
|
|
|
Keyword Args:
|
2020-09-27 14:11:49 +02:00
|
|
|
current_offset (:obj:`str`, optional): The :attr:`telegram.InlineQuery.offset` of
|
|
|
|
the inline query to answer. If passed, PTB will automatically take care of
|
2022-02-09 17:30:16 +01:00
|
|
|
the pagination for you, i.e. pass the correct :paramref:`next_offset` and truncate
|
|
|
|
the results list/get the results from the callable you passed.
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2021-06-06 11:48:48 +02:00
|
|
|
effective_results, next_offset = self._effective_inline_results(
|
|
|
|
results=results, next_offset=next_offset, current_offset=current_offset
|
|
|
|
)
|
2020-10-06 19:28:40 +02:00
|
|
|
|
2021-06-06 11:48:48 +02:00
|
|
|
# Apply defaults
|
2022-10-31 09:46:56 +01:00
|
|
|
effective_results = [
|
|
|
|
self._insert_defaults_for_ilq_results(result) for result in effective_results
|
|
|
|
]
|
2020-10-06 19:28:40 +02:00
|
|
|
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"inline_query_id": inline_query_id,
|
|
|
|
"results": effective_results,
|
|
|
|
"next_offset": next_offset,
|
|
|
|
"cache_time": cache_time,
|
|
|
|
"is_personal": is_personal,
|
2023-05-07 13:44:34 +02:00
|
|
|
"button": button,
|
2022-12-01 19:26:01 +01:00
|
|
|
}
|
2016-01-04 17:31:06 +01:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2020-10-06 19:28:40 +02:00
|
|
|
"answerInlineQuery",
|
|
|
|
data,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-10-06 19:28:40 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-01-04 17:31:06 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_user_profile_photos(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2023-05-18 07:57:59 +02:00
|
|
|
offset: Optional[int] = None,
|
|
|
|
limit: Optional[int] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-08-03 08:16:48 +02:00
|
|
|
) -> UserProfilePhotos:
|
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
|
2022-11-22 11:07:42 +01:00
|
|
|
between :tg-const:`telegram.constants.UserProfilePhotosLimit.MIN_LIMIT`-
|
|
|
|
:tg-const:`telegram.constants.UserProfilePhotosLimit.MAX_LIMIT` are accepted.
|
|
|
|
Defaults to ``100``.
|
2022-05-18 17:18:44 +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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"user_id": user_id, "offset": offset, "limit": limit}
|
2015-07-08 15:10:08 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getUserProfilePhotos",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2015-07-08 15:10:08 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return UserProfilePhotos.de_json(result, self) # type: ignore[return-value]
|
2015-07-08 15:10:08 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_file(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
file_id: Union[
|
|
|
|
str, Animation, Audio, ChatPhoto, Document, PhotoSize, Sticker, Video, VideoNote, Voice
|
|
|
|
],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> File:
|
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
|
2021-10-19 18:28:19 +02:00
|
|
|
moment, bots can download files of up to
|
|
|
|
:tg-const:`telegram.constants.FileSizeLimit.FILESIZE_DOWNLOAD` in size. The file can then
|
2022-11-24 12:09:51 +01:00
|
|
|
be e.g. downloaded with :meth:`telegram.File.download_to_drive`. It is guaranteed that
|
2022-11-02 08:28:41 +01:00
|
|
|
the link will be valid for at least 1 hour. When the link expires, a new one can be
|
|
|
|
requested by calling get_file again.
|
2015-09-20 17:28:10 +02:00
|
|
|
|
2020-04-10 20:05:01 +02:00
|
|
|
Note:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
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.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-12-15 15:20:04 +01:00
|
|
|
|
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.
|
2022-05-18 17:18:44 +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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2023-03-25 19:18:04 +01:00
|
|
|
# Try to get the file_id from the object, if it fails, assume it's a string
|
|
|
|
with contextlib.suppress(AttributeError):
|
2020-10-06 19:28:40 +02:00
|
|
|
file_id = file_id.file_id # type: ignore[union-attr]
|
2018-02-18 16:49:52 +01:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"file_id": file_id}
|
2015-09-20 17:28:10 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getFile",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2015-09-20 17:28:10 +02:00
|
|
|
|
2022-12-01 19:26:01 +01:00
|
|
|
file_path = cast(dict, result).get("file_path")
|
|
|
|
if file_path and not is_local_file(file_path):
|
2022-12-15 15:00:36 +01:00
|
|
|
result["file_path"] = f"{self._base_file_url}/{file_path}"
|
2015-09-20 17:28:10 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return File.de_json(result, self) # type: ignore[return-value]
|
2015-09-20 17:28:10 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def ban_chat_member(
|
2021-07-01 17:45:19 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2023-05-18 07:57:59 +02:00
|
|
|
until_date: Optional[Union[int, datetime]] = None,
|
|
|
|
revoke_messages: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-07-01 17:45:19 +02:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to ban a user from a group, supergroup or a channel. In the case of
|
2020-04-10 20:05:01 +02:00
|
|
|
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
|
2021-03-14 16:41:35 +01:00
|
|
|
chat for this to work and must have the appropriate admin rights.
|
2016-04-12 05:46:50 +02:00
|
|
|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
.. versionadded:: 13.7
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2016-10-17 00:11:20 +02:00
|
|
|
Args:
|
2021-03-14 16:41:35 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target group or username
|
2021-04-30 10:47:41 +02:00
|
|
|
of the target supergroup or channel (in the format ``@channelusername``).
|
2017-07-23 22:33:08 +02:00
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
|
|
|
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
|
2021-03-14 16:41:35 +01:00
|
|
|
seconds from the current time they are considered to be banned forever. Applied
|
|
|
|
for supergroups and channels only.
|
2020-09-27 12:59:48 +02:00
|
|
|
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
|
2022-06-27 18:58:51 +02:00
|
|
|
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
|
|
|
|
used.
|
2021-03-14 16:41:35 +01:00
|
|
|
revoke_messages (:obj:`bool`, optional): Pass :obj:`True` to delete all messages from
|
|
|
|
the chat for the user that is being removed. If :obj:`False`, the user will be able
|
|
|
|
to see messages in the group that were sent before the user was removed.
|
|
|
|
Always :obj:`True` for supergroups and channels.
|
|
|
|
|
|
|
|
.. versionadded:: 13.4
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2016-04-12 05:46:50 +02:00
|
|
|
Returns:
|
2021-04-30 10:47:41 +02:00
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"user_id": user_id,
|
|
|
|
"revoke_messages": revoke_messages,
|
|
|
|
"until_date": until_date,
|
|
|
|
}
|
2021-03-14 16:41:35 +01:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"banChatMember",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-04-12 05:46:50 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def ban_chat_sender_chat(
|
2021-12-11 15:21:56 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
sender_chat_id: int,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-12-11 15:21:56 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to ban a channel chat in a supergroup or a channel. Until the chat is
|
|
|
|
unbanned, the owner of the banned chat won't be able to send messages on behalf of **any of
|
|
|
|
their channels**. The bot must be an administrator in the supergroup or channel for this
|
|
|
|
to work and must have the appropriate administrator rights.
|
|
|
|
|
|
|
|
.. versionadded:: 13.9
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target group or username
|
|
|
|
of the target supergroup or channel (in the format ``@channelusername``).
|
|
|
|
sender_chat_id (:obj:`int`): Unique identifier of the target sender chat.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2021-12-11 15:21:56 +01:00
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id, "sender_chat_id": sender_chat_id}
|
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"banChatSenderChat",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-12-11 15:21:56 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def unban_chat_member(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2023-05-18 07:57:59 +02:00
|
|
|
only_if_banned: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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
|
|
|
|
2020-11-29 16:20:46 +01:00
|
|
|
The user will *not* return to the group or channel automatically, but will be able to join
|
|
|
|
via link, etc. The bot must be an administrator for this to work. By default, this method
|
|
|
|
guarantees that after the call the user is not a member of the chat, but will be able to
|
|
|
|
join it. So if the user is a member of the chat they will also be *removed* from the chat.
|
2022-02-09 17:30:16 +01:00
|
|
|
If you don't want this, use the parameter :paramref:`only_if_banned`.
|
2016-04-12 05:46:50 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2017-07-23 22:33:08 +02:00
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
2020-11-29 16:20:46 +01:00
|
|
|
only_if_banned (:obj:`bool`, optional): Do nothing if the user is not banned.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2016-04-12 05:46:50 +02:00
|
|
|
Returns:
|
2021-12-11 15:21:56 +01:00
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "user_id": user_id, "only_if_banned": only_if_banned}
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"unbanChatMember",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-04-12 05:46:50 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def unban_chat_sender_chat(
|
2021-12-11 15:21:56 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
sender_chat_id: int,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-12-11 15:21:56 +01:00
|
|
|
) -> bool:
|
|
|
|
"""Use this method to unban a previously banned channel in a supergroup or channel.
|
|
|
|
The bot must be an administrator for this to work and must have the
|
|
|
|
appropriate administrator rights.
|
|
|
|
|
|
|
|
.. versionadded:: 13.9
|
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2021-12-11 15:21:56 +01:00
|
|
|
sender_chat_id (:obj:`int`): Unique identifier of the target sender chat.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2021-12-11 15:21:56 +01:00
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id, "sender_chat_id": sender_chat_id}
|
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"unbanChatSenderChat",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-12-11 15:21:56 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def answer_callback_query(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
callback_query_id: str,
|
2023-05-18 07:57:59 +02:00
|
|
|
text: Optional[str] = None,
|
|
|
|
show_alert: Optional[bool] = None,
|
|
|
|
url: Optional[str] = None,
|
|
|
|
cache_time: Optional[int] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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
|
2021-04-30 10:47:41 +02:00
|
|
|
work, you must first create a game for your bot via `@BotFather <https://t.me/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
|
2021-10-19 18:28:19 +02:00
|
|
|
be shown to the user, 0-:tg-const:`telegram.CallbackQuery.MAX_ANSWER_TEXT_LENGTH`
|
|
|
|
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.
|
2022-05-18 17:18:44 +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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"callback_query_id": callback_query_id,
|
|
|
|
"cache_time": cache_time,
|
|
|
|
"text": text,
|
|
|
|
"show_alert": show_alert,
|
|
|
|
"url": url,
|
|
|
|
}
|
2016-04-14 02:25:26 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"answerCallbackQuery",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-04-14 02:25:26 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def edit_message_text(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
text: str,
|
2023-05-18 07:57:59 +02:00
|
|
|
chat_id: Optional[Union[str, int]] = None,
|
|
|
|
message_id: Optional[int] = None,
|
|
|
|
inline_message_id: Optional[str] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-09-15 21:33:42 +02:00
|
|
|
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
entities: Optional[Sequence["MessageEntity"]] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
link_preview_options: ODVInput["LinkPreviewOptions"] = DEFAULT_NONE,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
disable_web_page_preview: Optional[bool] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> Union[Message, bool]:
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
2020-11-29 16:20:46 +01:00
|
|
|
Use this method to edit text and game messages.
|
2016-04-14 05:28:06 +02:00
|
|
|
|
2022-06-27 18:58:51 +02:00
|
|
|
Note:
|
2022-09-19 22:31:23 +02:00
|
|
|
|editreplymarkup|.
|
2022-06-27 18:58:51 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :attr:`telegram.Game.text`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2016-04-14 05:28:06 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if :paramref:`inline_message_id`
|
|
|
|
is not specified. |chat_id_channel|
|
|
|
|
message_id (:obj:`int`, optional): Required if :paramref:`inline_message_id` is not
|
|
|
|
specified. Identifier of the message to edit.
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if :paramref:`chat_id` and
|
|
|
|
:paramref:`message_id` are not specified. Identifier of the inline message.
|
2021-10-19 18:28:19 +02:00
|
|
|
text (:obj:`str`): New text of the message,
|
2022-11-22 11:07:42 +01:00
|
|
|
:tg-const:`telegram.constants.MessageLimit.MIN_TEXT_LENGTH`-
|
|
|
|
:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters after
|
|
|
|
entities parsing.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
entities (Sequence[:class:`telegram.MessageEntity`], optional): Sequence of special
|
|
|
|
entities that appear in message text, which can be specified instead of
|
2022-02-09 17:30:16 +01:00
|
|
|
:paramref:`parse_mode`.
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
|
|
|
link_preview_options (:obj:`LinkPreviewOptions`, optional): Link preview generation
|
|
|
|
options for the message. Mutually exclusive with
|
|
|
|
:paramref:`disable_web_page_preview`.
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An object for an
|
|
|
|
inline keyboard.
|
|
|
|
|
|
|
|
Keyword Args:
|
2018-02-18 16:11:04 +01:00
|
|
|
disable_web_page_preview (:obj:`bool`, optional): Disables link previews for links in
|
2024-02-25 10:34:47 +01:00
|
|
|
this message. Convenience parameter for setting :paramref:`link_preview_options`.
|
|
|
|
Mutually exclusive with :paramref:`link_preview_options`.
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`link_preview_options` replacing this
|
|
|
|
argument. PTB will automatically convert this argument to that one, but
|
|
|
|
for advanced options, please use :paramref:`link_preview_options` directly.
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2016-04-14 05:28:06 +02:00
|
|
|
Returns:
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.Message`: On success, if edited message is not an inline message, the
|
|
|
|
edited message is returned, otherwise :obj:`True` is returned.
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
Raises:
|
2024-02-08 17:12:00 +01:00
|
|
|
:exc:`ValueError`: If both :paramref:`disable_web_page_preview` and
|
|
|
|
:paramref:`link_preview_options` are passed.
|
|
|
|
:class:`telegram.error.TelegramError`: For other errors.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"text": text,
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"inline_message_id": inline_message_id,
|
|
|
|
"entities": entities,
|
|
|
|
}
|
2016-04-14 05:28:06 +02:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
link_preview_options = parse_lpo_and_dwpp(disable_web_page_preview, link_preview_options)
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
return await self._send_message(
|
2020-06-30 22:07:38 +02:00
|
|
|
"editMessageText",
|
|
|
|
data,
|
|
|
|
reply_markup=reply_markup,
|
2022-11-26 19:05:44 +01:00
|
|
|
parse_mode=parse_mode,
|
2024-02-08 17:12:00 +01:00
|
|
|
link_preview_options=link_preview_options,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-04-14 05:28:06 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def edit_message_caption(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
chat_id: Optional[Union[str, int]] = None,
|
|
|
|
message_id: Optional[int] = None,
|
|
|
|
inline_message_id: Optional[str] = None,
|
|
|
|
caption: Optional[str] = None,
|
2023-09-15 21:33:42 +02:00
|
|
|
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> Union[Message, bool]:
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
2020-11-29 16:20:46 +01:00
|
|
|
Use this method to edit captions of messages.
|
2016-04-14 05:28:06 +02:00
|
|
|
|
2022-06-27 18:58:51 +02:00
|
|
|
Note:
|
2022-09-19 22:31:23 +02:00
|
|
|
|editreplymarkup|
|
2022-06-27 18:58:51 +02:00
|
|
|
|
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
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
specified. |chat_id_channel|
|
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.
|
2021-10-19 18:28:19 +02:00
|
|
|
caption (:obj:`str`, optional): New caption of the message,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after
|
2020-04-10 20:05:01 +02:00
|
|
|
entities parsing.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|
|
|
|
|caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2022-01-03 09:09:03 +01:00
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An object for an
|
|
|
|
inline keyboard.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2016-04-14 05:28:06 +02:00
|
|
|
Returns:
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.Message`: On success, if edited message is not an inline message, the
|
|
|
|
edited message is returned, otherwise :obj:`True` is returned.
|
2016-04-19 14:04:25 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"inline_message_id": inline_message_id,
|
|
|
|
}
|
2016-04-14 05:28:06 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"editMessageCaption",
|
|
|
|
data,
|
2020-06-30 22:07:38 +02:00
|
|
|
reply_markup=reply_markup,
|
2022-11-26 19:05:44 +01:00
|
|
|
caption=caption,
|
|
|
|
parse_mode=parse_mode,
|
|
|
|
caption_entities=caption_entities,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-04-14 05:28:06 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def edit_message_media(
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
self,
|
2021-08-29 18:17:06 +02:00
|
|
|
media: "InputMedia",
|
2023-05-18 07:57:59 +02:00
|
|
|
chat_id: Optional[Union[str, int]] = None,
|
|
|
|
message_id: Optional[int] = None,
|
|
|
|
inline_message_id: Optional[str] = None,
|
2023-09-15 21:33:42 +02:00
|
|
|
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> Union[Message, bool]:
|
2020-04-10 20:05:01 +02:00
|
|
|
"""
|
2020-11-29 16:20:46 +01:00
|
|
|
Use this method to edit animation, audio, document, photo, or video messages. If a message
|
|
|
|
is part of a message album, then it can be edited only to an audio for audio albums, only
|
|
|
|
to a document for document albums and to a photo or a video otherwise. When an inline
|
2021-10-01 16:51:03 +02:00
|
|
|
message is edited, a new file can't be uploaded; use a previously uploaded file via its
|
2022-06-27 18:58:51 +02:00
|
|
|
:attr:`~telegram.File.file_id` or specify a URL.
|
|
|
|
|
|
|
|
Note:
|
2022-09-19 22:31:23 +02:00
|
|
|
|editreplymarkup|
|
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
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
2022-08-27 11:46: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
|
|
|
Args:
|
2021-08-29 18:17:06 +02:00
|
|
|
media (:class:`telegram.InputMedia`): An object for a new media content
|
|
|
|
of the message.
|
2020-02-02 20:20:54 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`, optional): Required if inline_message_id is not
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
specified. |chat_id_channel|
|
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.
|
2022-01-03 09:09:03 +01:00
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An object for an
|
|
|
|
inline keyboard.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2020-04-10 20:05:01 +02:00
|
|
|
Returns:
|
2021-10-09 13:56:50 +02:00
|
|
|
:class:`telegram.Message`: On success, if edited message is not an inline message, the
|
|
|
|
edited Message is returned, otherwise :obj:`True` is returned.
|
2020-04-10 20:05:01 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.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
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"media": media,
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"inline_message_id": inline_message_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
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"editMessageMedia",
|
|
|
|
data,
|
|
|
|
reply_markup=reply_markup,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-10-06 19:28:40 +02:00
|
|
|
api_kwargs=api_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
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def edit_message_reply_markup(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
chat_id: Optional[Union[str, int]] = None,
|
|
|
|
message_id: Optional[int] = None,
|
|
|
|
inline_message_id: Optional[str] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> Union[Message, bool]:
|
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
|
|
|
|
2022-06-27 18:58:51 +02:00
|
|
|
Note:
|
2022-09-19 22:31:23 +02:00
|
|
|
|editreplymarkup|
|
2022-06-27 18:58:51 +02:00
|
|
|
|
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
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
specified. |chat_id_channel|
|
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.
|
2022-01-03 09:09:03 +01:00
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An object for an
|
|
|
|
inline keyboard.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2016-04-14 05:28:06 +02:00
|
|
|
Returns:
|
2020-11-29 16:20:46 +01:00
|
|
|
:class:`telegram.Message`: On success, if edited message is not an inline message, the
|
|
|
|
edited message is returned, otherwise :obj:`True` is returned.
|
2016-04-19 14:04:25 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"inline_message_id": inline_message_id,
|
|
|
|
}
|
2016-04-14 05:28:06 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"editMessageReplyMarkup",
|
|
|
|
data,
|
2020-06-30 22:07:38 +02:00
|
|
|
reply_markup=reply_markup,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-04-14 05:28:06 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_updates(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
offset: Optional[int] = None,
|
|
|
|
limit: Optional[int] = None,
|
2023-05-19 22:09:16 +02:00
|
|
|
timeout: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
allowed_updates: Optional[Sequence[str]] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2023-11-27 18:24:21 +01:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Tuple[Update, ...]:
|
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
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
Note:
|
|
|
|
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`
|
|
|
|
|
2022-12-15 15:20:04 +01:00
|
|
|
.. seealso:: :meth:`telegram.ext.Application.run_polling`,
|
|
|
|
:meth:`telegram.ext.Updater.start_polling`
|
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
Returns a tuple instead of a list.
|
|
|
|
|
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
|
2022-04-24 12:38:09 +02:00
|
|
|
returned. An update is considered confirmed as soon as this method is called with
|
|
|
|
an offset higher than its :attr:`telegram.Update.update_id`. The negative offset
|
|
|
|
can be specified to retrieve updates starting from -offset update from the end of
|
2023-05-07 14:51:22 +02:00
|
|
|
the updates queue. All previous updates will be forgotten.
|
2017-07-23 22:33:08 +02:00
|
|
|
limit (:obj:`int`, optional): Limits the number of updates to be retrieved. Values
|
2022-11-22 11:07:42 +01:00
|
|
|
between :tg-const:`telegram.constants.PollingLimit.MIN_LIMIT`-
|
|
|
|
:tg-const:`telegram.constants.PollingLimit.MAX_LIMIT` are accepted.
|
|
|
|
Defaults to ``100``.
|
2021-04-30 10:47:41 +02:00
|
|
|
timeout (:obj:`int`, optional): Timeout in seconds for long polling. Defaults to ``0``,
|
2017-07-23 22:33:08 +02:00
|
|
|
i.e. usual short polling. Should be positive, short polling should be used for
|
|
|
|
testing purposes only.
|
2023-01-01 14:24:30 +01:00
|
|
|
allowed_updates (Sequence[:obj:`str`]), optional): A sequence the types of
|
2022-05-18 17:18:44 +02:00
|
|
|
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.
|
2023-01-01 14:24:30 +01:00
|
|
|
Specify an empty sequence to receive all updates except
|
2024-03-06 14:45:50 +01:00
|
|
|
:attr:`telegram.Update.chat_member`, :attr:`telegram.Update.message_reaction` and
|
|
|
|
:attr:`telegram.Update.message_reaction_count` (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 get_updates, so unwanted updates may be
|
|
|
|
received for a short period of time.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2023-01-01 14:24:30 +01:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
|
|
|
|
2015-07-08 14:22:31 +02:00
|
|
|
Returns:
|
2022-12-15 15:00:36 +01:00
|
|
|
Tuple[:class:`telegram.Update`]
|
2016-04-21 13:15:38 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"timeout": timeout,
|
|
|
|
"offset": offset,
|
|
|
|
"limit": limit,
|
|
|
|
"allowed_updates": allowed_updates,
|
|
|
|
}
|
2015-07-07 21:50:36 +02:00
|
|
|
|
2023-11-27 18:24:21 +01:00
|
|
|
# The "or 0" is needed for the case where read_timeout is None.
|
|
|
|
if not isinstance(read_timeout, DefaultValue):
|
|
|
|
arg_read_timeout: float = read_timeout or 0
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
arg_read_timeout = self._request[0].read_timeout or 0
|
|
|
|
except NotImplementedError:
|
|
|
|
arg_read_timeout = 2
|
|
|
|
self._warn(
|
|
|
|
f"The class {self._request[0].__class__.__name__} does not override "
|
|
|
|
"the property `read_timeout`. Overriding this property will be mandatory in "
|
|
|
|
"future versions. Using 2 seconds as fallback.",
|
|
|
|
PTBDeprecationWarning,
|
2024-03-24 12:34:08 +01:00
|
|
|
stacklevel=2,
|
2023-11-27 18:24:21 +01: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.
|
2021-06-06 11:48:48 +02:00
|
|
|
result = cast(
|
|
|
|
List[JSONDict],
|
2022-04-24 12:38:09 +02:00
|
|
|
await self._post(
|
2021-06-06 11:48:48 +02:00
|
|
|
"getUpdates",
|
|
|
|
data,
|
2023-11-27 18:24:21 +01:00
|
|
|
read_timeout=arg_read_timeout + timeout if timeout else arg_read_timeout,
|
2022-04-24 12:38:09 +02:00
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2021-06-06 11:48:48 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
),
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
2015-09-05 16:55:55 +02:00
|
|
|
if result:
|
2023-04-10 17:01:35 +02:00
|
|
|
self._LOGGER.debug("Getting updates: %s", [u["update_id"] for u in result])
|
2015-07-20 13:59:41 +02:00
|
|
|
else:
|
2023-04-10 17:01:35 +02:00
|
|
|
self._LOGGER.debug("No new updates found.")
|
2015-07-20 13:59:41 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return Update.de_list(result, self)
|
2015-07-07 21:50:36 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_webhook(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2021-08-29 18:17:06 +02:00
|
|
|
url: str,
|
2023-05-18 07:57:59 +02:00
|
|
|
certificate: Optional[FileInput] = None,
|
|
|
|
max_connections: Optional[int] = None,
|
|
|
|
allowed_updates: Optional[Sequence[str]] = None,
|
|
|
|
ip_address: Optional[str] = None,
|
|
|
|
drop_pending_updates: Optional[bool] = None,
|
|
|
|
secret_token: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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
|
2022-01-03 09:09:03 +01:00
|
|
|
specified url, containing An 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
|
|
|
|
2022-06-27 18:54:11 +02:00
|
|
|
If you'd like to make sure that the Webhook was set by you, you can specify secret data in
|
|
|
|
the parameter :paramref:`secret_token`. If specified, the request will contain a header
|
|
|
|
``X-Telegram-Bot-Api-Secret-Token`` with the secret token as content.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
Note:
|
2022-09-19 22:31:23 +02:00
|
|
|
1. You will not be able to receive updates using :meth:`get_updates` for long as an
|
|
|
|
outgoing webhook is set up.
|
|
|
|
2. To use a self-signed certificate, you need to upload your public key certificate
|
|
|
|
using :paramref:`certificate` parameter. Please upload as
|
|
|
|
:class:`~telegram.InputFile`, sending a String will not work.
|
|
|
|
3. Ports currently supported for Webhooks:
|
|
|
|
:attr:`telegram.constants.SUPPORTED_WEBHOOK_PORTS`.
|
|
|
|
|
|
|
|
If you're having any trouble setting up webhooks, please check out this `guide to
|
|
|
|
Webhooks`_.
|
2015-07-09 18:19:58 +02:00
|
|
|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
Note:
|
|
|
|
1. You will not be able to receive updates using :meth:`get_updates` for 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:
|
|
|
|
:attr:`telegram.constants.SUPPORTED_WEBHOOK_PORTS`.
|
|
|
|
|
|
|
|
If you're having any trouble setting up webhooks, please check out this `guide to
|
|
|
|
Webhooks`_.
|
|
|
|
|
2022-12-15 15:20:04 +01:00
|
|
|
.. seealso:: :meth:`telegram.ext.Application.run_webhook`,
|
|
|
|
:meth:`telegram.ext.Updater.start_webhook`
|
|
|
|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
Examples:
|
|
|
|
:any:`Custom Webhook Bot <examples.customwebhookbot>`
|
|
|
|
|
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.
|
2022-09-19 22:31:23 +02:00
|
|
|
certificate (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`):
|
|
|
|
Upload your public key certificate so that the root
|
2023-01-01 16:24:00 +01:00
|
|
|
certificate in use can be checked. See our :wiki:`self-signed guide\
|
|
|
|
<Webhooks#creating-a-self-signed-certificate-using-openssl>` for details.
|
|
|
|
|uploadinputnopath|
|
2020-11-29 16:20:46 +01:00
|
|
|
ip_address (:obj:`str`, optional): The fixed IP address which will be used to send
|
|
|
|
webhook requests instead of the IP address resolved through DNS.
|
2017-07-23 22:33:08 +02:00
|
|
|
max_connections (:obj:`int`, optional): Maximum allowed number of simultaneous HTTPS
|
2022-11-22 11:07:42 +01:00
|
|
|
connections to the webhook for update delivery,
|
|
|
|
:tg-const:`telegram.constants.WebhookLimit.MIN_CONNECTIONS_LIMIT`-
|
|
|
|
:tg-const:`telegram.constants.WebhookLimit.MAX_CONNECTIONS_LIMIT`.
|
|
|
|
Defaults to ``40``. Use lower values to limit the load on your bot's server,
|
|
|
|
and higher values to increase your bot's throughput.
|
2023-02-05 18:09:55 +01:00
|
|
|
allowed_updates (Sequence[:obj:`str`], optional): A sequence of the types of
|
2020-02-02 20:20:54 +01:00
|
|
|
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.
|
2023-01-01 14:24:30 +01:00
|
|
|
Specify an empty sequence to receive all updates except
|
2024-03-06 14:45:50 +01:00
|
|
|
:attr:`telegram.Update.chat_member`,
|
|
|
|
:attr:`telegram.Update.message_reaction`
|
|
|
|
and :attr:`telegram.Update.message_reaction_count` (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 update
|
|
|
|
may be received for a short period of time.
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2020-11-29 16:20:46 +01:00
|
|
|
drop_pending_updates (:obj:`bool`, optional): Pass :obj:`True` to drop all pending
|
|
|
|
updates.
|
2022-06-27 18:54:11 +02:00
|
|
|
secret_token (:obj:`str`, optional): A secret token to be sent in a header
|
|
|
|
``X-Telegram-Bot-Api-Secret-Token`` in every webhook request,
|
|
|
|
:tg-const:`telegram.constants.WebhookLimit.MIN_SECRET_TOKEN_LENGTH`-
|
|
|
|
:tg-const:`telegram.constants.WebhookLimit.MAX_SECRET_TOKEN_LENGTH` characters.
|
|
|
|
Only characters ``A-Z``, ``a-z``, ``0-9``, ``_`` and ``-`` are allowed.
|
|
|
|
The header is useful to ensure that the request comes from a webhook set by you.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.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
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"url": url,
|
|
|
|
"max_connections": max_connections,
|
|
|
|
"allowed_updates": allowed_updates,
|
|
|
|
"ip_address": ip_address,
|
|
|
|
"drop_pending_updates": drop_pending_updates,
|
|
|
|
"secret_token": secret_token,
|
|
|
|
"certificate": self._parse_file_input(certificate), # type: ignore[arg-type]
|
|
|
|
}
|
2016-12-14 00:50:34 +01:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"setWebhook",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-12-14 00:50:34 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def delete_webhook(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
drop_pending_updates: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-11-29 16:20:46 +01:00
|
|
|
) -> bool:
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
|
|
|
Use this method to remove webhook integration if you decide to switch back to
|
2021-04-30 10:47:41 +02:00
|
|
|
:meth:`get_updates()`.
|
2016-12-14 00:50:34 +01:00
|
|
|
|
|
|
|
Args:
|
2021-04-30 10:47:41 +02:00
|
|
|
drop_pending_updates (:obj:`bool`, optional): Pass :obj:`True` to drop all pending
|
2020-11-29 16:20:46 +01:00
|
|
|
updates.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2016-12-14 00:50:34 +01:00
|
|
|
Returns:
|
2021-04-30 10:47:41 +02:00
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2016-12-14 00:50:34 +01:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data = {"drop_pending_updates": drop_pending_updates}
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"deleteWebhook",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2015-07-09 18:19:58 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def leave_chat(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
Returns:
|
2021-04-30 10:47:41 +02:00
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"leaveChat",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_chat(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> Chat:
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getChat",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return Chat.de_json(result, self) # type: ignore[return-value]
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_chat_administrators(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Tuple[ChatMember, ...]:
|
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
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
Returns a tuple instead of a list.
|
|
|
|
|
2016-05-26 02:41:12 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2016-05-26 02:41:12 +02:00
|
|
|
|
|
|
|
Returns:
|
2022-12-15 15:00:36 +01:00
|
|
|
Tuple[:class:`telegram.ChatMember`]: On success, returns a tuple of ``ChatMember``
|
2020-04-10 20:05:01 +02:00
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getChatAdministrators",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return ChatMember.de_list(result, self)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_chat_member_count(
|
2021-07-01 17:45:19 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> int:
|
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
|
|
|
|
2022-06-09 17:08:54 +02:00
|
|
|
.. versionadded:: 13.7
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2016-05-26 02:41:12 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"getChatMemberCount",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_chat_member(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> ChatMember:
|
2023-02-05 18:09:55 +01:00
|
|
|
"""Use this method to get information about a member of a chat. The method is only
|
|
|
|
guaranteed to work for other users if the bot is an administrator in the chat.
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2016-05-26 02:41:12 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2017-07-23 22:33:08 +02:00
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "user_id": user_id}
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getChatMember",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return ChatMember.de_json(result, self) # type: ignore[return-value]
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_chat_sticker_set(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
sticker_set_name: str,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2017-10-14 20:03:02 +02:00
|
|
|
"""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
|
2021-03-14 16:46:37 +01:00
|
|
|
in :meth:`get_chat` requests to check if the bot can use this method.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
2017-10-14 20:03:02 +02:00
|
|
|
sticker_set_name (:obj:`str`): Name of the sticker set to be set as the group
|
|
|
|
sticker set.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2017-10-14 20:03:02 +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-10-14 20:03:02 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "sticker_set_name": sticker_set_name}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"setChatStickerSet",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def delete_chat_sticker_set(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2017-10-14 20:03:02 +02:00
|
|
|
"""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
|
2021-03-14 16:46:37 +01:00
|
|
|
:meth:`get_chat` requests to check if the bot can use this method.
|
2017-10-14 20:03:02 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
2017-10-14 20:03:02 +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-10-14 20:03:02 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"deleteChatStickerSet",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-10-14 20:03:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_webhook_info(
|
|
|
|
self,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
) -> WebhookInfo:
|
2017-09-01 08:43:08 +02:00
|
|
|
"""Use this method to get current webhook status. Requires no parameters.
|
|
|
|
|
2021-04-30 10:47:41 +02:00
|
|
|
If the bot is using :meth:`get_updates`, will return an object with the
|
|
|
|
:attr:`telegram.WebhookInfo.url` field empty.
|
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
|
|
|
"""
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getWebhookInfo",
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return WebhookInfo.de_json(result, self) # type: ignore[return-value]
|
2016-10-03 15:16:43 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_game_score(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2020-10-06 19:28:40 +02:00
|
|
|
score: int,
|
2023-09-15 21:33:42 +02:00
|
|
|
chat_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_id: Optional[int] = None,
|
|
|
|
inline_message_id: Optional[str] = None,
|
|
|
|
force: Optional[bool] = None,
|
|
|
|
disable_edit_message: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> Union[Message, bool]:
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
2021-10-01 16:51:03 +02:00
|
|
|
Use this method to set the score of the specified user in a game message.
|
2016-10-04 00:50:46 +02:00
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :attr:`telegram.Game.text`
|
2022-08-27 11:46:51 +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.
|
2023-09-15 21:33:42 +02:00
|
|
|
chat_id (:obj:`int`, optional): Required if :paramref:`inline_message_id`
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
is not specified. Unique identifier for the target chat.
|
|
|
|
message_id (:obj:`int`, optional): Required if :paramref:`inline_message_id` is not
|
|
|
|
specified. Identifier of the sent message.
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if :paramref:`chat_id` and
|
|
|
|
:paramref:`message_id` are not specified. Identifier of the inline message.
|
2016-12-11 22:44:52 +01:00
|
|
|
|
2016-10-04 00:50:46 +02:00
|
|
|
Returns:
|
2021-10-01 16:51:03 +02:00
|
|
|
:class:`telegram.Message`: The edited message. If the message is not an inline message
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`: If the new score is not greater than the user's
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
current score in the chat and :paramref:`force` is :obj:`False`.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"user_id": user_id,
|
|
|
|
"score": score,
|
|
|
|
"force": force,
|
|
|
|
"disable_edit_message": disable_edit_message,
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"inline_message_id": inline_message_id,
|
|
|
|
}
|
2016-10-03 20:43:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"setGameScore",
|
|
|
|
data,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-10-06 19:28:40 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-10-03 20:43:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_game_high_scores(
|
2017-05-07 16:09:58 +02:00
|
|
|
self,
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
|
|
|
chat_id: Optional[int] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_id: Optional[int] = None,
|
|
|
|
inline_message_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Tuple[GameHighScore, ...]:
|
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
|
2021-04-30 10:47:41 +02:00
|
|
|
user and several of their neighbors in a game.
|
2016-10-04 00:57:19 +02:00
|
|
|
|
2021-06-06 12:16:23 +02:00
|
|
|
Note:
|
|
|
|
This method will currently return scores for the target user, plus two of their
|
|
|
|
closest neighbors on each side. Will also return the top three users if the user and
|
|
|
|
his neighbors are not among them. Please note that this behavior is subject to change.
|
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
Returns a tuple instead of a list.
|
2022-08-27 11:46:51 +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.
|
2023-09-15 21:33:42 +02:00
|
|
|
chat_id (:obj:`int`, optional): Required if :paramref:`inline_message_id`
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
is not specified. Unique identifier for the target chat.
|
|
|
|
message_id (:obj:`int`, optional): Required if :paramref:`inline_message_id` is not
|
|
|
|
specified. Identifier of the sent message.
|
|
|
|
inline_message_id (:obj:`str`, optional): Required if :paramref:`chat_id` and
|
|
|
|
:paramref:`message_id` are not specified. Identifier of the inline message.
|
2017-01-06 22:48:34 +01:00
|
|
|
|
2016-10-04 00:57:19 +02:00
|
|
|
Returns:
|
2022-12-15 15:00:36 +01:00
|
|
|
Tuple[:class:`telegram.GameHighScore`]
|
2016-10-04 00:57:19 +02:00
|
|
|
|
2017-07-23 22:33:08 +02:00
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"user_id": user_id,
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"inline_message_id": inline_message_id,
|
|
|
|
}
|
2016-10-03 20:43:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getGameHighScores",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2016-10-03 20:43:02 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return GameHighScore.de_list(result, self)
|
2016-10-03 20:43:02 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_invoice(
|
2017-05-19 19:46:42 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
|
|
|
title: str,
|
|
|
|
description: str,
|
|
|
|
payload: str,
|
|
|
|
provider_token: str,
|
|
|
|
currency: str,
|
2023-01-01 14:24:30 +01:00
|
|
|
prices: Sequence["LabeledPrice"],
|
2023-05-18 07:57:59 +02:00
|
|
|
start_parameter: Optional[str] = None,
|
|
|
|
photo_url: Optional[str] = None,
|
|
|
|
photo_size: Optional[int] = None,
|
|
|
|
photo_width: Optional[int] = None,
|
|
|
|
photo_height: Optional[int] = None,
|
|
|
|
need_name: Optional[bool] = None,
|
|
|
|
need_phone_number: Optional[bool] = None,
|
|
|
|
need_email: Optional[bool] = None,
|
|
|
|
need_shipping_address: Optional[bool] = None,
|
|
|
|
is_flexible: Optional[bool] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-09-15 21:33:42 +02:00
|
|
|
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
provider_data: Optional[Union[str, object]] = None,
|
|
|
|
send_phone_number_to_provider: Optional[bool] = None,
|
|
|
|
send_email_to_provider: Optional[bool] = None,
|
|
|
|
max_tip_amount: Optional[int] = None,
|
|
|
|
suggested_tip_amounts: Optional[Sequence[int]] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> Message:
|
2017-09-01 08:43:08 +02:00
|
|
|
"""Use this method to send invoices.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
2021-04-30 10:09:21 +02:00
|
|
|
Warning:
|
2022-02-09 17:30:16 +01:00
|
|
|
As of API 5.2 :paramref:`start_parameter` is an optional argument and therefore the
|
|
|
|
order of the arguments had to be changed. Use keyword arguments to make sure that the
|
2021-04-30 10:09:21 +02:00
|
|
|
arguments are passed correctly.
|
|
|
|
|
|
|
|
.. versionchanged:: 13.5
|
2022-02-09 17:30:16 +01:00
|
|
|
As of Bot API 5.2, the parameter :paramref:`start_parameter` is optional.
|
2021-04-30 10:09:21 +02:00
|
|
|
|
2017-05-19 19:46:42 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-06-27 18:54:11 +02:00
|
|
|
title (:obj:`str`): Product name. :tg-const:`telegram.Invoice.MIN_TITLE_LENGTH`-
|
|
|
|
:tg-const:`telegram.Invoice.MAX_TITLE_LENGTH` characters.
|
|
|
|
description (:obj:`str`): Product description.
|
|
|
|
:tg-const:`telegram.Invoice.MIN_DESCRIPTION_LENGTH`-
|
|
|
|
:tg-const:`telegram.Invoice.MAX_DESCRIPTION_LENGTH` characters.
|
|
|
|
payload (:obj:`str`): Bot-defined invoice payload.
|
|
|
|
:tg-const:`telegram.Invoice.MIN_PAYLOAD_LENGTH`-
|
|
|
|
:tg-const:`telegram.Invoice.MAX_PAYLOAD_LENGTH` bytes. This will not be
|
2017-07-23 22:33:08 +02:00
|
|
|
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>`_.
|
2022-06-27 18:54:11 +02:00
|
|
|
currency (:obj:`str`): Three-letter ISO 4217 currency code, see `more on currencies
|
|
|
|
<https://core.telegram.org/bots/payments#supported-currencies>`_.
|
2024-02-08 17:58:33 +01:00
|
|
|
prices (Sequence[:class:`telegram.LabeledPrice`]): Price breakdown, a sequence
|
2020-02-02 20:20:54 +01:00
|
|
|
of components (e.g. product price, tax, discount, delivery cost, delivery tax,
|
|
|
|
bonus, etc.).
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2021-04-30 10:09:21 +02:00
|
|
|
max_tip_amount (:obj:`int`, optional): The maximum accepted amount for tips in the
|
2022-06-27 18:54:11 +02:00
|
|
|
*smallest* units of the currency (integer, **not** float/double). For example, for
|
|
|
|
a maximum tip of US$ 1.45 pass ``max_tip_amount = 145``. See the exp parameter in
|
2021-04-30 10:09:21 +02:00
|
|
|
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
|
|
|
|
shows the number of digits past the decimal point for each currency (2 for the
|
|
|
|
majority of currencies). Defaults to ``0``.
|
|
|
|
|
|
|
|
.. versionadded:: 13.5
|
2023-01-01 14:24:30 +01:00
|
|
|
suggested_tip_amounts (Sequence[:obj:`int`], optional): An array of
|
2022-06-27 18:54:11 +02:00
|
|
|
suggested amounts of tips in the *smallest* units of the currency (integer, **not**
|
2022-12-30 14:09:06 +01:00
|
|
|
float/double). At most :tg-const:`telegram.Invoice.MAX_TIP_AMOUNTS` suggested tip
|
|
|
|
amounts can be specified. The suggested tip amounts must be positive, passed in a
|
|
|
|
strictly increased order and must not exceed :paramref:`max_tip_amount`.
|
2021-04-30 10:09:21 +02:00
|
|
|
|
|
|
|
.. versionadded:: 13.5
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2021-04-30 10:09:21 +02:00
|
|
|
start_parameter (:obj:`str`, optional): Unique deep-linking parameter. If left empty,
|
|
|
|
*forwarded copies* of the sent message will have a *Pay* button, allowing
|
|
|
|
multiple users to pay directly from the forwarded message, using the same invoice.
|
|
|
|
If non-empty, forwarded copies of the sent message will have a *URL* button with a
|
|
|
|
deep link to the bot (instead of a *Pay* button), with the value used as the
|
|
|
|
start parameter.
|
|
|
|
|
|
|
|
.. versionchanged:: 13.5
|
|
|
|
As of Bot API 5.2, this parameter is optional.
|
2022-01-03 09:09:03 +01:00
|
|
|
provider_data (:obj:`str` | :obj:`object`, optional): 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.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An 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.
|
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {
|
2017-05-19 19:46:42 +02:00
|
|
|
"chat_id": chat_id,
|
|
|
|
"title": title,
|
|
|
|
"description": description,
|
|
|
|
"payload": payload,
|
|
|
|
"provider_token": provider_token,
|
|
|
|
"currency": currency,
|
2022-04-24 12:38:09 +02:00
|
|
|
"prices": prices,
|
2022-12-01 19:26:01 +01:00
|
|
|
"max_tip_amount": max_tip_amount,
|
|
|
|
"suggested_tip_amounts": suggested_tip_amounts,
|
|
|
|
"start_parameter": start_parameter,
|
|
|
|
"provider_data": provider_data,
|
|
|
|
"photo_url": photo_url,
|
|
|
|
"photo_size": photo_size,
|
|
|
|
"photo_width": photo_width,
|
|
|
|
"photo_height": photo_height,
|
|
|
|
"need_name": need_name,
|
|
|
|
"need_phone_number": need_phone_number,
|
|
|
|
"need_email": need_email,
|
|
|
|
"need_shipping_address": need_shipping_address,
|
|
|
|
"is_flexible": is_flexible,
|
|
|
|
"send_phone_number_to_provider": send_phone_number_to_provider,
|
|
|
|
"send_email_to_provider": send_email_to_provider,
|
2017-05-19 19:46:42 +02:00
|
|
|
}
|
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendInvoice",
|
|
|
|
data,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-02-13 11:37:13 +01:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-05-19 19:46:42 +02:00
|
|
|
|
2023-09-09 23:12:30 +02:00
|
|
|
async def answer_shipping_query(
|
2017-05-19 19:46:42 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
shipping_query_id: str,
|
|
|
|
ok: bool,
|
2023-09-15 21:33:42 +02:00
|
|
|
shipping_options: Optional[Sequence["ShippingOption"]] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
error_message: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2017-05-19 19:46:42 +02:00
|
|
|
"""
|
2022-06-27 18:58:51 +02:00
|
|
|
If you sent an invoice requesting a shipping address and the parameter
|
|
|
|
:paramref:`send_invoice.is_flexible` was specified, the Bot API will send an
|
|
|
|
:class:`telegram.Update` with a :attr:`telegram.Update.shipping_query` field to the bot.
|
|
|
|
Use this method to reply to shipping queries.
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
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).
|
2023-01-01 14:24:30 +01:00
|
|
|
shipping_options (Sequence[:class:`telegram.ShippingOption`]), optional): Required if
|
|
|
|
:paramref:`ok` is :obj:`True`. A sequence of available shipping options.
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
error_message (:obj:`str`, optional): Required if :paramref:`ok` is :obj:`False`.
|
|
|
|
Error message in 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.
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-05-22 16:47:35 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"shipping_query_id": shipping_query_id,
|
|
|
|
"ok": ok,
|
|
|
|
"shipping_options": shipping_options,
|
|
|
|
"error_message": error_message,
|
|
|
|
}
|
2017-05-19 19:46:42 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"answerShippingQuery",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-05-22 16:55:19 +02:00
|
|
|
|
2023-09-09 23:12:30 +02:00
|
|
|
async def answer_pre_checkout_query(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
pre_checkout_query_id: str,
|
|
|
|
ok: bool,
|
2023-05-18 07:57:59 +02:00
|
|
|
error_message: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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
|
2021-04-30 10:47:41 +02:00
|
|
|
confirmation in the form of an :class:`telegram.Update` with the field
|
2022-02-09 17:30:16 +01:00
|
|
|
:attr:`telegram.Update.pre_checkout_query`. Use this method to respond to such pre-checkout
|
|
|
|
queries.
|
2017-07-23 22:33:08 +02:00
|
|
|
|
|
|
|
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.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
error_message (:obj:`str`, optional): Required if :paramref:`ok` is :obj:`False`. Error
|
|
|
|
message in human readable form that explains the reason for failure to proceed with
|
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 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.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2017-05-19 19:46:42 +02:00
|
|
|
Returns:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
:obj:`bool`: On success, :obj:`True` is returned
|
2017-05-19 19:46:42 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-05-22 16:47:35 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"pre_checkout_query_id": pre_checkout_query_id,
|
|
|
|
"ok": ok,
|
|
|
|
"error_message": error_message,
|
|
|
|
}
|
2017-05-19 19:46:42 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"answerPreCheckoutQuery",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-05-22 16:55:19 +02:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
async def answer_web_app_query(
|
|
|
|
self,
|
|
|
|
web_app_query_id: str,
|
|
|
|
result: "InlineQueryResult",
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-05-03 18:21:50 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-05-03 18:21:50 +02:00
|
|
|
) -> SentWebAppMessage:
|
|
|
|
"""Use this method to set the result of an interaction with a Web App and send a
|
|
|
|
corresponding message on behalf of the user to the chat from which the query originated.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
web_app_query_id (:obj:`str`): Unique identifier for the query to be answered.
|
|
|
|
result (:class:`telegram.InlineQueryResult`): An object describing the message to be
|
|
|
|
sent.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.SentWebAppMessage`: On success, a sent
|
|
|
|
:class:`telegram.SentWebAppMessage` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
2022-11-14 20:08:16 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"web_app_query_id": web_app_query_id,
|
|
|
|
"result": self._insert_defaults_for_ilq_results(result),
|
|
|
|
}
|
2022-05-03 18:21:50 +02:00
|
|
|
|
|
|
|
api_result = await self._post(
|
|
|
|
"answerWebAppQuery",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return SentWebAppMessage.de_json(api_result, self) # type: ignore[return-value]
|
2022-05-03 18:21:50 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def restrict_chat_member(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2020-10-06 19:28:40 +02:00
|
|
|
permissions: ChatPermissions,
|
2023-05-18 07:57:59 +02:00
|
|
|
until_date: Optional[Union[int, datetime]] = None,
|
|
|
|
use_independent_chat_permissions: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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
|
2022-04-27 20:17:58 +02:00
|
|
|
:obj:`True` for all boolean parameters to lift restrictions from a user.
|
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :meth:`telegram.ChatPermissions.all_permissions`
|
2019-09-06 21:41:43 +02:00
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
2017-07-23 22:33:08 +02:00
|
|
|
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.
|
2020-09-27 12:59:48 +02:00
|
|
|
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
|
2022-06-27 18:58:51 +02:00
|
|
|
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
|
|
|
|
used.
|
2022-01-03 09:09:03 +01:00
|
|
|
permissions (:class:`telegram.ChatPermissions`): An object for new 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
|
|
|
permissions.
|
2023-02-08 11:47:21 +01:00
|
|
|
use_independent_chat_permissions (:obj:`bool`, optional): Pass :obj:`True` if chat
|
|
|
|
permissions are set independently. Otherwise, the
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_other_messages` and
|
|
|
|
:attr:`~telegram.ChatPermissions.can_add_web_page_previews` permissions will imply
|
|
|
|
the :attr:`~telegram.ChatPermissions.can_send_messages`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_audios`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_documents`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_photos`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_videos`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_video_notes`, and
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_voice_notes` permissions; the
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_polls` permission will imply the
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_messages` permission.
|
|
|
|
|
|
|
|
.. versionadded: 20.1
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"user_id": user_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
"permissions": permissions,
|
2022-12-01 19:26:01 +01:00
|
|
|
"until_date": until_date,
|
2023-02-08 11:47:21 +01:00
|
|
|
"use_independent_chat_permissions": use_independent_chat_permissions,
|
2020-10-06 19:28:40 +02:00
|
|
|
}
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"restrictChatMember",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def promote_chat_member(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2023-05-18 07:57:59 +02:00
|
|
|
can_change_info: Optional[bool] = None,
|
|
|
|
can_post_messages: Optional[bool] = None,
|
|
|
|
can_edit_messages: Optional[bool] = None,
|
|
|
|
can_delete_messages: Optional[bool] = None,
|
|
|
|
can_invite_users: Optional[bool] = None,
|
|
|
|
can_restrict_members: Optional[bool] = None,
|
|
|
|
can_pin_messages: Optional[bool] = None,
|
|
|
|
can_promote_members: Optional[bool] = None,
|
|
|
|
is_anonymous: Optional[bool] = None,
|
|
|
|
can_manage_chat: Optional[bool] = None,
|
|
|
|
can_manage_video_chats: Optional[bool] = None,
|
|
|
|
can_manage_topics: Optional[bool] = None,
|
2023-10-03 14:32:57 +02:00
|
|
|
can_post_stories: Optional[bool] = None,
|
|
|
|
can_edit_stories: Optional[bool] = None,
|
|
|
|
can_delete_stories: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
The argument ``can_manage_voice_chats`` was renamed to
|
|
|
|
:paramref:`can_manage_video_chats` in accordance to Bot API 6.0.
|
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2017-07-23 22:33:08 +02:00
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
2020-11-29 16:20:46 +01:00
|
|
|
is_anonymous (:obj:`bool`, optional): Pass :obj:`True`, if the administrator's presence
|
|
|
|
in the chat is hidden.
|
2024-03-02 10:56:15 +01:00
|
|
|
can_manage_chat (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
|
|
|
access the chat event log, get boost list, see hidden supergroup and channel
|
|
|
|
members, report spam messages and ignore slow mode. Implied by any other
|
|
|
|
administrator privilege.
|
2021-03-14 16:41:35 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.4
|
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
can_manage_video_chats (:obj:`bool`, optional): Pass :obj:`True`, if the administrator
|
|
|
|
can manage video chats.
|
2021-03-14 16:41:35 +01:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
.. versionadded:: 20.0
|
2021-03-14 16:41:35 +01:00
|
|
|
|
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
|
2024-03-06 14:45:50 +01:00
|
|
|
post messages in the channel, or access channel statistics; for 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
|
2024-03-06 14:45:50 +01:00
|
|
|
edit messages of other users and can pin messages, for 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_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
|
2023-10-03 15:11:37 +02:00
|
|
|
can restrict, ban or unban chat members, or access supergroup statistics.
|
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_pin_messages (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
2024-03-06 14:45:50 +01:00
|
|
|
pin messages, for supergroups 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_promote_members (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
2023-02-05 18:09:55 +01:00
|
|
|
add new administrators with a subset of their own privileges or demote
|
|
|
|
administrators that they have promoted, directly or indirectly
|
|
|
|
(promoted by administrators that were appointed by the user).
|
2022-11-22 10:43:50 +01:00
|
|
|
can_manage_topics (:obj:`bool`, optional): Pass :obj:`True`, if the user is
|
2024-03-06 14:45:50 +01:00
|
|
|
allowed to create, rename, close, and reopen forum topics; for supergroups only.
|
2022-11-22 10:43:50 +01:00
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2023-10-03 14:32:57 +02:00
|
|
|
can_post_stories (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
2024-03-02 10:56:15 +01:00
|
|
|
post stories to the chat.
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2023-10-03 14:32:57 +02:00
|
|
|
can_edit_stories (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
2024-03-02 10:56:15 +01:00
|
|
|
edit stories posted by other users.
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2023-10-03 14:32:57 +02:00
|
|
|
can_delete_stories (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
|
2024-03-02 10:56:15 +01:00
|
|
|
delete stories posted by other users.
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"user_id": user_id,
|
|
|
|
"is_anonymous": is_anonymous,
|
|
|
|
"can_change_info": can_change_info,
|
|
|
|
"can_post_messages": can_post_messages,
|
|
|
|
"can_edit_messages": can_edit_messages,
|
|
|
|
"can_delete_messages": can_delete_messages,
|
|
|
|
"can_invite_users": can_invite_users,
|
|
|
|
"can_restrict_members": can_restrict_members,
|
|
|
|
"can_pin_messages": can_pin_messages,
|
|
|
|
"can_promote_members": can_promote_members,
|
|
|
|
"can_manage_chat": can_manage_chat,
|
|
|
|
"can_manage_video_chats": can_manage_video_chats,
|
|
|
|
"can_manage_topics": can_manage_topics,
|
2023-10-03 14:32:57 +02:00
|
|
|
"can_post_stories": can_post_stories,
|
|
|
|
"can_edit_stories": can_edit_stories,
|
|
|
|
"can_delete_stories": can_delete_stories,
|
2022-12-01 19:26:01 +01:00
|
|
|
}
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"promoteChatMember",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_chat_permissions(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
permissions: ChatPermissions,
|
2023-05-18 07:57:59 +02:00
|
|
|
use_independent_chat_permissions: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2019-09-06 21:41:43 +02:00
|
|
|
"""
|
|
|
|
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
|
2022-02-09 17:30:16 +01:00
|
|
|
:attr:`telegram.ChatMemberAdministrator.can_restrict_members` admin rights.
|
2019-09-06 21:41:43 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
2019-09-06 21:41:43 +02:00
|
|
|
permissions (:class:`telegram.ChatPermissions`): New default chat permissions.
|
2023-02-08 11:47:21 +01:00
|
|
|
use_independent_chat_permissions (:obj:`bool`, optional): Pass :obj:`True` if chat
|
|
|
|
permissions are set independently. Otherwise, the
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_other_messages` and
|
|
|
|
:attr:`~telegram.ChatPermissions.can_add_web_page_previews` permissions will imply
|
|
|
|
the :attr:`~telegram.ChatPermissions.can_send_messages`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_audios`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_documents`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_photos`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_videos`,
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_video_notes`, and
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_voice_notes` permissions; the
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_polls` permission will imply the
|
|
|
|
:attr:`~telegram.ChatPermissions.can_send_messages` permission.
|
|
|
|
|
|
|
|
.. versionadded: 20.1
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2019-09-06 21:41:43 +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.
|
2019-09-06 21:41:43 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2019-09-06 21:41:43 +02:00
|
|
|
|
|
|
|
"""
|
2023-02-08 11:47:21 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"permissions": permissions,
|
|
|
|
"use_independent_chat_permissions": use_independent_chat_permissions,
|
|
|
|
}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"setChatPermissions",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2019-09-06 21:41:43 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_chat_administrator_custom_title(
|
2020-03-28 16:37:26 +01:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2020-10-06 19:28:40 +02:00
|
|
|
custom_title: str,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2020-03-28 16:37:26 +01:00
|
|
|
"""
|
|
|
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
2020-03-28 16:37:26 +01:00
|
|
|
user_id (:obj:`int`): Unique identifier of the target administrator.
|
2022-11-22 11:07:42 +01:00
|
|
|
custom_title (:obj:`str`): New custom title for the administrator;
|
|
|
|
0-:tg-const:`telegram.constants.ChatLimit.CHAT_ADMINISTRATOR_CUSTOM_TITLE_LENGTH`
|
|
|
|
characters, emoji are not allowed.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2020-03-28 16:37:26 +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.
|
2020-03-28 16:37:26 +01:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2020-03-28 16:37:26 +01:00
|
|
|
|
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "user_id": user_id, "custom_title": custom_title}
|
2020-03-28 16:37:26 +01:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"setChatAdministratorCustomTitle",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2020-03-28 16:37:26 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def export_chat_invite_link(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> str:
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
2021-03-14 16:41:35 +01:00
|
|
|
Use this method to generate a new primary 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
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
Note:
|
|
|
|
Each administrator in a chat generates their own invite links. Bots can't use invite
|
|
|
|
links generated by other administrators. If you want your bot to work with invite
|
|
|
|
links, it will need to generate its own link using :meth:`export_chat_invite_link` or
|
|
|
|
by calling the :meth:`get_chat` method. If your bot needs to generate a new primary
|
2022-12-15 15:20:04 +01:00
|
|
|
invite link replacing its previous one, use :meth:`export_chat_invite_link` again.
|
2022-09-19 22:31:23 +02:00
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"exportChatInviteLink",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def create_chat_invite_link(
|
2021-03-14 16:41:35 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2023-05-18 07:57:59 +02:00
|
|
|
expire_date: Optional[Union[int, datetime]] = None,
|
|
|
|
member_limit: Optional[int] = None,
|
|
|
|
name: Optional[str] = None,
|
|
|
|
creates_join_request: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-03-14 16:41:35 +01:00
|
|
|
) -> ChatInviteLink:
|
|
|
|
"""
|
|
|
|
Use this method to create an additional invite link for a chat. The bot must be an
|
|
|
|
administrator in the chat for this to work and must have the appropriate admin rights.
|
|
|
|
The link can be revoked using the method :meth:`revoke_chat_invite_link`.
|
|
|
|
|
2023-07-09 11:22:08 +02:00
|
|
|
Note:
|
|
|
|
When joining *public* groups via an invite link, Telegram clients may display the
|
|
|
|
usual "Join" button, effectively ignoring the invite link. In particular, the parameter
|
|
|
|
:paramref:`creates_join_request` has no effect in this case.
|
|
|
|
However, this behavior is undocument and may be subject to change.
|
|
|
|
See `this GitHub thread <https://github.com/tdlib/telegram-bot-api/issues/429>`_
|
|
|
|
for some discussion.
|
|
|
|
|
2021-03-14 16:41:35 +01:00
|
|
|
.. versionadded:: 13.4
|
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2021-03-14 16:41:35 +01:00
|
|
|
expire_date (:obj:`int` | :obj:`datetime.datetime`, optional): Date when the link will
|
2021-06-06 12:16:23 +02:00
|
|
|
expire. Integer input will be interpreted as Unix timestamp.
|
2021-03-14 16:41:35 +01:00
|
|
|
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
|
2022-06-27 18:58:51 +02:00
|
|
|
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
|
|
|
|
used.
|
2021-03-14 16:41:35 +01:00
|
|
|
member_limit (:obj:`int`, optional): Maximum number of users that can be members of
|
2021-11-29 20:32:26 +01:00
|
|
|
the chat simultaneously after joining the chat via this invite link;
|
2022-11-22 11:07:42 +01:00
|
|
|
:tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
|
|
|
|
:tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
|
2022-05-18 17:18:44 +02:00
|
|
|
name (:obj:`str`, optional): Invite link name;
|
|
|
|
0-:tg-const:`telegram.constants.ChatInviteLinkLimit.NAME_LENGTH` characters.
|
|
|
|
|
|
|
|
.. versionadded:: 13.8
|
|
|
|
creates_join_request (:obj:`bool`, optional): :obj:`True`, if users joining the chat
|
|
|
|
via the link need to be approved by chat administrators.
|
2022-06-27 18:58:51 +02:00
|
|
|
If :obj:`True`, :paramref:`member_limit` can't be specified.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
|
|
|
.. versionadded:: 13.8
|
|
|
|
|
2021-03-14 16:41:35 +01:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.ChatInviteLink`
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"expire_date": expire_date,
|
|
|
|
"member_limit": member_limit,
|
|
|
|
"name": name,
|
|
|
|
"creates_join_request": creates_join_request,
|
|
|
|
}
|
2021-11-08 19:02:20 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"createChatInviteLink",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-03-14 16:41:35 +01:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return ChatInviteLink.de_json(result, self) # type: ignore[return-value]
|
2021-03-14 16:41:35 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def edit_chat_invite_link(
|
2021-03-14 16:41:35 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2021-11-29 20:32:26 +01:00
|
|
|
invite_link: Union[str, "ChatInviteLink"],
|
2023-05-18 07:57:59 +02:00
|
|
|
expire_date: Optional[Union[int, datetime]] = None,
|
|
|
|
member_limit: Optional[int] = None,
|
|
|
|
name: Optional[str] = None,
|
|
|
|
creates_join_request: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-03-14 16:41:35 +01:00
|
|
|
) -> ChatInviteLink:
|
|
|
|
"""
|
|
|
|
Use this method to edit a non-primary invite link created by the bot. The bot must be an
|
|
|
|
administrator in the chat for this to work and must have the appropriate admin rights.
|
|
|
|
|
2021-11-08 19:02:20 +01:00
|
|
|
Note:
|
|
|
|
Though not stated explicitly in the official docs, Telegram changes not only the
|
|
|
|
optional parameters that are explicitly passed, but also replaces all other optional
|
|
|
|
parameters to the default values. However, since not documented, this behaviour may
|
|
|
|
change unbeknown to PTB.
|
|
|
|
|
2021-03-14 16:41:35 +01:00
|
|
|
.. versionadded:: 13.4
|
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2021-11-29 20:32:26 +01:00
|
|
|
invite_link (:obj:`str` | :obj:`telegram.ChatInviteLink`): The invite link to edit.
|
|
|
|
|
2022-05-06 17:15:23 +02:00
|
|
|
.. versionchanged:: 20.0
|
2021-11-29 20:32:26 +01:00
|
|
|
Now also accepts :obj:`telegram.ChatInviteLink` instances.
|
2021-03-14 16:41:35 +01:00
|
|
|
expire_date (:obj:`int` | :obj:`datetime.datetime`, optional): Date when the link will
|
|
|
|
expire.
|
|
|
|
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
|
2022-06-27 18:58:51 +02:00
|
|
|
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
|
|
|
|
used.
|
2021-03-14 16:41:35 +01:00
|
|
|
member_limit (:obj:`int`, optional): Maximum number of users that can be members of
|
2021-11-29 20:32:26 +01:00
|
|
|
the chat simultaneously after joining the chat via this invite link;
|
2022-11-22 11:07:42 +01:00
|
|
|
:tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
|
|
|
|
:tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
|
2022-05-18 17:18:44 +02:00
|
|
|
name (:obj:`str`, optional): Invite link name;
|
|
|
|
0-:tg-const:`telegram.constants.ChatInviteLinkLimit.NAME_LENGTH` characters.
|
|
|
|
|
|
|
|
.. versionadded:: 13.8
|
|
|
|
creates_join_request (:obj:`bool`, optional): :obj:`True`, if users joining the chat
|
|
|
|
via the link need to be approved by chat administrators.
|
2022-06-27 18:58:51 +02:00
|
|
|
If :obj:`True`, :paramref:`member_limit` can't be specified.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
|
|
|
.. versionadded:: 13.8
|
|
|
|
|
2021-03-14 16:41:35 +01:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.ChatInviteLink`
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
2021-11-29 20:32:26 +01:00
|
|
|
link = invite_link.invite_link if isinstance(invite_link, ChatInviteLink) else invite_link
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"invite_link": link,
|
|
|
|
"expire_date": expire_date,
|
|
|
|
"member_limit": member_limit,
|
|
|
|
"name": name,
|
|
|
|
"creates_join_request": creates_join_request,
|
|
|
|
}
|
2021-11-08 19:02:20 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"editChatInviteLink",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-03-14 16:41:35 +01:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return ChatInviteLink.de_json(result, self) # type: ignore[return-value]
|
2021-03-14 16:41:35 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def revoke_chat_invite_link(
|
2021-03-14 16:41:35 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2021-11-29 20:32:26 +01:00
|
|
|
invite_link: Union[str, "ChatInviteLink"],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-03-14 16:41:35 +01:00
|
|
|
) -> ChatInviteLink:
|
|
|
|
"""
|
|
|
|
Use this method to revoke an invite link created by the bot. If the primary link is
|
|
|
|
revoked, a new link is automatically generated. The bot must be an administrator in the
|
|
|
|
chat for this to work and must have the appropriate admin rights.
|
|
|
|
|
|
|
|
.. versionadded:: 13.4
|
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2021-11-29 20:32:26 +01:00
|
|
|
invite_link (:obj:`str` | :obj:`telegram.ChatInviteLink`): The invite link to revoke.
|
|
|
|
|
2022-05-06 17:15:23 +02:00
|
|
|
.. versionchanged:: 20.0
|
2021-11-29 20:32:26 +01:00
|
|
|
Now also accepts :obj:`telegram.ChatInviteLink` instances.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2021-03-14 16:41:35 +01:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.ChatInviteLink`
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
2021-11-29 20:32:26 +01:00
|
|
|
link = invite_link.invite_link if isinstance(invite_link, ChatInviteLink) else invite_link
|
|
|
|
data: JSONDict = {"chat_id": chat_id, "invite_link": link}
|
2021-03-14 16:41:35 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"revokeChatInviteLink",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-03-14 16:41:35 +01:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return ChatInviteLink.de_json(result, self) # type: ignore[return-value]
|
2021-03-14 16:41:35 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def approve_chat_join_request(
|
2021-11-08 19:02:20 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
user_id: int,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-11-08 19:02:20 +01:00
|
|
|
) -> bool:
|
|
|
|
"""Use this method to approve a chat join request.
|
|
|
|
|
|
|
|
The bot must be an administrator in the chat for this to work and must have the
|
|
|
|
:attr:`telegram.ChatPermissions.can_invite_users` administrator right.
|
|
|
|
|
|
|
|
.. versionadded:: 13.8
|
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2021-11-08 19:02:20 +01:00
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2021-11-08 19:02:20 +01:00
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id, "user_id": user_id}
|
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"approveChatJoinRequest",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-11-08 19:02:20 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def decline_chat_join_request(
|
2021-11-08 19:02:20 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
user_id: int,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-11-08 19:02:20 +01:00
|
|
|
) -> bool:
|
|
|
|
"""Use this method to decline a chat join request.
|
|
|
|
|
|
|
|
The bot must be an administrator in the chat for this to work and must have the
|
|
|
|
:attr:`telegram.ChatPermissions.can_invite_users` administrator right.
|
|
|
|
|
|
|
|
.. versionadded:: 13.8
|
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2021-11-08 19:02:20 +01:00
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2021-11-08 19:02:20 +01:00
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id, "user_id": user_id}
|
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"declineChatJoinRequest",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-11-08 19:02:20 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_chat_photo(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2020-11-29 16:20:46 +01:00
|
|
|
photo: FileInput,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-02-09 17:30:16 +01:00
|
|
|
photo (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path`): New chat photo.
|
2022-09-19 22:31:23 +02:00
|
|
|
|uploadinput|
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
File paths as input is also accepted for bots *not* running in
|
|
|
|
:paramref:`~telegram.Bot.local_mode`.
|
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-09-19 22:31:23 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "photo": self._parse_file_input(photo)}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"setChatPhoto",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def delete_chat_photo(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"deleteChatPhoto",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_chat_title(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
title: str,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-11-22 10:43:50 +01:00
|
|
|
title (:obj:`str`): New chat title,
|
|
|
|
:tg-const:`telegram.constants.ChatLimit.MIN_CHAT_TITLE_LENGTH`-
|
|
|
|
:tg-const:`telegram.constants.ChatLimit.MAX_CHAT_TITLE_LENGTH` characters.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "title": title}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"setChatTitle",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_chat_description(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2023-05-18 07:57:59 +02:00
|
|
|
description: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-11-22 11:07:42 +01:00
|
|
|
description (:obj:`str`, optional): New chat description,
|
2022-11-22 12:09:44 +01:00
|
|
|
0-:tg-const:`telegram.constants.ChatLimit.CHAT_DESCRIPTION_LENGTH`
|
2022-11-22 11:07:42 +01:00
|
|
|
characters.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "description": description}
|
2021-08-29 18:17:06 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"setChatDescription",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def pin_chat_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2021-03-14 16:42:03 +01:00
|
|
|
message_id: int,
|
2021-02-19 19:07:48 +01:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
2020-11-29 16:20:46 +01:00
|
|
|
Use this method to add a message to the list of pinned messages in a chat. If the
|
|
|
|
chat is not a private chat, the bot must be an administrator in the chat for this to work
|
2022-06-27 18:58:51 +02:00
|
|
|
and must have the :paramref:`~telegram.ChatAdministratorRights.can_pin_messages` admin
|
|
|
|
right in a supergroup or :attr:`~telegram.ChatMemberAdministrator.can_edit_messages` admin
|
|
|
|
right in a channel.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
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
|
2020-11-29 16:20:46 +01:00
|
|
|
to send a notification to all chat members about the new pinned message.
|
|
|
|
Notifications are always disabled in channels and private chats.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2021-02-19 19:07:48 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"disable_notification": disable_notification,
|
|
|
|
}
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"pinChatMessage",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
2020-11-29 16:20:46 +01:00
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def unpin_chat_message(
|
2020-11-29 16:20:46 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2023-05-18 07:57:59 +02:00
|
|
|
message_id: Optional[int] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
2020-11-29 16:20:46 +01:00
|
|
|
Use this method to remove a message from the list of pinned messages in a chat. If the
|
|
|
|
chat is not a private chat, the bot must be an administrator in the chat for this to work
|
2022-06-27 18:58:51 +02:00
|
|
|
and must have the :paramref:`~telegram.ChatAdministratorRights.can_pin_messages` admin
|
|
|
|
right in a supergroup or :attr:`~telegram.ChatMemberAdministrator.can_edit_messages` admin
|
|
|
|
right in a channel.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2020-11-29 16:20:46 +01:00
|
|
|
message_id (:obj:`int`, optional): Identifier of a message to unpin. If not specified,
|
|
|
|
the most recent pinned message (by sending date) will be unpinned.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "message_id": message_id}
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"unpinChatMessage",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
2020-11-29 16:20:46 +01:00
|
|
|
)
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def unpin_all_chat_messages(
|
2020-11-29 16:20:46 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-11-29 16:20:46 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to clear the list of pinned messages in a chat. If the
|
|
|
|
chat is not a private chat, the bot must be an administrator in the chat for this
|
2022-06-27 18:58:51 +02:00
|
|
|
to work and must have the :paramref:`~telegram.ChatAdministratorRights.can_pin_messages`
|
|
|
|
admin right in a supergroup or :attr:`~telegram.ChatMemberAdministrator.can_edit_messages`
|
|
|
|
admin right in a channel.
|
2020-11-29 16:20:46 +01:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2020-11-29 16:20:46 +01:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2020-11-29 16:20:46 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"unpinAllChatMessages",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
2020-11-29 16:20:46 +01:00
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_sticker_set(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
|
|
|
name: str,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> StickerSet:
|
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.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2017-07-22 13:34:51 +02:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.StickerSet`
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"name": name}
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getStickerSet",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return StickerSet.de_json(result, self) # type: ignore[return-value]
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2022-08-25 19:36:55 +02:00
|
|
|
async def get_custom_emoji_stickers(
|
|
|
|
self,
|
2023-01-01 14:24:30 +01:00
|
|
|
custom_emoji_ids: Sequence[str],
|
2022-08-25 19:36:55 +02:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Tuple[Sticker, ...]:
|
2022-08-25 19:36:55 +02:00
|
|
|
"""
|
|
|
|
Use this method to get information about emoji stickers by their identifiers.
|
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
Returns a tuple instead of a list.
|
|
|
|
|
2022-08-25 19:36:55 +02:00
|
|
|
Args:
|
2023-01-01 14:24:30 +01:00
|
|
|
custom_emoji_ids (Sequence[:obj:`str`]): Sequence of custom emoji identifiers.
|
2022-08-25 19:36:55 +02:00
|
|
|
At most :tg-const:`telegram.constants.CustomEmojiStickerLimit.\
|
|
|
|
CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
|
|
|
|
2023-01-01 14:24:30 +01:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
|
|
|
|
2022-08-25 19:36:55 +02:00
|
|
|
Returns:
|
2022-12-15 15:00:36 +01:00
|
|
|
Tuple[:class:`telegram.Sticker`]
|
2022-08-25 19:36:55 +02:00
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"custom_emoji_ids": custom_emoji_ids}
|
|
|
|
result = await self._post(
|
|
|
|
"getCustomEmojiStickers",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return Sticker.de_list(result, self)
|
2022-08-25 19:36:55 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def upload_sticker_file(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2024-02-09 18:12:13 +01:00
|
|
|
sticker: FileInput,
|
|
|
|
sticker_format: str,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> File:
|
2017-07-22 13:34:51 +02:00
|
|
|
"""
|
2023-03-25 11:47:26 +01:00
|
|
|
Use this method to upload a file with a sticker for later use in the
|
2021-03-14 16:46:37 +01:00
|
|
|
:meth:`create_new_sticker_set` and :meth:`add_sticker_to_set` methods (can be used multiple
|
2017-07-22 13:34:51 +02:00
|
|
|
times).
|
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
Removed deprecated parameter ``png_sticker``.
|
|
|
|
|
2017-07-22 13:34:51 +02:00
|
|
|
Args:
|
|
|
|
user_id (:obj:`int`): User identifier of sticker file owner.
|
2023-03-25 11:47:26 +01:00
|
|
|
sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`):
|
|
|
|
A file with the sticker in the ``".WEBP"``, ``".PNG"``, ``".TGS"`` or ``".WEBM"``
|
|
|
|
format. See `here <https://core.telegram.org/stickers>`_ for technical requirements
|
|
|
|
. |uploadinput|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
|
|
|
sticker_format (:obj:`str`): Format of the sticker. Must be one of
|
|
|
|
:attr:`telegram.constants.StickerFormat.STATIC`,
|
|
|
|
:attr:`telegram.constants.StickerFormat.ANIMATED`,
|
|
|
|
:attr:`telegram.constants.StickerFormat.VIDEO`.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2017-07-22 13:34:51 +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
|
|
|
:class:`telegram.File`: On success, the uploaded File is returned.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
Raises:
|
2023-09-03 14:23:48 +02:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2023-03-25 11:47:26 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"user_id": user_id,
|
2024-02-09 18:12:13 +01:00
|
|
|
"sticker": self._parse_file_input(sticker),
|
2023-03-25 11:47:26 +01:00
|
|
|
"sticker_format": sticker_format,
|
|
|
|
}
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"uploadStickerFile",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return File.de_json(result, self) # type: ignore[return-value]
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2023-09-03 14:23:48 +02:00
|
|
|
async def add_sticker_to_set(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2020-10-06 19:28:40 +02:00
|
|
|
name: str,
|
2024-02-09 18:12:13 +01:00
|
|
|
sticker: "InputSticker",
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2020-04-10 20:05:01 +02:00
|
|
|
"""
|
2023-09-03 14:23:48 +02:00
|
|
|
Use this method to add a new sticker to a set created by the bot. The format of the added
|
|
|
|
sticker must match the format of the other stickers in the set. Emoji sticker sets can have
|
2024-04-12 11:58:25 +02:00
|
|
|
up to :tg-const:`telegram.constants.StickerSetLimit.MAX_EMOJI_STICKERS` stickers. Other
|
2023-09-03 14:23:48 +02:00
|
|
|
sticker sets can have up to
|
|
|
|
:tg-const:`telegram.constants.StickerSetLimit.MAX_STATIC_STICKERS` stickers.
|
2022-08-25 19:36:55 +02:00
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionchanged:: 20.2
|
2023-09-03 14:23:48 +02:00
|
|
|
Since Bot API 6.6, the parameter :paramref:`sticker` replace the parameters
|
|
|
|
``png_sticker``, ``tgs_sticker``, ``webm_sticker``, ``emojis``, and ``mask_position``.
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
Removed deprecated parameters ``png_sticker``, ``tgs_sticker``, ``webm_sticker``,
|
|
|
|
``emojis``, and ``mask_position``.
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2017-07-22 13:34:51 +02:00
|
|
|
Args:
|
|
|
|
user_id (:obj:`int`): User identifier of created sticker set owner.
|
2023-09-03 14:23:48 +02:00
|
|
|
name (:obj:`str`): Sticker set name.
|
|
|
|
sticker (:class:`telegram.InputSticker`): An object with information about the added
|
|
|
|
sticker. If exactly the same sticker had already been added to the set, then the
|
|
|
|
set isn't changed.
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2017-07-22 13:34:51 +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-22 13:34:51 +02:00
|
|
|
|
|
|
|
Raises:
|
2023-09-03 14:23:48 +02:00
|
|
|
:class:`telegram.error.TelegramError`
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2023-09-03 14:23:48 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"user_id": user_id,
|
|
|
|
"name": name,
|
2023-09-03 14:23:48 +02:00
|
|
|
"sticker": sticker,
|
2022-12-01 19:26:01 +01:00
|
|
|
}
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-09-03 14:23:48 +02:00
|
|
|
"addStickerToSet",
|
2022-04-24 12:38:09 +02:00
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2023-09-03 14:23:48 +02:00
|
|
|
async def set_sticker_position_in_set(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
2023-09-03 14:23:48 +02:00
|
|
|
sticker: str,
|
|
|
|
position: int,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-09-03 14:23:48 +02:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2023-09-03 14:23:48 +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:
|
2023-09-03 14:23:48 +02:00
|
|
|
sticker (:obj:`str`): File identifier of the sticker.
|
|
|
|
position (:obj:`int`): New sticker position in the set, zero-based.
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2017-07-22 13:34:51 +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-22 13:34:51 +02:00
|
|
|
|
|
|
|
Raises:
|
2023-09-03 14:23:48 +02:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2023-09-03 14:23:48 +02:00
|
|
|
data: JSONDict = {"sticker": sticker, "position": position}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-09-03 14:23:48 +02:00
|
|
|
"setStickerPositionInSet",
|
2022-04-24 12:38:09 +02:00
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2023-09-03 14:23:48 +02:00
|
|
|
async def create_new_sticker_set(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2023-09-03 14:23:48 +02:00
|
|
|
name: str,
|
|
|
|
title: str,
|
2024-02-09 18:12:13 +01:00
|
|
|
stickers: Sequence["InputSticker"],
|
2024-04-12 11:58:25 +02:00
|
|
|
sticker_format: Optional[str] = None,
|
2023-09-03 14:23:48 +02:00
|
|
|
sticker_type: Optional[str] = None,
|
|
|
|
needs_repainting: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-11-26 16:44:18 +01:00
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
2022-04-24 12:38:09 +02:00
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2023-09-03 14:23:48 +02:00
|
|
|
"""
|
|
|
|
Use this method to create new sticker set owned by a user.
|
|
|
|
The bot will be able to edit the created sticker set thus created.
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
The parameter ``contains_masks`` has been removed. Use :paramref:`sticker_type`
|
|
|
|
instead.
|
|
|
|
|
|
|
|
.. versionchanged:: 20.2
|
|
|
|
Since Bot API 6.6, the parameters :paramref:`stickers` and :paramref:`sticker_format`
|
|
|
|
replace the parameters ``png_sticker``, ``tgs_sticker``,``webm_sticker``, ``emojis``,
|
|
|
|
and ``mask_position``.
|
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
Removed the deprecated parameters mentioned above and adjusted the order of the
|
|
|
|
parameters.
|
2017-07-22 13:34:51 +02:00
|
|
|
|
|
|
|
Args:
|
2023-09-03 14:23:48 +02:00
|
|
|
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.
|
|
|
|
:tg-const:`telegram.constants.StickerLimit.MIN_NAME_AND_TITLE`-
|
|
|
|
:tg-const:`telegram.constants.StickerLimit.MAX_NAME_AND_TITLE` characters.
|
|
|
|
title (:obj:`str`): Sticker set title,
|
|
|
|
:tg-const:`telegram.constants.StickerLimit.MIN_NAME_AND_TITLE`-
|
|
|
|
:tg-const:`telegram.constants.StickerLimit.MAX_NAME_AND_TITLE` characters.
|
|
|
|
|
|
|
|
stickers (Sequence[:class:`telegram.InputSticker`]): A sequence of
|
|
|
|
:tg-const:`telegram.constants.StickerSetLimit.MIN_INITIAL_STICKERS`-
|
|
|
|
:tg-const:`telegram.constants.StickerSetLimit.MAX_INITIAL_STICKERS` initial
|
|
|
|
stickers to be added to the sticker set.
|
|
|
|
|
|
|
|
.. versionadded:: 20.2
|
|
|
|
|
|
|
|
sticker_format (:obj:`str`): Format of stickers in the set, must be one of
|
|
|
|
:attr:`~telegram.constants.StickerFormat.STATIC`,
|
|
|
|
:attr:`~telegram.constants.StickerFormat.ANIMATED` or
|
|
|
|
:attr:`~telegram.constants.StickerFormat.VIDEO`.
|
|
|
|
|
|
|
|
.. versionadded:: 20.2
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. deprecated:: 21.1
|
2024-04-12 11:58:25 +02:00
|
|
|
Use :paramref:`telegram.InputSticker.format` instead.
|
|
|
|
|
2023-09-03 14:23:48 +02:00
|
|
|
sticker_type (:obj:`str`, optional): Type of stickers in the set, pass
|
|
|
|
:attr:`telegram.Sticker.REGULAR` or :attr:`telegram.Sticker.MASK`, or
|
|
|
|
:attr:`telegram.Sticker.CUSTOM_EMOJI`. By default, a regular sticker set is created
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
needs_repainting (:obj:`bool`, optional): Pass :obj:`True` if stickers in the sticker
|
|
|
|
set must be repainted to the color of text when used in messages, the accent color
|
|
|
|
if used as emoji status, white on chat photos, or another appropriate color based
|
|
|
|
on context; for custom emoji sticker sets only.
|
|
|
|
|
|
|
|
.. versionadded:: 20.2
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2017-07-22 13:34:51 +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-22 13:34:51 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-07-22 13:34:51 +02:00
|
|
|
"""
|
2024-04-12 11:58:25 +02:00
|
|
|
if sticker_format is not None:
|
|
|
|
warn(
|
|
|
|
"The parameter `sticker_format` is deprecated. Use the parameter"
|
|
|
|
" `InputSticker.format` in the parameter `stickers` instead.",
|
|
|
|
stacklevel=2,
|
|
|
|
category=PTBDeprecationWarning,
|
|
|
|
)
|
|
|
|
|
2023-09-03 14:23:48 +02:00
|
|
|
data: JSONDict = {
|
|
|
|
"user_id": user_id,
|
|
|
|
"name": name,
|
|
|
|
"title": title,
|
|
|
|
"stickers": stickers,
|
|
|
|
"sticker_format": sticker_format,
|
|
|
|
"sticker_type": sticker_type,
|
|
|
|
"needs_repainting": needs_repainting,
|
|
|
|
}
|
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-09-03 14:23:48 +02:00
|
|
|
"createNewStickerSet",
|
2022-04-24 12:38:09 +02:00
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def delete_sticker_from_set(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
|
|
|
sticker: str,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2017-07-22 13:34:51 +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-22 13:34:51 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2017-09-01 08:43:08 +02:00
|
|
|
|
2017-07-22 13:34:51 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"sticker": sticker}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"deleteStickerFromSet",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2017-07-22 13:34:51 +02:00
|
|
|
|
2023-03-25 11:47:26 +01:00
|
|
|
async def delete_sticker_set(
|
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to delete a sticker set that was created by the bot.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
name (:obj:`str`): Sticker set name.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"name": name}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-03-25 11:47:26 +01:00
|
|
|
"deleteStickerSet",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def set_sticker_set_thumbnail(
|
|
|
|
self,
|
|
|
|
name: str,
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
2024-04-12 11:58:25 +02:00
|
|
|
format: str, # pylint: disable=redefined-builtin
|
2023-05-18 07:57:59 +02:00
|
|
|
thumbnail: Optional[FileInput] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> bool:
|
|
|
|
"""Use this method to set the thumbnail of a regular or mask sticker set. The format of the
|
|
|
|
thumbnail file must match the format of the stickers in the set.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionchanged:: 21.1
|
2024-04-12 11:58:25 +02:00
|
|
|
As per Bot API 7.2, the new argument :paramref:`format` will be required, and thus the
|
|
|
|
order of the arguments had to be changed.
|
|
|
|
|
2023-03-25 11:47:26 +01:00
|
|
|
Args:
|
|
|
|
name (:obj:`str`): Sticker set name
|
|
|
|
user_id (:obj:`int`): User identifier of created sticker set owner.
|
2024-04-12 11:58:25 +02:00
|
|
|
format (:obj:`str`): Format of the added sticker, must be one of
|
|
|
|
:tg-const:`telegram.constants.StickerFormat.STATIC` for a
|
|
|
|
``.WEBP`` or ``.PNG`` image, :tg-const:`telegram.constants.StickerFormat.ANIMATED`
|
|
|
|
for a ``.TGS`` animation, :tg-const:`telegram.constants.StickerFormat.VIDEO` for a
|
|
|
|
WEBM video.
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-04-12 11:58:25 +02:00
|
|
|
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`, \
|
|
|
|
optional): A **.WEBP** or **.PNG** image with the thumbnail, must
|
|
|
|
be up to :tg-const:`telegram.constants.StickerSetLimit.MAX_STATIC_THUMBNAIL_SIZE`
|
|
|
|
kilobytes in size and have width and height of exactly
|
|
|
|
:tg-const:`telegram.constants.StickerSetLimit.STATIC_THUMB_DIMENSIONS` px, or a
|
|
|
|
**.TGS** animation with the thumbnail up to
|
|
|
|
:tg-const:`telegram.constants.StickerSetLimit.MAX_ANIMATED_THUMBNAIL_SIZE`
|
|
|
|
kilobytes in size; see
|
|
|
|
`the docs <https://core.telegram.org/stickers#animation-requirements>`_ for
|
|
|
|
animated sticker technical requirements, or a **.WEBM** video with the thumbnail up
|
|
|
|
to :tg-const:`telegram.constants.StickerSetLimit.MAX_ANIMATED_THUMBNAIL_SIZE`
|
|
|
|
kilobytes in size; see
|
|
|
|
`this <https://core.telegram.org/stickers#video-requirements>`_ for video sticker
|
|
|
|
technical requirements.
|
|
|
|
|
|
|
|
|fileinput|
|
|
|
|
|
|
|
|
Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If
|
|
|
|
omitted, then the thumbnail is dropped and the first sticker is used as the
|
|
|
|
thumbnail.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"name": name,
|
|
|
|
"user_id": user_id,
|
2023-03-25 11:47:26 +01:00
|
|
|
"thumbnail": self._parse_file_input(thumbnail) if thumbnail else None,
|
2024-04-12 11:58:25 +02:00
|
|
|
"format": format,
|
2022-12-01 19:26:01 +01:00
|
|
|
}
|
2020-04-10 19:22:45 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-03-25 11:47:26 +01:00
|
|
|
"setStickerSetThumbnail",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def set_sticker_set_title(
|
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
title: str,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to set the title of a created sticker set.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
name (:obj:`str`): Sticker set name.
|
|
|
|
title (:obj:`str`): Sticker set title,
|
|
|
|
:tg-const:`telegram.constants.StickerLimit.MIN_NAME_AND_TITLE`-
|
|
|
|
:tg-const:`telegram.constants.StickerLimit.MAX_NAME_AND_TITLE` characters.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"name": name, "title": title}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-03-25 11:47:26 +01:00
|
|
|
"setStickerSetTitle",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def set_sticker_emoji_list(
|
|
|
|
self,
|
|
|
|
sticker: str,
|
|
|
|
emoji_list: Sequence[str],
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to change the list of emoji assigned to a regular or custom emoji sticker.
|
|
|
|
The sticker must belong to a sticker set created by the bot.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
sticker (:obj:`str`): File identifier of the sticker.
|
|
|
|
emoji_list (Sequence[:obj:`str`]): A sequence of
|
|
|
|
:tg-const:`telegram.constants.StickerLimit.MIN_STICKER_EMOJI`-
|
|
|
|
:tg-const:`telegram.constants.StickerLimit.MAX_STICKER_EMOJI` emoji associated with
|
|
|
|
the sticker.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"sticker": sticker, "emoji_list": emoji_list}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-03-25 11:47:26 +01:00
|
|
|
"setStickerEmojiList",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def set_sticker_keywords(
|
|
|
|
self,
|
|
|
|
sticker: str,
|
2023-05-18 07:57:59 +02:00
|
|
|
keywords: Optional[Sequence[str]] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to change search keywords assigned to a regular or custom emoji sticker.
|
|
|
|
The sticker must belong to a sticker set created by the bot.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
sticker (:obj:`str`): File identifier of the sticker.
|
|
|
|
keywords (Sequence[:obj:`str`]): A sequence of
|
|
|
|
0-:tg-const:`telegram.constants.StickerLimit.MAX_SEARCH_KEYWORDS` search keywords
|
|
|
|
for the sticker with total length up to
|
|
|
|
:tg-const:`telegram.constants.StickerLimit.MAX_KEYWORD_LENGTH` characters.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"sticker": sticker, "keywords": keywords}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-03-25 11:47:26 +01:00
|
|
|
"setStickerKeywords",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def set_sticker_mask_position(
|
|
|
|
self,
|
|
|
|
sticker: str,
|
2023-05-18 07:57:59 +02:00
|
|
|
mask_position: Optional[MaskPosition] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to change the mask position of a mask sticker.
|
|
|
|
The sticker must belong to a sticker set that was created by the bot.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
sticker (:obj:`str`): File identifier of the sticker.
|
|
|
|
mask_position (:class:`telegram.MaskPosition`, optional): A object with the position
|
|
|
|
where the mask should be placed on faces. Omit the parameter to remove the mask
|
|
|
|
position.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"sticker": sticker, "mask_position": mask_position}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-03-25 11:47:26 +01:00
|
|
|
"setStickerMaskPosition",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def set_custom_emoji_sticker_set_thumbnail(
|
|
|
|
self,
|
|
|
|
name: str,
|
2023-05-18 07:57:59 +02:00
|
|
|
custom_emoji_id: Optional[str] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to set the thumbnail of a custom emoji sticker set.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
name (:obj:`str`): Sticker set name.
|
|
|
|
custom_emoji_id (:obj:`str`, optional): Custom emoji identifier of a sticker from the
|
|
|
|
sticker set; pass an empty string to drop the thumbnail and use the first sticker
|
|
|
|
as the thumbnail.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"name": name, "custom_emoji_id": custom_emoji_id}
|
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2023-03-25 11:47:26 +01:00
|
|
|
"setCustomEmojiStickerSetThumbnail",
|
2022-04-24 12:38:09 +02:00
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2020-04-10 19:22:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_passport_data_errors(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
2023-09-15 21:33:42 +02:00
|
|
|
user_id: int,
|
|
|
|
errors: Sequence["PassportElementError"],
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
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
|
|
|
"""
|
|
|
|
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
|
2023-01-01 14:24:30 +01:00
|
|
|
errors (Sequence[:class:`PassportElementError`]): A Sequence describing the errors.
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
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
|
|
|
|
|
|
|
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:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.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
|
|
|
|
|
|
|
"""
|
2022-04-24 12:38:09 +02:00
|
|
|
data: JSONDict = {"user_id": user_id, "errors": errors}
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"setPassportDataErrors",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_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
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_poll(
|
2019-08-23 21:20:41 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
|
|
|
question: str,
|
2023-01-01 14:24:30 +01:00
|
|
|
options: Sequence[str],
|
2023-05-18 07:57:59 +02:00
|
|
|
is_anonymous: Optional[bool] = None,
|
|
|
|
type: Optional[str] = None, # pylint: disable=redefined-builtin
|
|
|
|
allows_multiple_answers: Optional[bool] = None,
|
2023-06-29 18:17:47 +02:00
|
|
|
correct_option_id: Optional[CorrectOptionID] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
is_closed: Optional[bool] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
|
|
|
explanation: Optional[str] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
explanation_parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
open_period: Optional[int] = None,
|
|
|
|
close_date: Optional[Union[int, datetime]] = None,
|
|
|
|
explanation_entities: Optional[Sequence["MessageEntity"]] = None,
|
2022-01-07 17:02:23 +01:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> Message:
|
2019-08-23 21:20:41 +02:00
|
|
|
"""
|
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:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2022-11-22 11:07:42 +01:00
|
|
|
question (:obj:`str`): Poll question, :tg-const:`telegram.Poll.MIN_QUESTION_LENGTH`-
|
|
|
|
:tg-const:`telegram.Poll.MAX_QUESTION_LENGTH` characters.
|
2023-01-01 14:24:30 +01:00
|
|
|
options (Sequence[:obj:`str`]): Sequence of answer options,
|
2022-11-22 11:07:42 +01:00
|
|
|
:tg-const:`telegram.Poll.MIN_OPTION_NUMBER`-
|
|
|
|
:tg-const:`telegram.Poll.MAX_OPTION_NUMBER` strings
|
|
|
|
:tg-const:`telegram.Poll.MIN_OPTION_LENGTH`-
|
|
|
|
:tg-const:`telegram.Poll.MAX_OPTION_LENGTH` characters each.
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
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`.
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`, optional): Poll type, :tg-const:`telegram.Poll.QUIZ` or
|
|
|
|
:tg-const:`telegram.Poll.REGULAR`, defaults to :tg-const:`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
|
2022-11-22 11:07:42 +01:00
|
|
|
answer or taps on the lamp icon in a quiz-style poll,
|
|
|
|
0-:tg-const:`telegram.Poll.MAX_EXPLANATION_LENGTH` characters with at most
|
|
|
|
:tg-const:`telegram.Poll.MAX_EXPLANATION_LINE_FEEDS` line feeds after entities
|
|
|
|
parsing.
|
2020-05-02 11:56:52 +02:00
|
|
|
explanation_parse_mode (:obj:`str`, optional): Mode for parsing entities in the
|
2021-10-19 18:28:19 +02:00
|
|
|
explanation. See the constants in :class:`telegram.constants.ParseMode` for the
|
|
|
|
available modes.
|
2023-01-01 14:24:30 +01:00
|
|
|
explanation_entities (Sequence[:class:`telegram.MessageEntity`], optional): Sequence of
|
|
|
|
special entities that appear in message text, which can be specified instead of
|
2022-05-06 17:15:23 +02:00
|
|
|
:paramref:`explanation_parse_mode`.
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2020-05-02 11:56:52 +02:00
|
|
|
open_period (:obj:`int`, optional): Amount of time in seconds the poll will be active
|
2022-11-22 11:07:42 +01:00
|
|
|
after creation, :tg-const:`telegram.Poll.MIN_OPEN_PERIOD`-
|
|
|
|
:tg-const:`telegram.Poll.MAX_OPEN_PERIOD`. Can't be used together with
|
|
|
|
:paramref:`close_date`.
|
2020-05-02 11:56:52 +02:00
|
|
|
close_date (:obj:`int` | :obj:`datetime.datetime`, optional): Point in time (Unix
|
2022-11-22 11:07:42 +01:00
|
|
|
timestamp) when the poll will be automatically closed. Must be at least
|
|
|
|
:tg-const:`telegram.Poll.MIN_OPEN_PERIOD` and no more than
|
|
|
|
:tg-const:`telegram.Poll.MAX_OPEN_PERIOD` seconds in the future.
|
|
|
|
Can't be used together with :paramref:`open_period`.
|
2020-09-27 12:59:48 +02:00
|
|
|
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
|
2022-06-27 18:58:51 +02:00
|
|
|
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
|
|
|
|
used.
|
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.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2019-08-23 21:20:41 +02:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2019-08-23 21:20:41 +02:00
|
|
|
|
|
|
|
"""
|
2021-02-19 19:07:48 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"question": question,
|
|
|
|
"options": options,
|
|
|
|
"explanation_parse_mode": explanation_parse_mode,
|
2022-12-01 19:26:01 +01:00
|
|
|
"is_anonymous": is_anonymous,
|
|
|
|
"type": type,
|
|
|
|
"allows_multiple_answers": allows_multiple_answers,
|
|
|
|
"correct_option_id": correct_option_id,
|
|
|
|
"is_closed": is_closed,
|
|
|
|
"explanation": explanation,
|
|
|
|
"explanation_entities": explanation_entities,
|
|
|
|
"open_period": open_period,
|
|
|
|
"close_date": close_date,
|
2021-02-19 19:07:48 +01:00
|
|
|
}
|
2020-05-02 11:56:52 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendPoll",
|
|
|
|
data,
|
2019-08-23 21:20:41 +02:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2019-08-23 21:20:41 +02:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2019-08-23 21:20:41 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def stop_poll(
|
2019-08-23 21:20:41 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2021-03-14 16:42:03 +01:00
|
|
|
message_id: int,
|
2023-09-15 21:33:42 +02:00
|
|
|
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> Poll:
|
2019-08-23 21:20:41 +02:00
|
|
|
"""
|
|
|
|
Use this method to stop a poll which was sent by the bot.
|
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2019-08-23 21:20:41 +02:00
|
|
|
message_id (:obj:`int`): Identifier of the original message with the poll.
|
2022-01-03 09:09:03 +01:00
|
|
|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An object for a new
|
|
|
|
message inline keyboard.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2019-08-23 21:20:41 +02:00
|
|
|
Returns:
|
2021-10-01 16:51:03 +02:00
|
|
|
:class:`telegram.Poll`: On success, the stopped Poll is returned.
|
2019-08-23 21:20:41 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2019-08-23 21:20:41 +02:00
|
|
|
|
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"reply_markup": reply_markup,
|
|
|
|
}
|
2019-08-23 21:20:41 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"stopPoll",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return Poll.de_json(result, self) # type: ignore[return-value]
|
2019-08-23 21:20:41 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def send_dice(
|
2020-04-10 19:22:45 +02:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
chat_id: Union[int, str],
|
2021-02-19 19:07:48 +01:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
|
|
|
emoji: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> Message:
|
2020-04-10 19:22:45 +02:00
|
|
|
"""
|
2021-03-14 16:41:35 +01:00
|
|
|
Use this method to send an animated emoji that will display a random value.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
2022-08-27 11:46:51 +02:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user
|
2020-05-02 11:56:52 +02:00
|
|
|
emoji (:obj:`str`, optional): Emoji on which the dice throw animation is based.
|
2021-10-19 18:28:19 +02:00
|
|
|
Currently, must be one of :class:`telegram.constants.DiceEmoji`. Dice can have
|
2022-11-22 11:07:42 +01:00
|
|
|
values
|
|
|
|
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BOWLING`
|
|
|
|
for :tg-const:`telegram.Dice.DICE`, :tg-const:`telegram.Dice.DARTS` and
|
|
|
|
:tg-const:`telegram.Dice.BOWLING`, values
|
|
|
|
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BASKETBALL`
|
|
|
|
for :tg-const:`telegram.Dice.BASKETBALL` and :tg-const:`telegram.Dice.FOOTBALL`,
|
|
|
|
and values :tg-const:`telegram.Dice.MIN_VALUE`-
|
|
|
|
:tg-const:`telegram.Dice.MAX_VALUE_SLOT_MACHINE`
|
|
|
|
for :tg-const:`telegram.Dice.SLOT_MACHINE`. Defaults to
|
|
|
|
:tg-const:`telegram.Dice.DICE`.
|
2021-03-14 16:41:35 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.4
|
2022-11-22 11:07:42 +01:00
|
|
|
Added the :tg-const:`telegram.Dice.BOWLING` emoji.
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id (:obj:`str`, optional): |business_id_str|
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2022-01-03 08:13:33 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
|
|
|
|
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
|
|
|
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.Message`: On success, the sent Message is returned.
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "emoji": emoji}
|
2020-05-02 11:56:52 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._send_message(
|
2020-10-06 19:28:40 +02:00
|
|
|
"sendDice",
|
|
|
|
data,
|
2020-04-10 19:22:45 +02:00
|
|
|
reply_to_message_id=reply_to_message_id,
|
2022-04-24 12:38:09 +02:00
|
|
|
disable_notification=disable_notification,
|
2020-04-10 19:22:45 +02:00
|
|
|
reply_markup=reply_markup,
|
2020-11-29 16:20:46 +01:00
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content=protect_content,
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id=message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters=reply_parameters,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2020-06-30 22:07:38 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2024-04-12 11:58:25 +02:00
|
|
|
business_connection_id=business_connection_id,
|
2020-06-30 22:07:38 +02:00
|
|
|
)
|
2020-04-10 19:22:45 +02:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
async def get_my_default_administrator_rights(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
for_channels: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-05-03 18:21:50 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-05-03 18:21:50 +02:00
|
|
|
) -> ChatAdministratorRights:
|
|
|
|
"""Use this method to get the current default administrator rights of the bot.
|
|
|
|
|
|
|
|
.. seealso:: :meth:`set_my_default_administrator_rights`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
for_channels (:obj:`bool`, optional): Pass :obj:`True` to get default administrator
|
|
|
|
rights of the bot in channels. Otherwise, default administrator rights of the bot
|
|
|
|
for groups and supergroups will be returned.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.ChatAdministratorRights`: On success.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"for_channels": for_channels}
|
2022-05-03 18:21:50 +02:00
|
|
|
|
|
|
|
result = await self._post(
|
|
|
|
"getMyDefaultAdministratorRights",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return ChatAdministratorRights.de_json(result, self) # type: ignore[return-value]
|
2022-05-03 18:21:50 +02:00
|
|
|
|
|
|
|
async def set_my_default_administrator_rights(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
rights: Optional[ChatAdministratorRights] = None,
|
|
|
|
for_channels: Optional[bool] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-05-03 18:21:50 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-05-03 18:21:50 +02:00
|
|
|
) -> bool:
|
|
|
|
"""Use this method to change the default administrator rights requested by the bot when
|
|
|
|
it's added as an administrator to groups or channels. These rights will be suggested to
|
2024-04-12 12:03:01 +02:00
|
|
|
users, but they are free to modify the list before adding the bot.
|
2022-05-03 18:21:50 +02:00
|
|
|
|
|
|
|
.. seealso:: :meth:`get_my_default_administrator_rights`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
rights (:obj:`telegram.ChatAdministratorRights`, optional): A
|
|
|
|
:obj:`telegram.ChatAdministratorRights` object describing new default administrator
|
|
|
|
rights. If not specified, the default administrator rights will be cleared.
|
|
|
|
for_channels (:obj:`bool`, optional): Pass :obj:`True` to change the default
|
|
|
|
administrator rights of the bot in channels. Otherwise, the default administrator
|
|
|
|
rights of the bot for groups and supergroups will be changed.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
Returns:
|
|
|
|
:obj:`bool`: Returns :obj:`True` on success.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:obj:`telegram.error.TelegramError`
|
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"rights": rights, "for_channels": for_channels}
|
2022-05-03 18:21:50 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-05-03 18:21:50 +02:00
|
|
|
"setMyDefaultAdministratorRights",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_my_commands(
|
2021-07-01 17:45:19 +02:00
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
scope: Optional[BotCommandScope] = None,
|
|
|
|
language_code: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Tuple[BotCommand, ...]:
|
2020-04-10 19:22:45 +02:00
|
|
|
"""
|
2021-07-01 17:45:19 +02:00
|
|
|
Use this method to get the current list of the bot's commands for the given scope and user
|
|
|
|
language.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
2022-12-15 15:20:04 +01:00
|
|
|
.. seealso:: :meth:`set_my_commands`, :meth:`delete_my_commands`
|
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
Returns a tuple instead of a list.
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
Args:
|
2022-05-18 17:18:44 +02:00
|
|
|
scope (:class:`telegram.BotCommandScope`, optional): An object,
|
|
|
|
describing scope of users. Defaults to :class:`telegram.BotCommandScopeDefault`.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code or an empty
|
|
|
|
string.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
Returns:
|
2022-12-15 15:00:36 +01:00
|
|
|
Tuple[:class:`telegram.BotCommand`]: On success, the commands set for the bot. An empty
|
|
|
|
tuple is returned if commands are not set.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"scope": scope, "language_code": language_code}
|
2020-04-10 19:22:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"getMyCommands",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return BotCommand.de_list(result, self)
|
2020-04-10 19:22:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def set_my_commands(
|
2020-10-06 19:28:40 +02:00
|
|
|
self,
|
2023-01-01 14:24:30 +01:00
|
|
|
commands: Sequence[Union[BotCommand, Tuple[str, str]]],
|
2023-05-18 07:57:59 +02:00
|
|
|
scope: Optional[BotCommandScope] = None,
|
|
|
|
language_code: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
) -> bool:
|
2020-04-10 19:22:45 +02:00
|
|
|
"""
|
2021-07-01 17:45:19 +02:00
|
|
|
Use this method to change the list of the bot's commands. See the
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
`Telegram docs <https://core.telegram.org/bots/features#commands>`_ for more details about
|
|
|
|
bot commands.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
2022-12-15 15:20:04 +01:00
|
|
|
.. seealso:: :meth:`get_my_commands`, :meth:`delete_my_commands`
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
Args:
|
2023-01-01 14:24:30 +01:00
|
|
|
commands (Sequence[:class:`BotCommand` | (:obj:`str`, :obj:`str`)]): A sequence
|
2022-11-22 11:07:42 +01:00
|
|
|
of bot commands to be set as the list of the bot's commands. At most
|
|
|
|
:tg-const:`telegram.constants.BotCommandLimit.MAX_COMMAND_NUMBER` commands can be
|
|
|
|
specified.
|
2023-01-01 14:24:30 +01:00
|
|
|
|
2023-03-25 12:48:34 +01:00
|
|
|
Note:
|
|
|
|
If you pass in a sequence of :obj:`tuple`, the order of elements in each
|
|
|
|
:obj:`tuple` must correspond to the order of positional arguments to create a
|
|
|
|
:class:`BotCommand` instance.
|
|
|
|
|
2023-01-01 14:24:30 +01:00
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2022-05-18 17:18:44 +02:00
|
|
|
scope (:class:`telegram.BotCommandScope`, optional): An object,
|
|
|
|
describing scope of users for which the commands are relevant. Defaults to
|
|
|
|
:class:`telegram.BotCommandScopeDefault`.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code. If empty,
|
|
|
|
commands will be applied to all users from the given scope, for whose language
|
|
|
|
there are no dedicated commands.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
Returns:
|
2021-07-01 17:45:19 +02:00
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
cmds = [c if isinstance(c, BotCommand) else BotCommand(c[0], c[1]) for c in commands]
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"commands": cmds, "scope": scope, "language_code": language_code}
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"setMyCommands",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2020-04-10 19:22:45 +02:00
|
|
|
|
2022-07-04 19:33:45 +02:00
|
|
|
async def delete_my_commands(
|
2021-07-01 17:45:19 +02:00
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
scope: Optional[BotCommandScope] = None,
|
|
|
|
language_code: Optional[str] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-07-01 17:45:19 +02:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to delete the list of the bot's commands for the given scope and user
|
|
|
|
language. After deletion,
|
|
|
|
`higher level commands <https://core.telegram.org/bots/api#determining-list-of-commands>`_
|
|
|
|
will be shown to affected users.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
2022-12-15 15:20:04 +01:00
|
|
|
.. seealso:: :meth:`get_my_commands`, :meth:`set_my_commands`
|
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
Args:
|
2022-01-03 09:09:03 +01:00
|
|
|
scope (:class:`telegram.BotCommandScope`, optional): An object,
|
2021-07-01 17:45:19 +02:00
|
|
|
describing scope of users for which the commands are relevant. Defaults to
|
|
|
|
:class:`telegram.BotCommandScopeDefault`.
|
|
|
|
language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code. If empty,
|
|
|
|
commands will be applied to all users from the given scope, for whose language
|
|
|
|
there are no dedicated commands.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"scope": scope, "language_code": language_code}
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2023-03-25 19:18:04 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"deleteMyCommands",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def log_out(
|
|
|
|
self,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
) -> bool:
|
2020-11-29 16:20:46 +01:00
|
|
|
"""
|
|
|
|
Use this method to log out from the cloud Bot API server before launching the bot locally.
|
|
|
|
You *must* log out the bot before running it locally, otherwise there is no guarantee that
|
|
|
|
the bot will receive updates. After a successful call, you can immediately log in on a
|
|
|
|
local server, but will not be able to log in back to the cloud Bot API server for 10
|
|
|
|
minutes.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`True`: On success
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2020-11-29 16:20:46 +01:00
|
|
|
|
|
|
|
"""
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"logOut",
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2022-07-10 15:37:12 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2022-04-24 12:38:09 +02:00
|
|
|
)
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def close(
|
|
|
|
self,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
) -> bool:
|
2020-11-29 16:20:46 +01:00
|
|
|
"""
|
|
|
|
Use this method to close the bot instance before moving it from one local server to
|
|
|
|
another. You need to delete the webhook before calling this method to ensure that the bot
|
|
|
|
isn't launched again after server restart. The method will return error 429 in the first
|
|
|
|
10 minutes after the bot is launched.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`True`: On success
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2020-11-29 16:20:46 +01:00
|
|
|
|
|
|
|
"""
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-04-24 12:38:09 +02:00
|
|
|
"close",
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
2022-05-18 17:18:44 +02:00
|
|
|
api_kwargs=api_kwargs,
|
2022-04-24 12:38:09 +02:00
|
|
|
)
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def copy_message(
|
2020-11-29 16:20:46 +01:00
|
|
|
self,
|
|
|
|
chat_id: Union[int, str],
|
|
|
|
from_chat_id: Union[str, int],
|
2021-03-14 16:42:03 +01:00
|
|
|
message_id: int,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption: Optional[str] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
2023-10-25 21:53:43 +02:00
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
reply_markup: Optional[ReplyMarkup] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
message_thread_id: Optional[int] = None,
|
2024-02-08 17:12:00 +01:00
|
|
|
reply_parameters: Optional["ReplyParameters"] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2024-02-25 10:34:47 +01:00
|
|
|
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
reply_to_message_id: Optional[int] = None,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2020-12-30 13:41:07 +01:00
|
|
|
) -> MessageId:
|
2024-02-08 17:12:00 +01:00
|
|
|
"""Use this method to copy messages of any kind. Service messages and invoice messages
|
|
|
|
can't be copied. The method is analogous to the method :meth:`forward_message`, but the
|
|
|
|
copied message doesn't have a link to the original message.
|
2020-11-29 16:20:46 +01:00
|
|
|
|
|
|
|
Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
2020-11-29 16:20:46 +01:00
|
|
|
from_chat_id (:obj:`int` | :obj:`str`): Unique identifier for the chat where the
|
2021-04-30 10:47:41 +02:00
|
|
|
original message was sent (or channel username in the format ``@channelusername``).
|
2020-11-29 16:20:46 +01:00
|
|
|
message_id (:obj:`int`): Message identifier in the chat specified in from_chat_id.
|
2021-10-19 18:28:19 +02:00
|
|
|
caption (:obj:`str`, optional): New caption for media,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after
|
2020-11-29 16:20:46 +01:00
|
|
|
entities parsing. If not specified, the original caption is kept.
|
|
|
|
parse_mode (:obj:`str`, optional): Mode for parsing entities in the new caption. See
|
2021-10-19 18:28:19 +02:00
|
|
|
the constants in :class:`telegram.constants.ParseMode` for the available modes.
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|
|
|
|
|caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
2022-01-03 08:13:33 +01:00
|
|
|
|
|
|
|
.. versionadded:: 13.10
|
2022-11-22 10:43:50 +01:00
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
|
|
|
|
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
|
|
|
|
Additional interface options. An object for an inline keyboard, custom reply
|
|
|
|
keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
|
|
|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
Keyword Args:
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
2024-02-25 10:34:47 +01:00
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionchanged:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-08 17:12:00 +01:00
|
|
|
|keyword_only_arg|
|
2024-02-25 10:34:47 +01:00
|
|
|
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
|
|
|
|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
|
|
|
|
parameter for
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-02-25 10:34:47 +01:00
|
|
|
.. versionchanged:: 20.8
|
|
|
|
Bot API 7.0 introduced :paramref:`reply_parameters` |rtm_aswr_deprecated|
|
2024-02-08 17:12:00 +01:00
|
|
|
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-02-25 10:34:47 +01:00
|
|
|
|keyword_only_arg|
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2020-11-29 16:20:46 +01:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.MessageId`: On success
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2020-11-29 16:20:46 +01:00
|
|
|
"""
|
2024-02-08 17:12:00 +01:00
|
|
|
if allow_sending_without_reply is not DEFAULT_NONE and reply_parameters is not None:
|
|
|
|
raise ValueError(
|
|
|
|
"`allow_sending_without_reply` and `reply_parameters` are mutually exclusive."
|
|
|
|
)
|
|
|
|
|
|
|
|
if reply_to_message_id is not None and reply_parameters is not None:
|
|
|
|
raise ValueError(
|
|
|
|
"`reply_to_message_id` and `reply_parameters` are mutually exclusive."
|
|
|
|
)
|
|
|
|
|
|
|
|
if reply_to_message_id is not None:
|
|
|
|
reply_parameters = ReplyParameters(
|
|
|
|
message_id=reply_to_message_id,
|
|
|
|
allow_sending_without_reply=allow_sending_without_reply,
|
|
|
|
)
|
|
|
|
|
2020-11-29 16:20:46 +01:00
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"from_chat_id": from_chat_id,
|
|
|
|
"message_id": message_id,
|
2021-02-19 19:07:48 +01:00
|
|
|
"parse_mode": parse_mode,
|
|
|
|
"disable_notification": disable_notification,
|
2022-01-07 17:02:23 +01:00
|
|
|
"protect_content": protect_content,
|
2022-12-01 19:26:01 +01:00
|
|
|
"caption": caption,
|
|
|
|
"caption_entities": caption_entities,
|
|
|
|
"reply_markup": reply_markup,
|
|
|
|
"message_thread_id": message_thread_id,
|
2024-02-08 17:12:00 +01:00
|
|
|
"reply_parameters": reply_parameters,
|
2020-11-29 16:20:46 +01:00
|
|
|
}
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
result = await self._post(
|
|
|
|
"copyMessage",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return MessageId.de_json(result, self) # type: ignore[return-value]
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2024-02-08 17:12:00 +01:00
|
|
|
async def copy_messages(
|
|
|
|
self,
|
|
|
|
chat_id: Union[int, str],
|
|
|
|
from_chat_id: Union[str, int],
|
|
|
|
message_ids: Sequence[int],
|
|
|
|
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
|
|
|
message_thread_id: Optional[int] = None,
|
|
|
|
remove_caption: Optional[bool] = None,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
|
|
|
) -> Tuple["MessageId", ...]:
|
|
|
|
"""
|
|
|
|
Use this method to copy messages of any kind. If some of the specified messages can't be
|
|
|
|
found or copied, they are skipped. Service messages, giveaway messages, giveaway winners
|
|
|
|
messages, and invoice messages can't be copied. A quiz poll can be copied only if the value
|
|
|
|
of the field correct_option_id is known to the bot. The method is analogous to the method
|
|
|
|
:meth:`forward_messages`, but the copied messages don't have a link to the original
|
|
|
|
message. Album grouping is kept for copied messages.
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
|
|
|
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``).
|
2024-03-06 14:45:50 +01:00
|
|
|
message_ids (Sequence[:obj:`int`]): A list of
|
2024-02-08 17:12:00 +01:00
|
|
|
:tg-const:`telegram.constants.BulkRequestLimit.MIN_LIMIT` -
|
2024-03-06 14:45:50 +01:00
|
|
|
:tg-const:`telegram.constants.BulkRequestLimit.MAX_LIMIT` identifiers of messages
|
|
|
|
in the chat :paramref:`from_chat_id` to copy. The identifiers must be
|
|
|
|
specified in a strictly increasing order.
|
2024-02-08 17:12:00 +01:00
|
|
|
disable_notification (:obj:`bool`, optional): |disable_notification|
|
|
|
|
protect_content (:obj:`bool`, optional): |protect_content|
|
|
|
|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
|
|
|
|
remove_caption (:obj:`bool`, optional): Pass :obj:`True` to copy the messages without
|
|
|
|
their captions.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Tuple[:class:`telegram.MessageId`]: On success, a tuple of :class:`~telegram.MessageId`
|
|
|
|
of the sent messages is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"from_chat_id": from_chat_id,
|
|
|
|
"message_ids": message_ids,
|
|
|
|
"disable_notification": disable_notification,
|
|
|
|
"protect_content": protect_content,
|
|
|
|
"message_thread_id": message_thread_id,
|
|
|
|
"remove_caption": remove_caption,
|
|
|
|
}
|
|
|
|
|
|
|
|
result = await self._post(
|
|
|
|
"copyMessages",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
return MessageId.de_list(result, self)
|
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
async def set_chat_menu_button(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
chat_id: Optional[int] = None,
|
|
|
|
menu_button: Optional[MenuButton] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-05-03 18:21:50 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-05-03 18:21:50 +02:00
|
|
|
) -> bool:
|
|
|
|
"""Use this method to change the bot's menu button in a private chat, or the default menu
|
|
|
|
button.
|
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :meth:`get_chat_menu_button`, :meth:`telegram.Chat.get_menu_button`
|
2022-08-27 11:46:51 +02:00
|
|
|
:meth:`telegram.User.get_menu_button`
|
2022-05-03 18:21:50 +02:00
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int`, optional): Unique identifier for the target private chat. If not
|
|
|
|
specified, default bot's menu button will be changed
|
|
|
|
menu_button (:class:`telegram.MenuButton`, optional): An object for the new bot's menu
|
|
|
|
button. Defaults to :class:`telegram.MenuButtonDefault`.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data: JSONDict = {"chat_id": chat_id, "menu_button": menu_button}
|
2022-05-03 18:21:50 +02:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-05-03 18:21:50 +02:00
|
|
|
"setChatMenuButton",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def get_chat_menu_button(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
chat_id: Optional[int] = None,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-05-03 18:21:50 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-05-03 18:21:50 +02:00
|
|
|
) -> MenuButton:
|
|
|
|
"""Use this method to get the current value of the bot's menu button in a private chat, or
|
|
|
|
the default menu button.
|
|
|
|
|
2023-02-05 18:09:55 +01:00
|
|
|
.. seealso:: :meth:`set_chat_menu_button`, :meth:`telegram.Chat.set_menu_button`,
|
2022-08-27 11:46:51 +02:00
|
|
|
:meth:`telegram.User.set_menu_button`
|
2022-05-03 18:21:50 +02:00
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int`, optional): Unique identifier for the target private chat. If not
|
|
|
|
specified, default bot's menu button will be returned.
|
2022-05-18 17:18:44 +02:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
Returns:
|
|
|
|
:class:`telegram.MenuButton`: On success, the current menu button is returned.
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2022-05-03 18:21:50 +02:00
|
|
|
"""
|
2022-12-01 19:26:01 +01:00
|
|
|
data = {"chat_id": chat_id}
|
2022-05-03 18:21:50 +02:00
|
|
|
|
|
|
|
result = await self._post(
|
|
|
|
"getChatMenuButton",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return MenuButton.de_json(result, bot=self) # type: ignore[return-value]
|
2022-05-03 18:21:50 +02:00
|
|
|
|
2022-06-27 18:54:11 +02:00
|
|
|
async def create_invoice_link(
|
|
|
|
self,
|
|
|
|
title: str,
|
|
|
|
description: str,
|
|
|
|
payload: str,
|
|
|
|
provider_token: str,
|
|
|
|
currency: str,
|
2023-01-01 14:24:30 +01:00
|
|
|
prices: Sequence["LabeledPrice"],
|
2023-05-18 07:57:59 +02:00
|
|
|
max_tip_amount: Optional[int] = None,
|
|
|
|
suggested_tip_amounts: Optional[Sequence[int]] = None,
|
|
|
|
provider_data: Optional[Union[str, object]] = None,
|
|
|
|
photo_url: Optional[str] = None,
|
|
|
|
photo_size: Optional[int] = None,
|
|
|
|
photo_width: Optional[int] = None,
|
|
|
|
photo_height: Optional[int] = None,
|
|
|
|
need_name: Optional[bool] = None,
|
|
|
|
need_phone_number: Optional[bool] = None,
|
|
|
|
need_email: Optional[bool] = None,
|
|
|
|
need_shipping_address: Optional[bool] = None,
|
|
|
|
send_phone_number_to_provider: Optional[bool] = None,
|
|
|
|
send_email_to_provider: Optional[bool] = None,
|
|
|
|
is_flexible: Optional[bool] = None,
|
2022-06-27 18:54:11 +02:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-06-27 18:54:11 +02:00
|
|
|
) -> str:
|
|
|
|
"""Use this method to create a link for an invoice.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
title (:obj:`str`): Product name. :tg-const:`telegram.Invoice.MIN_TITLE_LENGTH`-
|
|
|
|
:tg-const:`telegram.Invoice.MAX_TITLE_LENGTH` characters.
|
|
|
|
description (:obj:`str`): Product description.
|
|
|
|
:tg-const:`telegram.Invoice.MIN_DESCRIPTION_LENGTH`-
|
|
|
|
:tg-const:`telegram.Invoice.MAX_DESCRIPTION_LENGTH` characters.
|
|
|
|
payload (:obj:`str`): Bot-defined invoice payload.
|
|
|
|
:tg-const:`telegram.Invoice.MIN_PAYLOAD_LENGTH`-
|
|
|
|
:tg-const:`telegram.Invoice.MAX_PAYLOAD_LENGTH` bytes. This will not be
|
|
|
|
displayed to the user, use for your internal processes.
|
|
|
|
provider_token (:obj:`str`): Payments provider token, obtained via
|
|
|
|
`@BotFather <https://t.me/BotFather>`_.
|
|
|
|
currency (:obj:`str`): Three-letter ISO 4217 currency code, see `more on currencies
|
|
|
|
<https://core.telegram.org/bots/payments#supported-currencies>`_.
|
2023-01-01 14:24:30 +01:00
|
|
|
prices (Sequence[:class:`telegram.LabeledPrice`)]: Price breakdown, a sequence
|
2022-06-27 18:54:11 +02:00
|
|
|
of components (e.g. product price, tax, discount, delivery cost, delivery tax,
|
|
|
|
bonus, etc.).
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2022-06-27 18:54:11 +02:00
|
|
|
max_tip_amount (:obj:`int`, optional): The maximum accepted amount for tips in the
|
|
|
|
*smallest* units of the currency (integer, **not** float/double). For example, for
|
|
|
|
a maximum tip of US$ 1.45 pass ``max_tip_amount = 145``. See the exp parameter in
|
|
|
|
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
|
|
|
|
shows the number of digits past the decimal point for each currency (2 for the
|
|
|
|
majority of currencies). Defaults to ``0``.
|
2023-01-01 14:24:30 +01:00
|
|
|
suggested_tip_amounts (Sequence[:obj:`int`], optional): An array of
|
2022-06-27 18:54:11 +02:00
|
|
|
suggested amounts of tips in the *smallest* units of the currency (integer, **not**
|
2022-12-30 14:09:06 +01:00
|
|
|
float/double). At most :tg-const:`telegram.Invoice.MAX_TIP_AMOUNTS` suggested tip
|
|
|
|
amounts can be specified. The suggested tip amounts must be positive, passed in a
|
|
|
|
strictly increased order and must not exceed :paramref:`max_tip_amount`.
|
2023-01-01 14:24:30 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceargs|
|
2022-06-27 18:54:11 +02:00
|
|
|
provider_data (:obj:`str` | :obj:`object`, optional): Data about the
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
photo_size (:obj:`int`, optional): Photo size in bytes.
|
|
|
|
photo_width (:obj:`int`, optional): Photo width.
|
|
|
|
photo_height (:obj:`int`, optional): Photo height.
|
|
|
|
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
|
|
|
|
phone number to complete the order.
|
|
|
|
need_email (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's email
|
|
|
|
address 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.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`str`: On success, the created invoice link is returned.
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"title": title,
|
|
|
|
"description": description,
|
|
|
|
"payload": payload,
|
|
|
|
"provider_token": provider_token,
|
|
|
|
"currency": currency,
|
|
|
|
"prices": prices,
|
2022-12-01 19:26:01 +01:00
|
|
|
"max_tip_amount": max_tip_amount,
|
|
|
|
"suggested_tip_amounts": suggested_tip_amounts,
|
|
|
|
"provider_data": provider_data,
|
|
|
|
"photo_url": photo_url,
|
|
|
|
"photo_size": photo_size,
|
|
|
|
"photo_width": photo_width,
|
|
|
|
"photo_height": photo_height,
|
|
|
|
"need_name": need_name,
|
|
|
|
"need_phone_number": need_phone_number,
|
|
|
|
"need_email": need_email,
|
|
|
|
"need_shipping_address": need_shipping_address,
|
|
|
|
"is_flexible": is_flexible,
|
|
|
|
"send_phone_number_to_provider": send_phone_number_to_provider,
|
|
|
|
"send_email_to_provider": send_email_to_provider,
|
2022-06-27 18:54:11 +02:00
|
|
|
}
|
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-06-27 18:54:11 +02:00
|
|
|
"createInvoiceLink",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2022-11-22 10:43:50 +01:00
|
|
|
async def get_forum_topic_icon_stickers(
|
|
|
|
self,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-12-15 15:00:36 +01:00
|
|
|
) -> Tuple[Sticker, ...]:
|
2022-11-22 10:43:50 +01:00
|
|
|
"""Use this method to get custom emoji stickers, which can be used as a forum topic
|
2023-02-05 18:09:55 +01:00
|
|
|
icon by any user. Requires no parameters.
|
2022-11-22 10:43:50 +01:00
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Returns:
|
2022-12-15 15:00:36 +01:00
|
|
|
Tuple[:class:`telegram.Sticker`]
|
2022-11-22 10:43:50 +01:00
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
result = await self._post(
|
|
|
|
"getForumTopicIconStickers",
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return Sticker.de_list(result, self)
|
2022-11-22 10:43:50 +01:00
|
|
|
|
|
|
|
async def create_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
name: str,
|
2023-05-18 07:57:59 +02:00
|
|
|
icon_color: Optional[int] = None,
|
|
|
|
icon_custom_emoji_id: Optional[str] = None,
|
2022-11-22 10:43:50 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-11-22 10:43:50 +01:00
|
|
|
) -> ForumTopic:
|
|
|
|
"""
|
|
|
|
Use this method to create a topic in a forum supergroup chat. The bot must be
|
|
|
|
an administrator in the chat for this to work and must have
|
|
|
|
:paramref:`~telegram.ChatAdministratorRights.can_manage_topics` administrator rights.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
name (:obj:`str`): New topic name,
|
|
|
|
:tg-const:`telegram.constants.ForumTopicLimit.MIN_NAME_LENGTH`-
|
|
|
|
:tg-const:`telegram.constants.ForumTopicLimit.MAX_NAME_LENGTH` characters.
|
|
|
|
icon_color (:obj:`int`, optional): Color of the topic icon in RGB format. Currently,
|
|
|
|
must be one of :attr:`telegram.constants.ForumIconColor.BLUE`,
|
|
|
|
:attr:`telegram.constants.ForumIconColor.YELLOW`,
|
|
|
|
:attr:`telegram.constants.ForumIconColor.PURPLE`,
|
|
|
|
:attr:`telegram.constants.ForumIconColor.GREEN`,
|
|
|
|
:attr:`telegram.constants.ForumIconColor.PINK`, or
|
|
|
|
:attr:`telegram.constants.ForumIconColor.RED`.
|
|
|
|
icon_custom_emoji_id (:obj:`str`, optional): New unique identifier of the custom emoji
|
|
|
|
shown as the topic icon. Use :meth:`~telegram.Bot.get_forum_topic_icon_stickers`
|
|
|
|
to get all allowed custom emoji identifiers.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`telegram.ForumTopic`
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"name": name,
|
|
|
|
"icon_color": icon_color,
|
|
|
|
"icon_custom_emoji_id": icon_custom_emoji_id,
|
|
|
|
}
|
|
|
|
result = await self._post(
|
|
|
|
"createForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
return ForumTopic.de_json(result, self) # type: ignore[return-value]
|
2022-11-22 10:43:50 +01:00
|
|
|
|
|
|
|
async def edit_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
message_thread_id: int,
|
2023-05-18 07:57:59 +02:00
|
|
|
name: Optional[str] = None,
|
|
|
|
icon_custom_emoji_id: Optional[str] = None,
|
2022-11-22 10:43:50 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-11-22 10:43:50 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must
|
|
|
|
be an administrator in the chat for this to work and must have
|
|
|
|
:paramref:`~telegram.ChatAdministratorRights.can_manage_topics` administrator rights,
|
|
|
|
unless it is the creator of the topic.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
message_thread_id (:obj:`int`): |message_thread_id|
|
2023-01-01 17:00:49 +01:00
|
|
|
name (:obj:`str`, optional): New topic name,
|
2022-11-22 10:43:50 +01:00
|
|
|
:tg-const:`telegram.constants.ForumTopicLimit.MIN_NAME_LENGTH`-
|
2023-01-01 17:00:49 +01:00
|
|
|
:tg-const:`telegram.constants.ForumTopicLimit.MAX_NAME_LENGTH` characters. If
|
|
|
|
not specified or empty, the current name of the topic will be kept.
|
|
|
|
icon_custom_emoji_id (:obj:`str`, optional): New unique identifier of the custom emoji
|
|
|
|
shown as the topic icon. Use :meth:`~telegram.Bot.get_forum_topic_icon_stickers`
|
|
|
|
to get all allowed custom emoji identifiers.Pass an empty string to remove the
|
|
|
|
icon. If not specified, the current icon will be kept.
|
2022-11-22 10:43:50 +01:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_thread_id": message_thread_id,
|
|
|
|
"name": name,
|
|
|
|
"icon_custom_emoji_id": icon_custom_emoji_id,
|
|
|
|
}
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-11-22 10:43:50 +01:00
|
|
|
"editForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def close_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
message_thread_id: int,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-11-22 10:43:50 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to close an open topic in a forum supergroup chat. The bot must
|
|
|
|
be an administrator in the chat for this to work and must have
|
|
|
|
:paramref:`~telegram.ChatAdministratorRights.can_manage_topics` administrator rights,
|
|
|
|
unless it is the creator of the topic.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
message_thread_id (:obj:`int`): |message_thread_id|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_thread_id": message_thread_id,
|
|
|
|
}
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-11-22 10:43:50 +01:00
|
|
|
"closeForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def reopen_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
message_thread_id: int,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-11-22 10:43:50 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to reopen a closed topic in a forum supergroup chat. The bot must
|
|
|
|
be an administrator in the chat for this to work and must have
|
|
|
|
:paramref:`~telegram.ChatAdministratorRights.can_manage_topics` administrator rights,
|
|
|
|
unless it is the creator of the topic.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
message_thread_id (:obj:`int`): |message_thread_id|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_thread_id": message_thread_id,
|
|
|
|
}
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-11-22 10:43:50 +01:00
|
|
|
"reopenForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def delete_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
message_thread_id: int,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-11-22 10:43:50 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to delete a forum topic along with all its messages in a forum supergroup
|
|
|
|
chat. The bot must be an administrator in the chat for this to work and must have
|
|
|
|
:paramref:`~telegram.ChatAdministratorRights.can_delete_messages` administrator rights.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
message_thread_id (:obj:`int`): |message_thread_id|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_thread_id": message_thread_id,
|
|
|
|
}
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-11-22 10:43:50 +01:00
|
|
|
"deleteForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def unpin_all_forum_topic_messages(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
message_thread_id: int,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-11-22 10:43:50 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to clear the list of pinned messages in a forum topic. The bot must
|
|
|
|
be an administrator in the chat for this to work and must have
|
|
|
|
:paramref:`~telegram.ChatAdministratorRights.can_pin_messages` administrator rights
|
|
|
|
in the supergroup.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
message_thread_id (:obj:`int`): |message_thread_id|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_thread_id": message_thread_id,
|
|
|
|
}
|
2022-12-15 15:00:36 +01:00
|
|
|
return await self._post(
|
2022-11-22 10:43:50 +01:00
|
|
|
"unpinAllForumTopicMessages",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2023-09-03 13:43:44 +02:00
|
|
|
async def unpin_all_general_forum_topic_messages(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to clear the list of pinned messages in a General forum topic. The bot must
|
|
|
|
be an administrator in the chat for this to work and must have
|
|
|
|
:paramref:`~telegram.ChatAdministratorRights.can_pin_messages` administrator rights in the
|
|
|
|
supergroup.
|
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionadded:: 20.5
|
2023-09-03 13:43:44 +02:00
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"unpinAllGeneralForumTopicMessages",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
async def edit_general_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
name: str,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-01-01 17:00:49 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot
|
|
|
|
must be an administrator in the chat for this to work and must have
|
|
|
|
:attr:`~telegram.ChatAdministratorRights.can_manage_topics` administrator rights.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
name (:obj:`str`): New topic name,
|
|
|
|
:tg-const:`telegram.constants.ForumTopicLimit.MIN_NAME_LENGTH`-
|
|
|
|
:tg-const:`telegram.constants.ForumTopicLimit.MAX_NAME_LENGTH` characters.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id, "name": name}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"editGeneralForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def close_general_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-01-01 17:00:49 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to close an open 'General' topic in a forum supergroup chat. The bot must
|
|
|
|
be an administrator in the chat for this to work and must have
|
|
|
|
:attr:`~telegram.ChatAdministratorRights.can_manage_topics` administrator rights.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"closeGeneralForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def reopen_general_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-01-01 17:00:49 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must
|
|
|
|
be an administrator in the chat for this to work and must have
|
|
|
|
:attr:`~telegram.ChatAdministratorRights.can_manage_topics` administrator rights.
|
|
|
|
The topic will be automatically unhidden if it was hidden.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"reopenGeneralForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def hide_general_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-01-01 17:00:49 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to hide the 'General' topic in a forum supergroup chat. The bot must
|
|
|
|
be an administrator in the chat for this to work and must have
|
|
|
|
:attr:`~telegram.ChatAdministratorRights.can_manage_topics` administrator rights.
|
|
|
|
The topic will be automatically closed if it was open.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"hideGeneralForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def unhide_general_forum_topic(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-01-01 17:00:49 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must
|
|
|
|
be an administrator in the chat for this to work and must have
|
|
|
|
:attr:`~telegram.ChatAdministratorRights.can_manage_topics` administrator rights.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"unhideGeneralForumTopic",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2023-03-25 11:47:26 +01:00
|
|
|
async def set_my_description(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
description: Optional[str] = None,
|
|
|
|
language_code: Optional[str] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to change the bot's description, which is shown in the chat with the bot
|
|
|
|
if the chat is empty.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
description (:obj:`str`, optional): New bot description;
|
|
|
|
0-:tg-const:`telegram.constants.BotDescriptionLimit.MAX_DESCRIPTION_LENGTH`
|
|
|
|
characters. Pass an empty string to remove the dedicated description for the given
|
|
|
|
language.
|
|
|
|
language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code. If empty,
|
|
|
|
the description will be applied to all users for whose language there is no
|
|
|
|
dedicated description.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"description": description, "language_code": language_code}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"setMyDescription",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def set_my_short_description(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
short_description: Optional[str] = None,
|
|
|
|
language_code: Optional[str] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to change the bot's short description, which is shown on the bot's profile
|
|
|
|
page and is sent together with the link when users share the bot.
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
short_description (:obj:`str`, optional): New short description for the bot;
|
|
|
|
0-:tg-const:`telegram.constants.BotDescriptionLimit.MAX_SHORT_DESCRIPTION_LENGTH`
|
|
|
|
characters. Pass an empty string to remove the dedicated description for the given
|
|
|
|
language.
|
|
|
|
language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code. If empty,
|
|
|
|
the description will be applied to all users for whose language there is no
|
|
|
|
dedicated description.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"short_description": short_description, "language_code": language_code}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"setMyShortDescription",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def get_my_description(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
language_code: Optional[str] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> BotDescription:
|
|
|
|
"""
|
|
|
|
Use this method to get the current bot description for the given user language.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code or an empty
|
|
|
|
string.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`telegram.BotDescription`: On success, the bot description is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data = {"language_code": language_code}
|
|
|
|
return BotDescription.de_json( # type: ignore[return-value]
|
|
|
|
await self._post(
|
|
|
|
"getMyDescription",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
),
|
|
|
|
bot=self,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def get_my_short_description(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
language_code: Optional[str] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-03-25 11:47:26 +01:00
|
|
|
) -> BotShortDescription:
|
|
|
|
"""
|
|
|
|
Use this method to get the current bot short description for the given user language.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code or an empty
|
|
|
|
string.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`telegram.BotShortDescription`: On success, the bot short description is
|
|
|
|
returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data = {"language_code": language_code}
|
|
|
|
return BotShortDescription.de_json( # type: ignore[return-value]
|
|
|
|
await self._post(
|
|
|
|
"getMyShortDescription",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
),
|
|
|
|
bot=self,
|
|
|
|
)
|
|
|
|
|
2023-05-07 13:44:34 +02:00
|
|
|
async def set_my_name(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
name: Optional[str] = None,
|
|
|
|
language_code: Optional[str] = None,
|
2023-05-07 13:44:34 +02:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-05-07 13:44:34 +02:00
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to change the bot's name.
|
|
|
|
|
2023-05-07 15:31:23 +02:00
|
|
|
.. versionadded:: 20.3
|
2023-05-07 13:44:34 +02:00
|
|
|
|
|
|
|
Args:
|
|
|
|
name (:obj:`str`, optional): New bot name;
|
|
|
|
0-:tg-const:`telegram.constants.BotNameLimit.MAX_NAME_LENGTH`
|
|
|
|
characters. Pass an empty string to remove the dedicated name for the given
|
|
|
|
language.
|
|
|
|
|
|
|
|
Caution:
|
|
|
|
If :paramref:`language_code` is not specified, a :paramref:`name` *must*
|
|
|
|
be specified.
|
|
|
|
language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code. If empty,
|
|
|
|
the name will be applied to all users for whose language there is no
|
|
|
|
dedicated name.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"name": name, "language_code": language_code}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"setMyName",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def get_my_name(
|
|
|
|
self,
|
2023-05-18 07:57:59 +02:00
|
|
|
language_code: Optional[str] = None,
|
2023-05-07 13:44:34 +02:00
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-05-07 13:44:34 +02:00
|
|
|
) -> BotName:
|
|
|
|
"""
|
|
|
|
Use this method to get the current bot name for the given user language.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code or an empty
|
|
|
|
string.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`telegram.BotName`: On success, the bot name is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
|
|
|
|
"""
|
|
|
|
data = {"language_code": language_code}
|
|
|
|
return BotName.de_json( # type: ignore[return-value]
|
|
|
|
await self._post(
|
|
|
|
"getMyName",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
),
|
|
|
|
bot=self,
|
|
|
|
)
|
|
|
|
|
2024-02-08 17:12:00 +01:00
|
|
|
async def get_user_chat_boosts(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
user_id: int,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
|
|
|
) -> UserChatBoosts:
|
|
|
|
"""
|
|
|
|
Use this method to get the list of boosts added to a chat by a user. Requires
|
|
|
|
administrator rights in the chat.
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`telegram.UserChatBoosts`: On success, the object containing the list of boosts
|
|
|
|
is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"chat_id": chat_id, "user_id": user_id}
|
|
|
|
return UserChatBoosts.de_json( # type: ignore[return-value]
|
|
|
|
await self._post(
|
|
|
|
"getUserChatBoosts",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
),
|
|
|
|
bot=self,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def set_message_reaction(
|
|
|
|
self,
|
|
|
|
chat_id: Union[str, int],
|
|
|
|
message_id: int,
|
|
|
|
reaction: Optional[Union[Sequence[Union[ReactionType, str]], ReactionType, str]] = None,
|
|
|
|
is_big: Optional[bool] = None,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Use this method to change the chosen reactions on a message. Service messages can't be
|
|
|
|
reacted to. Automatically forwarded messages from a channel to its discussion group have
|
|
|
|
the same available reactions as messages in the channel.
|
|
|
|
|
2024-02-08 18:36:28 +01:00
|
|
|
.. versionadded:: 20.8
|
2024-02-08 17:12:00 +01:00
|
|
|
|
|
|
|
Args:
|
|
|
|
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
|
|
|
message_id (:obj:`int`): Identifier of the target message. If the message belongs to a
|
|
|
|
media group, the reaction is set to the first non-deleted message in the group
|
|
|
|
instead.
|
|
|
|
reaction (Sequence[:class:`telegram.ReactionType` | :obj:`str`] | \
|
2024-03-06 14:45:50 +01:00
|
|
|
:class:`telegram.ReactionType` | :obj:`str`, optional): A list of reaction
|
2024-02-08 17:12:00 +01:00
|
|
|
types to set on the message. Currently, as non-premium users, bots can set up to
|
|
|
|
one reaction per message. A custom emoji reaction can be used if it is either
|
|
|
|
already present on the message or explicitly allowed by chat administrators.
|
|
|
|
|
|
|
|
Tip:
|
|
|
|
Passed :obj:`str` values will be converted to either
|
|
|
|
:class:`telegram.ReactionTypeEmoji` or
|
|
|
|
:class:`telegram.ReactionTypeCustomEmoji`
|
|
|
|
depending on whether they are listed in
|
|
|
|
:class:`~telegram.constants.ReactionEmoji`.
|
|
|
|
|
|
|
|
is_big (:obj:`bool`, optional): Pass :obj:`True` to set the reaction with a big
|
|
|
|
animation.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool` On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
allowed_reactions: Set[str] = set(ReactionEmoji)
|
|
|
|
parsed_reaction = (
|
|
|
|
[
|
|
|
|
(
|
|
|
|
entry
|
|
|
|
if isinstance(entry, ReactionType)
|
|
|
|
else (
|
|
|
|
ReactionTypeEmoji(emoji=entry)
|
|
|
|
if entry in allowed_reactions
|
|
|
|
else ReactionTypeCustomEmoji(custom_emoji_id=entry)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
for entry in (
|
|
|
|
[reaction] if isinstance(reaction, (ReactionType, str)) else reaction
|
|
|
|
)
|
|
|
|
]
|
|
|
|
if reaction is not None
|
|
|
|
else None
|
|
|
|
)
|
|
|
|
|
|
|
|
data: JSONDict = {
|
|
|
|
"chat_id": chat_id,
|
|
|
|
"message_id": message_id,
|
|
|
|
"reaction": parsed_reaction,
|
|
|
|
"is_big": is_big,
|
|
|
|
}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"setMessageReaction",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2024-04-12 11:58:25 +02:00
|
|
|
async def get_business_connection(
|
|
|
|
self,
|
|
|
|
business_connection_id: str,
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
|
|
|
) -> BusinessConnection:
|
|
|
|
"""
|
|
|
|
Use this method to get information about the connection of the bot with a business account.
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-04-12 11:58:25 +02:00
|
|
|
|
|
|
|
Args:
|
|
|
|
business_connection_id (:obj:`str`): Unique identifier of the business connection.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`telegram.BusinessConnection`: On success, the object containing the business
|
|
|
|
connection information is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {"business_connection_id": business_connection_id}
|
|
|
|
return BusinessConnection.de_json( # type: ignore[return-value]
|
|
|
|
await self._post(
|
|
|
|
"getBusinessConnection",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
),
|
|
|
|
bot=self,
|
|
|
|
)
|
|
|
|
|
|
|
|
async def replace_sticker_in_set(
|
|
|
|
self,
|
|
|
|
user_id: int,
|
|
|
|
name: str,
|
|
|
|
old_sticker: str,
|
|
|
|
sticker: "InputSticker",
|
|
|
|
*,
|
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
|
|
|
) -> bool:
|
|
|
|
"""Use this method to replace an existing sticker in a sticker set with a new one.
|
|
|
|
The method is equivalent to calling :meth:`delete_sticker_from_set`,
|
|
|
|
then :meth:`add_sticker_to_set`, then :meth:`set_sticker_position_in_set`.
|
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionadded:: 21.1
|
2024-04-12 11:58:25 +02:00
|
|
|
|
|
|
|
Args:
|
|
|
|
user_id (:obj:`int`): User identifier of the sticker set owner.
|
|
|
|
name (:obj:`str`): Sticker set name.
|
|
|
|
old_sticker (:obj:`str`): File identifier of the replaced sticker.
|
|
|
|
sticker (:obj:`telegram.InputSticker`): An object with information about the added
|
|
|
|
sticker. If exactly the same sticker had already been added to the set, then the
|
|
|
|
set remains unchanged.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
:obj:`bool`: On success, :obj:`True` is returned.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
:class:`telegram.error.TelegramError`
|
|
|
|
"""
|
|
|
|
data: JSONDict = {
|
|
|
|
"user_id": user_id,
|
|
|
|
"name": name,
|
|
|
|
"old_sticker": old_sticker,
|
|
|
|
"sticker": sticker,
|
|
|
|
}
|
|
|
|
|
|
|
|
return await self._post(
|
|
|
|
"replaceStickerInSet",
|
|
|
|
data,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
|
|
|
|
2024-02-07 20:45:57 +01:00
|
|
|
def to_dict(self, recursive: bool = True) -> JSONDict:
|
2021-05-27 09:38:17 +02:00
|
|
|
"""See :meth:`telegram.TelegramObject.to_dict`."""
|
2020-10-06 19:28:40 +02:00
|
|
|
data: JSONDict = {"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
|
|
|
|
2017-05-07 16:09:58 +02:00
|
|
|
# camelCase aliases
|
|
|
|
getMe = get_me
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_me`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendMessage = send_message
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_message`"""
|
2017-05-12 17:40:57 +02:00
|
|
|
deleteMessage = delete_message
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`delete_message`"""
|
2024-02-08 17:12:00 +01:00
|
|
|
deleteMessages = delete_messages
|
|
|
|
"""Alias for :meth:`delete_messages`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
forwardMessage = forward_message
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`forward_message`"""
|
2024-02-08 17:12:00 +01:00
|
|
|
forwardMessages = forward_messages
|
|
|
|
"""Alias for :meth:`forward_messages`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendPhoto = send_photo
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_photo`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendAudio = send_audio
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_audio`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendDocument = send_document
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_document`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendSticker = send_sticker
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_sticker`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendVideo = send_video
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`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
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_animation`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendVoice = send_voice
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_voice`"""
|
2017-05-20 19:35:55 +02:00
|
|
|
sendVideoNote = send_video_note
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_video_note`"""
|
2017-12-08 22:38:59 +01:00
|
|
|
sendMediaGroup = send_media_group
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_media_group`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendLocation = send_location
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_location`"""
|
2017-10-14 20:03:02 +02:00
|
|
|
editMessageLiveLocation = edit_message_live_location
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`edit_message_live_location`"""
|
2017-10-14 20:03:02 +02:00
|
|
|
stopMessageLiveLocation = stop_message_live_location
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`stop_message_live_location`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendVenue = send_venue
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_venue`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendContact = send_contact
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_contact`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendGame = send_game
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_game`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
sendChatAction = send_chat_action
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_chat_action`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
answerInlineQuery = answer_inline_query
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`answer_inline_query`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
getUserProfilePhotos = get_user_profile_photos
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_user_profile_photos`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
getFile = get_file
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_file`"""
|
2021-07-01 17:45:19 +02:00
|
|
|
banChatMember = ban_chat_member
|
|
|
|
"""Alias for :meth:`ban_chat_member`"""
|
2021-12-11 15:21:56 +01:00
|
|
|
banChatSenderChat = ban_chat_sender_chat
|
|
|
|
"""Alias for :meth:`ban_chat_sender_chat`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
unbanChatMember = unban_chat_member
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`unban_chat_member`"""
|
2021-12-11 15:21:56 +01:00
|
|
|
unbanChatSenderChat = unban_chat_sender_chat
|
|
|
|
"""Alias for :meth:`unban_chat_sender_chat`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
answerCallbackQuery = answer_callback_query
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`answer_callback_query`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
editMessageText = edit_message_text
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`edit_message_text`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
editMessageCaption = edit_message_caption
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`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
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`edit_message_media`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
editMessageReplyMarkup = edit_message_reply_markup
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`edit_message_reply_markup`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
getUpdates = get_updates
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_updates`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
setWebhook = set_webhook
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_webhook`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
deleteWebhook = delete_webhook
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`delete_webhook`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
leaveChat = leave_chat
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`leave_chat`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
getChat = get_chat
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_chat`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
getChatAdministrators = get_chat_administrators
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_chat_administrators`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
getChatMember = get_chat_member
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_chat_member`"""
|
2017-10-14 20:03:02 +02:00
|
|
|
setChatStickerSet = set_chat_sticker_set
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_chat_sticker_set`"""
|
2017-10-14 20:03:02 +02:00
|
|
|
deleteChatStickerSet = delete_chat_sticker_set
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`delete_chat_sticker_set`"""
|
2021-07-01 17:45:19 +02:00
|
|
|
getChatMemberCount = get_chat_member_count
|
|
|
|
"""Alias for :meth:`get_chat_member_count`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
getWebhookInfo = get_webhook_info
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_webhook_info`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
setGameScore = set_game_score
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_game_score`"""
|
2017-05-07 16:09:58 +02:00
|
|
|
getGameHighScores = get_game_high_scores
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_game_high_scores`"""
|
2017-05-19 19:46:42 +02:00
|
|
|
sendInvoice = send_invoice
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_invoice`"""
|
2017-05-19 19:46:42 +02:00
|
|
|
answerShippingQuery = answer_shipping_query
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`answer_shipping_query`"""
|
2017-05-19 19:46:42 +02:00
|
|
|
answerPreCheckoutQuery = answer_pre_checkout_query
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`answer_pre_checkout_query`"""
|
2022-05-03 18:21:50 +02:00
|
|
|
answerWebAppQuery = answer_web_app_query
|
|
|
|
"""Alias for :meth:`answer_web_app_query`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
restrictChatMember = restrict_chat_member
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`restrict_chat_member`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
promoteChatMember = promote_chat_member
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`promote_chat_member`"""
|
2019-09-06 21:41:43 +02:00
|
|
|
setChatPermissions = set_chat_permissions
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_chat_permissions`"""
|
2020-03-28 16:37:26 +01:00
|
|
|
setChatAdministratorCustomTitle = set_chat_administrator_custom_title
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_chat_administrator_custom_title`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
exportChatInviteLink = export_chat_invite_link
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`export_chat_invite_link`"""
|
2021-03-14 16:41:35 +01:00
|
|
|
createChatInviteLink = create_chat_invite_link
|
2021-11-08 19:02:20 +01:00
|
|
|
"""Alias for :meth:`create_chat_invite_link`"""
|
2021-03-14 16:41:35 +01:00
|
|
|
editChatInviteLink = edit_chat_invite_link
|
2021-11-08 19:02:20 +01:00
|
|
|
"""Alias for :meth:`edit_chat_invite_link`"""
|
2021-03-14 16:41:35 +01:00
|
|
|
revokeChatInviteLink = revoke_chat_invite_link
|
2021-11-08 19:02:20 +01:00
|
|
|
"""Alias for :meth:`revoke_chat_invite_link`"""
|
|
|
|
approveChatJoinRequest = approve_chat_join_request
|
|
|
|
"""Alias for :meth:`approve_chat_join_request`"""
|
|
|
|
declineChatJoinRequest = decline_chat_join_request
|
|
|
|
"""Alias for :meth:`decline_chat_join_request`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
setChatPhoto = set_chat_photo
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_chat_photo`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
deleteChatPhoto = delete_chat_photo
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`delete_chat_photo`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
setChatTitle = set_chat_title
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_chat_title`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
setChatDescription = set_chat_description
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_chat_description`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
pinChatMessage = pin_chat_message
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`pin_chat_message`"""
|
2017-07-01 17:08:45 +02:00
|
|
|
unpinChatMessage = unpin_chat_message
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`unpin_chat_message`"""
|
2020-11-29 16:20:46 +01:00
|
|
|
unpinAllChatMessages = unpin_all_chat_messages
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`unpin_all_chat_messages`"""
|
2022-08-25 19:36:55 +02:00
|
|
|
getCustomEmojiStickers = get_custom_emoji_stickers
|
|
|
|
"""Alias for :meth:`get_custom_emoji_stickers`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
getStickerSet = get_sticker_set
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_sticker_set`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
uploadStickerFile = upload_sticker_file
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`upload_sticker_file`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
createNewStickerSet = create_new_sticker_set
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`create_new_sticker_set`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
addStickerToSet = add_sticker_to_set
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`add_sticker_to_set`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
setStickerPositionInSet = set_sticker_position_in_set
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_sticker_position_in_set`"""
|
2017-07-22 13:34:51 +02:00
|
|
|
deleteStickerFromSet = delete_sticker_from_set
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`delete_sticker_from_set`"""
|
2023-03-25 11:47:26 +01:00
|
|
|
setStickerSetThumbnail = set_sticker_set_thumbnail
|
|
|
|
"""Alias for :meth:`set_sticker_set_thumbnail`"""
|
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
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_passport_data_errors`"""
|
2019-08-23 21:20:41 +02:00
|
|
|
sendPoll = send_poll
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_poll`"""
|
2019-08-23 21:20:41 +02:00
|
|
|
stopPoll = stop_poll
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`stop_poll`"""
|
2020-04-10 19:22:45 +02:00
|
|
|
sendDice = send_dice
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`send_dice`"""
|
2020-04-10 19:22:45 +02:00
|
|
|
getMyCommands = get_my_commands
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`get_my_commands`"""
|
2020-04-10 19:22:45 +02:00
|
|
|
setMyCommands = set_my_commands
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`set_my_commands`"""
|
2021-07-01 17:45:19 +02:00
|
|
|
deleteMyCommands = delete_my_commands
|
|
|
|
"""Alias for :meth:`delete_my_commands`"""
|
2020-11-29 16:20:46 +01:00
|
|
|
logOut = log_out
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`log_out`"""
|
2020-11-29 16:20:46 +01:00
|
|
|
copyMessage = copy_message
|
2021-03-14 16:46:37 +01:00
|
|
|
"""Alias for :meth:`copy_message`"""
|
2024-02-08 17:12:00 +01:00
|
|
|
copyMessages = copy_messages
|
|
|
|
"""Alias for :meth:`copy_messages`"""
|
2022-05-03 18:21:50 +02:00
|
|
|
getChatMenuButton = get_chat_menu_button
|
|
|
|
"""Alias for :meth:`get_chat_menu_button`"""
|
|
|
|
setChatMenuButton = set_chat_menu_button
|
|
|
|
"""Alias for :meth:`set_chat_menu_button`"""
|
|
|
|
getMyDefaultAdministratorRights = get_my_default_administrator_rights
|
|
|
|
"""Alias for :meth:`get_my_default_administrator_rights`"""
|
|
|
|
setMyDefaultAdministratorRights = set_my_default_administrator_rights
|
|
|
|
"""Alias for :meth:`set_my_default_administrator_rights`"""
|
2022-06-27 18:54:11 +02:00
|
|
|
createInvoiceLink = create_invoice_link
|
|
|
|
"""Alias for :meth:`create_invoice_link`"""
|
2022-11-22 10:43:50 +01:00
|
|
|
getForumTopicIconStickers = get_forum_topic_icon_stickers
|
|
|
|
"""Alias for :meth:`get_forum_topic_icon_stickers`"""
|
|
|
|
createForumTopic = create_forum_topic
|
|
|
|
"""Alias for :meth:`create_forum_topic`"""
|
|
|
|
editForumTopic = edit_forum_topic
|
|
|
|
"""Alias for :meth:`edit_forum_topic`"""
|
|
|
|
closeForumTopic = close_forum_topic
|
|
|
|
"""Alias for :meth:`close_forum_topic`"""
|
|
|
|
reopenForumTopic = reopen_forum_topic
|
|
|
|
"""Alias for :meth:`reopen_forum_topic`"""
|
|
|
|
deleteForumTopic = delete_forum_topic
|
|
|
|
"""Alias for :meth:`delete_forum_topic`"""
|
|
|
|
unpinAllForumTopicMessages = unpin_all_forum_topic_messages
|
|
|
|
"""Alias for :meth:`unpin_all_forum_topic_messages`"""
|
2023-01-01 17:00:49 +01:00
|
|
|
editGeneralForumTopic = edit_general_forum_topic
|
|
|
|
"""Alias for :meth:`edit_general_forum_topic`"""
|
|
|
|
closeGeneralForumTopic = close_general_forum_topic
|
|
|
|
"""Alias for :meth:`close_general_forum_topic`"""
|
|
|
|
reopenGeneralForumTopic = reopen_general_forum_topic
|
|
|
|
"""Alias for :meth:`reopen_general_forum_topic`"""
|
|
|
|
hideGeneralForumTopic = hide_general_forum_topic
|
|
|
|
"""Alias for :meth:`hide_general_forum_topic`"""
|
|
|
|
unhideGeneralForumTopic = unhide_general_forum_topic
|
|
|
|
"""Alias for :meth:`unhide_general_forum_topic`"""
|
2023-03-25 11:47:26 +01:00
|
|
|
setMyDescription = set_my_description
|
|
|
|
"""Alias for :meth:`set_my_description`"""
|
|
|
|
setMyShortDescription = set_my_short_description
|
|
|
|
"""Alias for :meth:`set_my_short_description`"""
|
|
|
|
getMyDescription = get_my_description
|
|
|
|
"""Alias for :meth:`get_my_description`"""
|
|
|
|
getMyShortDescription = get_my_short_description
|
|
|
|
"""Alias for :meth:`get_my_short_description`"""
|
|
|
|
setCustomEmojiStickerSetThumbnail = set_custom_emoji_sticker_set_thumbnail
|
|
|
|
"""Alias for :meth:`set_custom_emoji_sticker_set_thumbnail`"""
|
|
|
|
setStickerSetTitle = set_sticker_set_title
|
|
|
|
"""Alias for :meth:`set_sticker_set_title`"""
|
|
|
|
deleteStickerSet = delete_sticker_set
|
|
|
|
"""Alias for :meth:`delete_sticker_set`"""
|
|
|
|
setStickerEmojiList = set_sticker_emoji_list
|
|
|
|
"""Alias for :meth:`set_sticker_emoji_list`"""
|
|
|
|
setStickerKeywords = set_sticker_keywords
|
|
|
|
"""Alias for :meth:`set_sticker_keywords`"""
|
|
|
|
setStickerMaskPosition = set_sticker_mask_position
|
|
|
|
"""Alias for :meth:`set_sticker_mask_position`"""
|
2023-05-07 13:44:34 +02:00
|
|
|
setMyName = set_my_name
|
|
|
|
"""Alias for :meth:`set_my_name`"""
|
|
|
|
getMyName = get_my_name
|
|
|
|
"""Alias for :meth:`get_my_name`"""
|
2023-09-03 13:43:44 +02:00
|
|
|
unpinAllGeneralForumTopicMessages = unpin_all_general_forum_topic_messages
|
|
|
|
"""Alias for :meth:`unpin_all_general_forum_topic_messages`"""
|
2024-02-08 17:12:00 +01:00
|
|
|
getUserChatBoosts = get_user_chat_boosts
|
|
|
|
"""Alias for :meth:`get_user_chat_boosts`"""
|
|
|
|
setMessageReaction = set_message_reaction
|
|
|
|
"""Alias for :meth:`set_message_reaction`"""
|
2024-04-12 11:58:25 +02:00
|
|
|
getBusinessConnection = get_business_connection
|
|
|
|
"""Alias for :meth:`get_business_connection`"""
|
|
|
|
replaceStickerInSet = replace_sticker_in_set
|
|
|
|
"""Alias for :meth:`replace_sticker_in_set`"""
|