Reworked bot-wide defaults (#1392)

* Reworked defaults

* Added changelog and partial docs
This commit is contained in:
Alex Root Junior 2024-01-27 17:19:45 +02:00 committed by GitHub
parent 1281bf551a
commit 24f59da70d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
140 changed files with 608 additions and 530 deletions

View file

@ -0,0 +1,2 @@
parse_mode: parse_mode
protect_content: protect_content

View file

@ -1,5 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1,2 @@
disable_web_page_preview: link_preview_is_disabled
parse_mode: parse_mode

View file

@ -1,5 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
disable_web_page_preview:
value: UNSET_DISABLE_WEB_PAGE_PREVIEW

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,3 +0,0 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1,2 @@
parse_mode: parse_mode
protect_content: protect_content

View file

@ -1,8 +1,4 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
protect_content:
value: UNSET_PROTECT_CONTENT
thumbnail:
parsed_type:
type: entity

View file

@ -0,0 +1,2 @@
parse_mode: parse_mode
protect_content: protect_content

View file

@ -1,8 +1,4 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
protect_content:
value: UNSET_PROTECT_CONTENT
thumbnail:
parsed_type:
type: entity

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,3 +0,0 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,3 +0,0 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1,2 @@
parse_mode: parse_mode
protect_content: protect_content

View file

@ -1,8 +1,4 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
protect_content:
value: UNSET_PROTECT_CONTENT
thumbnail:
parsed_type:
type: entity

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,3 +0,0 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,3 +0,0 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,3 +0,0 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,3 +0,0 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1,4 @@
disable_web_page_preview: link_preview_is_disabled
parse_mode: parse_mode
protect_content: protect_content
link_preview_options: link_preview

View file

@ -1,7 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
disable_web_page_preview:
value: UNSET_DISABLE_WEB_PAGE_PREVIEW
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1,2 @@
parse_mode: parse_mode
protect_content: protect_content

View file

@ -1,5 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1,2 @@
explanation_parse_mode: parse_mode
protect_content: protect_content

View file

@ -1,8 +1,4 @@
annotations:
explanation_parse_mode:
value: UNSET_PARSE_MODE
protect_content:
value: UNSET_PROTECT_CONTENT
close_date:
parsed_type:
type: union

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,3 +0,0 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,3 +0,0 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1,2 @@
parse_mode: parse_mode
protect_content: protect_content

View file

@ -1,8 +1,4 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
protect_content:
value: UNSET_PROTECT_CONTENT
thumbnail:
parsed_type:
type: entity

View file

@ -0,0 +1 @@
protect_content: protect_content

View file

@ -1,6 +1,4 @@
annotations:
protect_content:
value: UNSET_PROTECT_CONTENT
thumbnail:
parsed_type:
type: entity

View file

@ -0,0 +1,2 @@
parse_mode: parse_mode
protect_content: protect_content

View file

@ -1,5 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
protect_content:
value: UNSET_PROTECT_CONTENT

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -1,3 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -15,5 +15,3 @@ annotations:
references:
category: types
name: InputFile
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -15,5 +15,3 @@ annotations:
references:
category: types
name: InputFile
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -15,5 +15,3 @@ annotations:
references:
category: types
name: InputFile
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -9,5 +9,3 @@ annotations:
references:
category: types
name: InputFile
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1 @@
parse_mode: parse_mode

View file

@ -15,5 +15,3 @@ annotations:
references:
category: types
name: InputFile
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1,2 @@
disable_web_page_preview: disable_web_page_preview
parse_mode: parse_mode

View file

@ -1,5 +0,0 @@
annotations:
parse_mode:
value: UNSET_PARSE_MODE
disable_web_page_preview:
value: UNSET_DISABLE_WEB_PAGE_PREVIEW

View file

@ -0,0 +1,4 @@
is_disabled: link_preview_is_disabled
prefer_small_media: link_preview_prefer_small_media
prefer_large_media: link_preview_prefer_large_media
show_above_text: link_preview_show_above_text

View file

@ -0,0 +1,2 @@
quote_parse_mode: parse_mode
allow_sending_without_reply: allow_sending_without_reply

View file

@ -1,3 +0,0 @@
annotations:
quote_parse_mode:
value: UNSET_PARSE_MODE

1
CHANGES/1392.feature.rst Normal file
View file

@ -0,0 +1 @@
Reworked bot-wide globals like :code:`parse_mode`, :code:`disable_web_page_preview`, and others to be more flexible.

View file

@ -3,6 +3,7 @@ from __future__ import annotations
import datetime
import io
import pathlib
import warnings
from contextlib import asynccontextmanager
from typing import (
Any,
@ -143,7 +144,6 @@ from ..methods import (
UploadStickerFile,
)
from ..types import (
UNSET_PARSE_MODE,
BotCommand,
BotCommandScopeAllChatAdministrators,
BotCommandScopeAllGroupChats,
@ -233,7 +233,7 @@ from ..types import (
UserProfilePhotos,
WebhookInfo,
)
from ..types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW, UNSET_PROTECT_CONTENT
from .default import Default, DefaultBotProperties
from .session.aiohttp import AiohttpSession
from .session.base import BaseSession
@ -248,6 +248,7 @@ class Bot:
parse_mode: Optional[str] = None,
disable_web_page_preview: Optional[bool] = None,
protect_content: Optional[bool] = None,
default: Optional[DefaultBotProperties] = None,
) -> None:
"""
Bot class
@ -261,6 +262,8 @@ class Bot:
If specified it will be propagated into the API methods at runtime.
:param protect_content: Default protect_content mode.
If specified it will be propagated into the API methods at runtime.
:param default: Default bot properties.
If specified it will be propagated into the API methods at runtime.
:raise TokenValidationError: When token has invalid format this exception will be raised
"""
@ -268,11 +271,29 @@ class Bot:
if session is None:
session = AiohttpSession()
if default is None:
default = DefaultBotProperties(
parse_mode=parse_mode,
link_preview_is_disabled=disable_web_page_preview,
protect_content=protect_content,
)
self.session = session
self.parse_mode = parse_mode
self.disable_web_page_preview = disable_web_page_preview
self.protect_content = protect_content
if (
parse_mode is not None
or disable_web_page_preview is not None
or protect_content is not None
):
warnings.warn(
"Passing `parse_mode`, `disable_web_page_preview` or `protect_content` "
"to Bot initializer is deprecated. This arguments will be removed in 3.5.0 version\n"
"Use `default=DefaultBotProperties(...)` instead.",
category=DeprecationWarning,
stacklevel=2,
)
self.default = default
self.__token = token
self._me: Optional[User] = None
@ -805,10 +826,10 @@ class Bot:
message_id: int,
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1302,7 +1323,7 @@ class Bot:
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
request_timeout: Optional[int] = None,
@ -1451,11 +1472,13 @@ class Bot:
chat_id: Optional[Union[int, str]] = None,
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[LinkPreviewOptions] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
request_timeout: Optional[int] = None,
) -> Union[Message, bool]:
"""
@ -1518,7 +1541,7 @@ class Bot:
message_id: int,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
request_timeout: Optional[int] = None,
) -> Message:
"""
@ -2137,11 +2160,11 @@ class Bot:
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2203,14 +2226,14 @@ class Bot:
audio: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2304,7 +2327,7 @@ class Bot:
last_name: Optional[str] = None,
vcard: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2356,7 +2379,7 @@ class Bot:
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2403,11 +2426,11 @@ class Bot:
message_thread_id: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2463,7 +2486,7 @@ class Bot:
game_short_name: str,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -2527,7 +2550,7 @@ class Bot:
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -2616,7 +2639,7 @@ class Bot:
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2672,7 +2695,7 @@ class Bot:
media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]],
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
allow_sending_without_reply: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
@ -2712,17 +2735,21 @@ class Bot:
chat_id: Union[int, str],
text: str,
message_thread_id: Optional[int] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[LinkPreviewOptions] = None,
link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = Default(
"link_preview"
),
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
allow_sending_without_reply: Optional[bool] = None,
disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
reply_to_message_id: Optional[int] = None,
request_timeout: Optional[int] = None,
) -> Message:
@ -2771,11 +2798,11 @@ class Bot:
photo: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2834,13 +2861,13 @@ class Bot:
allows_multiple_answers: Optional[bool] = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_parse_mode: Optional[str] = UNSET_PARSE_MODE,
explanation_parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
explanation_entities: Optional[List[MessageEntity]] = None,
open_period: Optional[int] = None,
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
is_closed: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2909,7 +2936,7 @@ class Bot:
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2964,7 +2991,7 @@ class Bot:
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -3028,12 +3055,12 @@ class Bot:
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
supports_streaming: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -3100,7 +3127,7 @@ class Bot:
length: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -3152,11 +3179,11 @@ class Bot:
voice: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

84
aiogram/client/default.py Normal file
View file

@ -0,0 +1,84 @@
from __future__ import annotations
import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Dict, Optional
if TYPE_CHECKING:
from aiogram.types import LinkPreviewOptions
# @dataclass ??
class Default:
# Is not a dataclass because of JSON serialization.
__slots__ = ("_name",)
def __init__(self, name: str) -> None:
self._name = name
@property
def name(self) -> str:
return self._name
def __str__(self) -> str:
return f"Default({self._name!r})"
def __repr__(self) -> str:
return f"<{self}>"
_dataclass_properties: Dict[str, Any] = {}
if sys.version_info >= (3, 10):
# Speedup attribute access for dataclasses in Python 3.10+
_dataclass_properties.update({"slots": True, "kw_only": True})
@dataclass(**_dataclass_properties)
class DefaultBotProperties:
"""
Default bot properties.
"""
parse_mode: Optional[str] = None
"""Default parse mode for messages."""
disable_notification: Optional[bool] = None
"""Sends the message silently. Users will receive a notification with no sound."""
protect_content: Optional[bool] = None
"""Protects content from copying."""
allow_sending_without_reply: Optional[bool] = None
"""Allows to send messages without reply."""
link_preview: Optional[LinkPreviewOptions] = None
"""Link preview settings."""
link_preview_is_disabled: Optional[bool] = None
"""Disables link preview."""
link_preview_prefer_small_media: Optional[bool] = None
"""Prefer small media in link preview."""
link_preview_prefer_large_media: Optional[bool] = None
"""Prefer large media in link preview."""
link_preview_show_above_text: Optional[bool] = None
"""Show link preview above text."""
def __post_init__(self) -> None:
has_any_link_preview_option = any(
(
self.link_preview_is_disabled,
self.link_preview_prefer_small_media,
self.link_preview_prefer_large_media,
self.link_preview_show_above_text,
)
)
if has_any_link_preview_option and self.link_preview is None:
from ..types import LinkPreviewOptions
self.link_preview = LinkPreviewOptions(
is_disabled=self.link_preview_is_disabled,
prefer_small_media=self.link_preview_prefer_small_media,
prefer_large_media=self.link_preview_prefer_large_media,
show_above_text=self.link_preview_show_above_text,
)
def __getitem__(self, item: str) -> Any:
return getattr(self, item, None)

View file

@ -6,7 +6,6 @@ from typing import (
TYPE_CHECKING,
Any,
AsyncGenerator,
AsyncIterator,
Dict,
Iterable,
List,

View file

@ -38,8 +38,8 @@ from aiogram.exceptions import (
from ...methods import Response, TelegramMethod
from ...methods.base import TelegramType
from ...types import UNSET_PARSE_MODE, InputFile
from ...types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW, UNSET_PROTECT_CONTENT
from ...types import InputFile
from ..default import Default
from ..telegram import PRODUCTION, TelegramAPIServer
from .middlewares.manager import RequestMiddlewareManager
@ -191,18 +191,9 @@ class BaseSession(abc.ABC):
return None
if isinstance(value, str):
return value
if value is UNSET_PARSE_MODE:
return self.prepare_value(
bot.parse_mode, bot=bot, files=files, _dumps_json=_dumps_json
)
if value is UNSET_DISABLE_WEB_PAGE_PREVIEW:
return self.prepare_value(
bot.disable_web_page_preview, bot=bot, files=files, _dumps_json=_dumps_json
)
if value is UNSET_PROTECT_CONTENT:
return self.prepare_value(
bot.protect_content, bot=bot, files=files, _dumps_json=_dumps_json
)
if isinstance(value, Default):
default_value = bot.default[value.name]
return self.prepare_value(default_value, bot=bot, files=files, _dumps_json=_dumps_json)
if isinstance(value, InputFile):
key = secrets.token_urlsafe(10)
files[key] = value

View file

@ -4,8 +4,8 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..types import (
UNSET_PARSE_MODE,
ForceReply,
InlineKeyboardMarkup,
MessageEntity,
@ -14,7 +14,6 @@ from ..types import (
ReplyKeyboardRemove,
ReplyParameters,
)
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
@ -38,13 +37,13 @@ class CopyMessage(TelegramMethod[MessageId]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
caption: Optional[str] = None
"""New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept"""
parse_mode: Optional[str] = UNSET_PARSE_MODE
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
"""Mode for parsing entities in the new caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of *parse_mode*"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -77,10 +76,10 @@ class CopyMessage(TelegramMethod[MessageId]):
message_id: int,
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -2,6 +2,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Optional, Union
from ..client.default import Default
from ..types import UNSET_PARSE_MODE, InlineKeyboardMarkup, Message, MessageEntity
from .base import TelegramMethod
@ -24,7 +25,7 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
"""Required if *chat_id* and *message_id* are not specified. Identifier of the inline message"""
caption: Optional[str] = None
"""New caption of the message, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = UNSET_PARSE_MODE
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
"""Mode for parsing entities in the message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -42,7 +43,7 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
**__pydantic_kwargs: Any,

View file

@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..types import (
UNSET_PARSE_MODE,
InlineKeyboardMarkup,
@ -11,7 +12,6 @@ from ..types import (
Message,
MessageEntity,
)
from ..types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW
from .base import TelegramMethod
@ -33,7 +33,7 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
"""Required if *inline_message_id* is not specified. Identifier of the message to edit"""
inline_message_id: Optional[str] = None
"""Required if *chat_id* and *message_id* are not specified. Identifier of the inline message"""
parse_mode: Optional[str] = UNSET_PARSE_MODE
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
"""Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in message text, which can be specified instead of *parse_mode*"""
@ -41,8 +41,8 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
"""Link preview generation options for the message"""
reply_markup: Optional[InlineKeyboardMarkup] = None
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_."""
disable_web_page_preview: Optional[bool] = Field(
UNSET_DISABLE_WEB_PAGE_PREVIEW, json_schema_extra={"deprecated": True}
disable_web_page_preview: Optional[Union[bool, Default]] = Field(
Default("link_preview_is_disabled"), json_schema_extra={"deprecated": True}
)
"""Disables link previews for links in this message
@ -60,11 +60,13 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
chat_id: Optional[Union[int, str]] = None,
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[LinkPreviewOptions] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!

View file

@ -2,6 +2,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional, Union
from ..client.default import Default
from ..types import Message
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
@ -27,7 +28,7 @@ class ForwardMessage(TelegramMethod[Message]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
"""Protects the contents of the forwarded message from forwarding and saving"""
if TYPE_CHECKING:
@ -42,7 +43,7 @@ class ForwardMessage(TelegramMethod[Message]):
message_id: int,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!

View file

@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..types import (
UNSET_PARSE_MODE,
ForceReply,
@ -15,7 +16,6 @@ from ..types import (
ReplyKeyboardRemove,
ReplyParameters,
)
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
@ -45,7 +45,7 @@ class SendAnimation(TelegramMethod[Message]):
"""Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
caption: Optional[str] = None
"""Animation caption (may also be used when resending animation by *file_id*), 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = UNSET_PARSE_MODE
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
"""Mode for parsing entities in the animation caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -53,7 +53,7 @@ class SendAnimation(TelegramMethod[Message]):
"""Pass :code:`True` if the animation needs to be covered with a spoiler animation"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -89,11 +89,11 @@ class SendAnimation(TelegramMethod[Message]):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,8 +4,8 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..types import (
UNSET_PARSE_MODE,
ForceReply,
InlineKeyboardMarkup,
InputFile,
@ -15,7 +15,6 @@ from ..types import (
ReplyKeyboardRemove,
ReplyParameters,
)
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
@ -38,7 +37,7 @@ class SendAudio(TelegramMethod[Message]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
caption: Optional[str] = None
"""Audio caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = UNSET_PARSE_MODE
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
"""Mode for parsing entities in the audio caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -52,7 +51,7 @@ class SendAudio(TelegramMethod[Message]):
"""Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -84,14 +83,14 @@ class SendAudio(TelegramMethod[Message]):
audio: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -12,7 +13,6 @@ from ..types import (
ReplyKeyboardRemove,
ReplyParameters,
)
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
@ -40,7 +40,7 @@ class SendContact(TelegramMethod[Message]):
"""Additional data about the contact in the form of a `vCard <https://en.wikipedia.org/wiki/VCard>`_, 0-2048 bytes"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -75,7 +75,7 @@ class SendContact(TelegramMethod[Message]):
last_name: Optional[str] = None,
vcard: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -12,7 +13,6 @@ from ..types import (
ReplyKeyboardRemove,
ReplyParameters,
)
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
@ -34,7 +34,7 @@ class SendDice(TelegramMethod[Message]):
"""Emoji on which the dice throw animation is based. Currently, must be one of '🎲', '🎯', '🏀', '', '🎳', or '🎰'. Dice can have values 1-6 for '🎲', '🎯' and '🎳', values 1-5 for '🏀' and '', and values 1-64 for '🎰'. Defaults to '🎲'"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
"""Protects the contents of the sent message from forwarding"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -66,7 +66,7 @@ class SendDice(TelegramMethod[Message]):
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..types import (
UNSET_PARSE_MODE,
ForceReply,
@ -15,7 +16,6 @@ from ..types import (
ReplyKeyboardRemove,
ReplyParameters,
)
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
@ -39,7 +39,7 @@ class SendDocument(TelegramMethod[Message]):
"""Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
caption: Optional[str] = None
"""Document caption (may also be used when resending documents by *file_id*), 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = UNSET_PARSE_MODE
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
"""Mode for parsing entities in the document caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -47,7 +47,7 @@ class SendDocument(TelegramMethod[Message]):
"""Disables automatic server-side content type detection for files uploaded using multipart/form-data"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -80,11 +80,11 @@ class SendDocument(TelegramMethod[Message]):
message_thread_id: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -1,11 +1,11 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional
from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..types import InlineKeyboardMarkup, Message, ReplyParameters
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
@ -27,7 +27,7 @@ class SendGame(TelegramMethod[Message]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -57,7 +57,7 @@ class SendGame(TelegramMethod[Message]):
game_short_name: str,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,

Some files were not shown because too many files have changed in this diff Show more