mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Reworked request builder (#1142)
* Reworked request builder * Added more default values * Update tests * Fixed timestamp * Fixed Py3.8 support * Describe changes
This commit is contained in:
parent
924a83966d
commit
fea1b7b0a3
300 changed files with 1003 additions and 3448 deletions
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ..types import InputFile, InputSticker
|
||||
from .base import Request, TelegramMethod, prepare_input_sticker
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types import InputSticker
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class AddStickerToSet(TelegramMethod[bool]):
|
||||
|
|
@ -17,6 +14,7 @@ class AddStickerToSet(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "addStickerToSet"
|
||||
|
||||
user_id: int
|
||||
"""User identifier of sticker set owner"""
|
||||
|
|
@ -24,11 +22,3 @@ class AddStickerToSet(TelegramMethod[bool]):
|
|||
"""Sticker set name"""
|
||||
sticker: InputSticker
|
||||
"""A JSON-serialized 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."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_input_sticker(input_sticker=data["sticker"], files=files)
|
||||
|
||||
return Request(method="addStickerToSet", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class AnswerCallbackQuery(TelegramMethod[bool]):
|
||||
|
|
@ -18,6 +15,7 @@ class AnswerCallbackQuery(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "answerCallbackQuery"
|
||||
|
||||
callback_query_id: str
|
||||
"""Unique identifier for the query to be answered"""
|
||||
|
|
@ -29,8 +27,3 @@ class AnswerCallbackQuery(TelegramMethod[bool]):
|
|||
"""URL that will be opened by the user's client. If you have created a :class:`aiogram.types.game.Game` and accepted the conditions via `@BotFather <https://t.me/botfather>`_, specify the URL that opens your game - note that this will only work if the query comes from a `https://core.telegram.org/bots/api#inlinekeyboardbutton <https://core.telegram.org/bots/api#inlinekeyboardbutton>`_ *callback_game* button."""
|
||||
cache_time: Optional[int] = None
|
||||
"""The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="answerCallbackQuery", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from ..types import InlineQueryResult
|
||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class AnswerInlineQuery(TelegramMethod[bool]):
|
||||
|
|
@ -19,6 +16,7 @@ class AnswerInlineQuery(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "answerInlineQuery"
|
||||
|
||||
inline_query_id: str
|
||||
"""Unique identifier for the answered query"""
|
||||
|
|
@ -34,15 +32,3 @@ class AnswerInlineQuery(TelegramMethod[bool]):
|
|||
"""If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter *switch_pm_parameter*"""
|
||||
switch_pm_parameter: Optional[str] = None
|
||||
"""`Deep-linking <https://core.telegram.org/bots/features#deep-linking>`_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
input_message_contents = []
|
||||
for result in data["results"]:
|
||||
input_message_content = result.get("input_message_content", None)
|
||||
if input_message_content is not None:
|
||||
input_message_contents.append(input_message_content)
|
||||
|
||||
prepare_parse_mode(bot, data["results"] + input_message_contents)
|
||||
return Request(method="answerInlineQuery", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class AnswerPreCheckoutQuery(TelegramMethod[bool]):
|
||||
|
|
@ -16,6 +13,7 @@ class AnswerPreCheckoutQuery(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "answerPreCheckoutQuery"
|
||||
|
||||
pre_checkout_query_id: str
|
||||
"""Unique identifier for the query to be answered"""
|
||||
|
|
@ -23,8 +21,3 @@ class AnswerPreCheckoutQuery(TelegramMethod[bool]):
|
|||
"""Specify :code:`True` if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use :code:`False` if there are any problems."""
|
||||
error_message: Optional[str] = None
|
||||
"""Required if *ok* is :code:`False`. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="answerPreCheckoutQuery", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from ..types import ShippingOption
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class AnswerShippingQuery(TelegramMethod[bool]):
|
||||
|
|
@ -17,6 +14,7 @@ class AnswerShippingQuery(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "answerShippingQuery"
|
||||
|
||||
shipping_query_id: str
|
||||
"""Unique identifier for the query to be answered"""
|
||||
|
|
@ -26,8 +24,3 @@ class AnswerShippingQuery(TelegramMethod[bool]):
|
|||
"""Required if *ok* is :code:`True`. A JSON-serialized array of available shipping options."""
|
||||
error_message: Optional[str] = None
|
||||
"""Required if *ok* is :code:`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."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="answerShippingQuery", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ..types import InlineQueryResult, SentWebAppMessage
|
||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class AnswerWebAppQuery(TelegramMethod[SentWebAppMessage]):
|
||||
|
|
@ -17,17 +14,9 @@ class AnswerWebAppQuery(TelegramMethod[SentWebAppMessage]):
|
|||
"""
|
||||
|
||||
__returning__ = SentWebAppMessage
|
||||
__api_method__ = "answerWebAppQuery"
|
||||
|
||||
web_app_query_id: str
|
||||
"""Unique identifier for the query to be answered"""
|
||||
result: InlineQueryResult
|
||||
"""A JSON-serialized object describing the message to be sent"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data["result"], parse_mode_property="parse_mode", entities_property="entities"
|
||||
)
|
||||
|
||||
return Request(method="answerWebAppQuery", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class ApproveChatJoinRequest(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class ApproveChatJoinRequest(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "approveChatJoinRequest"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
user_id: int
|
||||
"""Unique identifier of the target user"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="approveChatJoinRequest", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class BanChatMember(TelegramMethod[bool]):
|
||||
|
|
@ -17,6 +14,7 @@ class BanChatMember(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "banChatMember"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target group or username of the target supergroup or channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -26,8 +24,3 @@ class BanChatMember(TelegramMethod[bool]):
|
|||
"""Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only."""
|
||||
revoke_messages: Optional[bool] = None
|
||||
"""Pass :code:`True` to delete all messages from the chat for the user that is being removed. If :code:`False`, the user will be able to see messages in the group that were sent before the user was removed. Always :code:`True` for supergroups and channels."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="banChatMember", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class BanChatSenderChat(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class BanChatSenderChat(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "banChatSenderChat"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
sender_chat_id: int
|
||||
"""Unique identifier of the target sender chat"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="banChatSenderChat", data=data)
|
||||
|
|
|
|||
|
|
@ -1,22 +1,13 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import abc
|
||||
import secrets
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Dict,
|
||||
Generator,
|
||||
Generic,
|
||||
Optional,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import TYPE_CHECKING, Any, Dict, Generator, Generic, Optional, TypeVar
|
||||
|
||||
from pydantic import BaseConfig, BaseModel, Extra, root_validator
|
||||
from pydantic.generics import GenericModel
|
||||
|
||||
from ..types import UNSET, InputFile, ResponseParameters
|
||||
from ..types import InputFile, ResponseParameters
|
||||
from ..types.base import UNSET_TYPE
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
|
@ -42,7 +33,7 @@ class Response(GenericModel, Generic[TelegramType]):
|
|||
parameters: Optional[ResponseParameters] = None
|
||||
|
||||
|
||||
class TelegramMethod(abc.ABC, BaseModel, Generic[TelegramType]):
|
||||
class TelegramMethod(ABC, BaseModel, Generic[TelegramType]):
|
||||
class Config(BaseConfig):
|
||||
# use_enum_values = True
|
||||
extra = Extra.allow
|
||||
|
|
@ -54,25 +45,23 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[TelegramType]):
|
|||
@root_validator(pre=True)
|
||||
def remove_unset(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
Remove UNSET from `parse_mode` before fields validation.
|
||||
Remove UNSET before fields validation.
|
||||
|
||||
We use UNSET as a sentinel value for `parse_mode` and replace it to real value later.
|
||||
It isn't a problem when it's just default value for a model field, but UNSET might be passing to
|
||||
a model initialization from `Bot.method_name`, so we must take care of it and
|
||||
remove it before fields validation.
|
||||
It isn't a problem when it's just default value for a model field,
|
||||
but UNSET might be passing to a model initialization from `Bot.method_name`,
|
||||
so we must take care of it and remove it before fields validation.
|
||||
"""
|
||||
for parse_mode_attribute in {"parse_mode", "explanation_parse_mode"}:
|
||||
if parse_mode_attribute in values and values[parse_mode_attribute] is UNSET:
|
||||
values.pop(parse_mode_attribute)
|
||||
return values
|
||||
return {k: v for k, v in values.items() if not isinstance(v, UNSET_TYPE)}
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
@abstractmethod
|
||||
def __returning__(self) -> type: # pragma: no cover
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def build_request(self, bot: Bot) -> Request: # pragma: no cover
|
||||
@property
|
||||
@abstractmethod
|
||||
def __api_method__(self) -> str:
|
||||
pass
|
||||
|
||||
def dict(self, **kwargs: Any) -> Any:
|
||||
|
|
@ -95,84 +84,3 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[TelegramType]):
|
|||
|
||||
bot = Bot.get_current(no_error=False)
|
||||
return self.emit(bot).__await__()
|
||||
|
||||
|
||||
def prepare_file(name: str, value: Any, data: Dict[str, Any], files: Dict[str, Any]) -> None:
|
||||
if not value:
|
||||
return
|
||||
if name == "thumbnail":
|
||||
tag = secrets.token_urlsafe(10)
|
||||
files[tag] = value
|
||||
data["thumbnail"] = f"attach://{tag}"
|
||||
elif isinstance(value, InputFile):
|
||||
files[name] = value
|
||||
else:
|
||||
data[name] = value
|
||||
|
||||
|
||||
def prepare_input_media(data: Dict[str, Any], files: Dict[str, InputFile]) -> None:
|
||||
for input_media in data.get("media", []): # type: Dict[str, Union[str, InputFile]]
|
||||
if (
|
||||
"media" in input_media
|
||||
and input_media["media"]
|
||||
and isinstance(input_media["media"], InputFile)
|
||||
):
|
||||
tag = secrets.token_urlsafe(10)
|
||||
files[tag] = input_media.pop("media") # type: ignore
|
||||
input_media["media"] = f"attach://{tag}"
|
||||
|
||||
|
||||
def prepare_input_sticker(input_sticker: Dict[str, Any], files: Dict[str, InputFile]) -> None:
|
||||
if (
|
||||
"sticker" in input_sticker
|
||||
and input_sticker["sticker"]
|
||||
and isinstance(input_sticker["sticker"], InputFile)
|
||||
):
|
||||
tag = secrets.token_urlsafe(10)
|
||||
files[tag] = input_sticker.pop("sticker")
|
||||
input_sticker["sticker"] = f"attach://{tag}"
|
||||
|
||||
|
||||
def prepare_input_stickers(data: Dict[str, Any], files: Dict[str, InputFile]) -> None:
|
||||
for input_sticker in data["stickers"]:
|
||||
prepare_input_sticker(input_sticker, files=files)
|
||||
|
||||
|
||||
def prepare_media_file(data: Dict[str, Any], files: Dict[str, InputFile]) -> None:
|
||||
if (
|
||||
data["media"]
|
||||
and "media" in data["media"]
|
||||
and isinstance(data["media"]["media"], InputFile)
|
||||
):
|
||||
tag = secrets.token_urlsafe(10)
|
||||
files[tag] = data["media"].pop("media")
|
||||
data["media"]["media"] = f"attach://{tag}"
|
||||
|
||||
|
||||
def prepare_parse_mode(
|
||||
bot: Bot,
|
||||
root: Any,
|
||||
parse_mode_property: str = "parse_mode",
|
||||
entities_property: str = "entities",
|
||||
) -> None:
|
||||
"""
|
||||
Find and set parse_mode with highest priority.
|
||||
|
||||
Developer can manually set parse_mode for each message (or message-like) object,
|
||||
but if parse_mode was unset we should use value from Bot object.
|
||||
|
||||
We can't use None for "unset state", because None itself is the parse_mode option.
|
||||
"""
|
||||
if isinstance(root, list):
|
||||
for item in root:
|
||||
prepare_parse_mode(
|
||||
bot=bot,
|
||||
root=item,
|
||||
parse_mode_property=parse_mode_property,
|
||||
entities_property=entities_property,
|
||||
)
|
||||
elif root.get(parse_mode_property, UNSET) is UNSET:
|
||||
if bot.parse_mode and root.get(entities_property, None) is None:
|
||||
root[parse_mode_property] = bot.parse_mode
|
||||
else:
|
||||
root[parse_mode_property] = None
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class Close(TelegramMethod[bool]):
|
||||
|
|
@ -16,8 +13,4 @@ class Close(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="close", data=data)
|
||||
__api_method__ = "close"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class CloseForumTopic(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class CloseForumTopic(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "closeForumTopic"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
message_thread_id: int
|
||||
"""Unique identifier for the target message thread of the forum topic"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="closeForumTopic", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class CloseGeneralForumTopic(TelegramMethod[bool]):
|
||||
|
|
@ -16,11 +13,7 @@ class CloseGeneralForumTopic(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "closeGeneralForumTopic"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="closeGeneralForumTopic", data=data)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
UNSET_PARSE_MODE,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
MessageEntity,
|
||||
|
|
@ -11,10 +11,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class CopyMessage(TelegramMethod[MessageId]):
|
||||
|
|
@ -25,6 +23,7 @@ class CopyMessage(TelegramMethod[MessageId]):
|
|||
"""
|
||||
|
||||
__returning__ = MessageId
|
||||
__api_method__ = "copyMessage"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -36,13 +35,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: Optional[str] = UNSET_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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -52,12 +51,3 @@ class CopyMessage(TelegramMethod[MessageId]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="caption_entities"
|
||||
)
|
||||
|
||||
return Request(method="copyMessage", data=data)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import ChatInviteLink
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class CreateChatInviteLink(TelegramMethod[ChatInviteLink]):
|
||||
|
|
@ -18,6 +15,7 @@ class CreateChatInviteLink(TelegramMethod[ChatInviteLink]):
|
|||
"""
|
||||
|
||||
__returning__ = ChatInviteLink
|
||||
__api_method__ = "createChatInviteLink"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -29,8 +27,3 @@ class CreateChatInviteLink(TelegramMethod[ChatInviteLink]):
|
|||
"""The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
|
||||
creates_join_request: Optional[bool] = None
|
||||
""":code:`True`, if users joining the chat via the link need to be approved by chat administrators. If :code:`True`, *member_limit* can't be specified"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="createChatInviteLink", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import ForumTopic
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class CreateForumTopic(TelegramMethod[ForumTopic]):
|
||||
|
|
@ -17,6 +14,7 @@ class CreateForumTopic(TelegramMethod[ForumTopic]):
|
|||
"""
|
||||
|
||||
__returning__ = ForumTopic
|
||||
__api_method__ = "createForumTopic"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
|
@ -26,8 +24,3 @@ class CreateForumTopic(TelegramMethod[ForumTopic]):
|
|||
"""Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F)"""
|
||||
icon_custom_emoji_id: Optional[str] = None
|
||||
"""Unique identifier of the custom emoji shown as the topic icon. Use :class:`aiogram.methods.get_forum_topic_icon_stickers.GetForumTopicIconStickers` to get all allowed custom emoji identifiers."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="createForumTopic", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from ..types import LabeledPrice
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class CreateInvoiceLink(TelegramMethod[str]):
|
||||
|
|
@ -17,6 +14,7 @@ class CreateInvoiceLink(TelegramMethod[str]):
|
|||
"""
|
||||
|
||||
__returning__ = str
|
||||
__api_method__ = "createInvoiceLink"
|
||||
|
||||
title: str
|
||||
"""Product name, 1-32 characters"""
|
||||
|
|
@ -58,8 +56,3 @@ class CreateInvoiceLink(TelegramMethod[str]):
|
|||
"""Pass :code:`True` if the user's email address should be sent to the provider"""
|
||||
is_flexible: Optional[bool] = None
|
||||
"""Pass :code:`True` if the final price depends on the shipping method"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="createInvoiceLink", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from ..types import InputFile, InputSticker
|
||||
from .base import Request, TelegramMethod, prepare_input_sticker, prepare_input_stickers
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types import InputSticker
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class CreateNewStickerSet(TelegramMethod[bool]):
|
||||
|
|
@ -17,6 +14,7 @@ class CreateNewStickerSet(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "createNewStickerSet"
|
||||
|
||||
user_id: int
|
||||
"""User identifier of created sticker set owner"""
|
||||
|
|
@ -32,11 +30,3 @@ class CreateNewStickerSet(TelegramMethod[bool]):
|
|||
"""Type of stickers in the set, pass 'regular', 'mask', or 'custom_emoji'. By default, a regular sticker set is created."""
|
||||
needs_repainting: Optional[bool] = None
|
||||
"""Pass :code:`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"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
files: Dict[str, InputFile] = {}
|
||||
|
||||
prepare_input_stickers(data=data, files=files)
|
||||
|
||||
return Request(method="createNewStickerSet", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class DeclineChatJoinRequest(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class DeclineChatJoinRequest(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "declineChatJoinRequest"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
user_id: int
|
||||
"""Unique identifier of the target user"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="declineChatJoinRequest", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class DeleteChatPhoto(TelegramMethod[bool]):
|
||||
|
|
@ -16,11 +13,7 @@ class DeleteChatPhoto(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "deleteChatPhoto"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="deleteChatPhoto", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class DeleteChatStickerSet(TelegramMethod[bool]):
|
||||
|
|
@ -16,11 +13,7 @@ class DeleteChatStickerSet(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "deleteChatStickerSet"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="deleteChatStickerSet", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class DeleteForumTopic(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class DeleteForumTopic(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "deleteForumTopic"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
message_thread_id: int
|
||||
"""Unique identifier for the target message thread of the forum topic"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="deleteForumTopic", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class DeleteMessage(TelegramMethod[bool]):
|
||||
|
|
@ -34,13 +31,9 @@ class DeleteMessage(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "deleteMessage"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
message_id: int
|
||||
"""Identifier of the message to delete"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="deleteMessage", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from ..types import BotCommandScope
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class DeleteMyCommands(TelegramMethod[bool]):
|
||||
|
|
@ -17,13 +14,9 @@ class DeleteMyCommands(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "deleteMyCommands"
|
||||
|
||||
scope: Optional[BotCommandScope] = None
|
||||
"""A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to :class:`aiogram.types.bot_command_scope_default.BotCommandScopeDefault`."""
|
||||
language_code: Optional[str] = None
|
||||
"""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"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="deleteMyCommands", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class DeleteStickerFromSet(TelegramMethod[bool]):
|
||||
|
|
@ -16,11 +13,7 @@ class DeleteStickerFromSet(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "deleteStickerFromSet"
|
||||
|
||||
sticker: str
|
||||
"""File identifier of the sticker"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="deleteStickerFromSet", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class DeleteStickerSet(TelegramMethod[bool]):
|
||||
|
|
@ -16,11 +13,7 @@ class DeleteStickerSet(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "deleteStickerSet"
|
||||
|
||||
name: str
|
||||
"""Sticker set name"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="deleteStickerSet", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class DeleteWebhook(TelegramMethod[bool]):
|
||||
|
|
@ -16,11 +13,7 @@ class DeleteWebhook(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "deleteWebhook"
|
||||
|
||||
drop_pending_updates: Optional[bool] = None
|
||||
"""Pass :code:`True` to drop all pending updates"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="deleteWebhook", data=data)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import ChatInviteLink
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class EditChatInviteLink(TelegramMethod[ChatInviteLink]):
|
||||
|
|
@ -18,6 +15,7 @@ class EditChatInviteLink(TelegramMethod[ChatInviteLink]):
|
|||
"""
|
||||
|
||||
__returning__ = ChatInviteLink
|
||||
__api_method__ = "editChatInviteLink"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -31,8 +29,3 @@ class EditChatInviteLink(TelegramMethod[ChatInviteLink]):
|
|||
"""The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
|
||||
creates_join_request: Optional[bool] = None
|
||||
""":code:`True`, if users joining the chat via the link need to be approved by chat administrators. If :code:`True`, *member_limit* can't be specified"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="editChatInviteLink", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class EditForumTopic(TelegramMethod[bool]):
|
||||
|
|
@ -16,6 +13,7 @@ class EditForumTopic(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "editForumTopic"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
|
@ -25,8 +23,3 @@ class EditForumTopic(TelegramMethod[bool]):
|
|||
"""New topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept"""
|
||||
icon_custom_emoji_id: Optional[str] = None
|
||||
"""New unique identifier of the custom emoji shown as the topic icon. Use :class:`aiogram.methods.get_forum_topic_icon_stickers.GetForumTopicIconStickers` to get all allowed custom emoji identifiers. Pass an empty string to remove the icon. If not specified, the current icon will be kept"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="editForumTopic", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class EditGeneralForumTopic(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class EditGeneralForumTopic(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "editGeneralForumTopic"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
name: str
|
||||
"""New topic name, 1-128 characters"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="editGeneralForumTopic", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import UNSET, InlineKeyboardMarkup, Message, MessageEntity
|
||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types import UNSET_PARSE_MODE, InlineKeyboardMarkup, Message, MessageEntity
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
|
||||
|
|
@ -17,6 +14,7 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
|
|||
"""
|
||||
|
||||
__returning__ = Union[Message, bool]
|
||||
__api_method__ = "editMessageCaption"
|
||||
|
||||
chat_id: Optional[Union[int, str]] = None
|
||||
"""Required if *inline_message_id* is not specified. Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -26,18 +24,9 @@ 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: Optional[str] = UNSET_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*"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="caption_entities"
|
||||
)
|
||||
|
||||
return Request(method="editMessageCaption", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import InlineKeyboardMarkup, Message
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class EditMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
||||
|
|
@ -17,6 +14,7 @@ class EditMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
|||
"""
|
||||
|
||||
__returning__ = Union[Message, bool]
|
||||
__api_method__ = "editMessageLiveLocation"
|
||||
|
||||
latitude: float
|
||||
"""Latitude of new location"""
|
||||
|
|
@ -36,8 +34,3 @@ class EditMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
|||
"""The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for a new `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="editMessageLiveLocation", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import InlineKeyboardMarkup, InputFile, InputMedia, Message
|
||||
from .base import Request, TelegramMethod, prepare_media_file, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types import InlineKeyboardMarkup, InputMedia, Message
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class EditMessageMedia(TelegramMethod[Union[Message, bool]]):
|
||||
|
|
@ -17,6 +14,7 @@ class EditMessageMedia(TelegramMethod[Union[Message, bool]]):
|
|||
"""
|
||||
|
||||
__returning__ = Union[Message, bool]
|
||||
__api_method__ = "editMessageMedia"
|
||||
|
||||
media: InputMedia
|
||||
"""A JSON-serialized object for a new media content of the message"""
|
||||
|
|
@ -28,11 +26,3 @@ class EditMessageMedia(TelegramMethod[Union[Message, bool]]):
|
|||
"""Required if *chat_id* and *message_id* are not specified. Identifier of the inline message"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for a new `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
prepare_parse_mode(bot, data["media"])
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_media_file(data=data, files=files)
|
||||
|
||||
return Request(method="editMessageMedia", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import InlineKeyboardMarkup, Message
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class EditMessageReplyMarkup(TelegramMethod[Union[Message, bool]]):
|
||||
|
|
@ -17,6 +14,7 @@ class EditMessageReplyMarkup(TelegramMethod[Union[Message, bool]]):
|
|||
"""
|
||||
|
||||
__returning__ = Union[Message, bool]
|
||||
__api_method__ = "editMessageReplyMarkup"
|
||||
|
||||
chat_id: Optional[Union[int, str]] = None
|
||||
"""Required if *inline_message_id* is not specified. Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -26,8 +24,3 @@ class EditMessageReplyMarkup(TelegramMethod[Union[Message, bool]]):
|
|||
"""Required if *chat_id* and *message_id* are not specified. Identifier of the inline message"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="editMessageReplyMarkup", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import UNSET, InlineKeyboardMarkup, Message, MessageEntity
|
||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types import UNSET_PARSE_MODE, InlineKeyboardMarkup, Message, MessageEntity
|
||||
from ..types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class EditMessageText(TelegramMethod[Union[Message, bool]]):
|
||||
|
|
@ -17,6 +15,7 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
|
|||
"""
|
||||
|
||||
__returning__ = Union[Message, bool]
|
||||
__api_method__ = "editMessageText"
|
||||
|
||||
text: str
|
||||
"""New text of the message, 1-4096 characters after entities parsing"""
|
||||
|
|
@ -26,20 +25,11 @@ 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: Optional[str] = UNSET_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*"""
|
||||
disable_web_page_preview: Optional[bool] = None
|
||||
disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW
|
||||
"""Disables link previews for links in this message"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="entities"
|
||||
)
|
||||
|
||||
return Request(method="editMessageText", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class ExportChatInviteLink(TelegramMethod[str]):
|
||||
|
|
@ -18,11 +15,7 @@ class ExportChatInviteLink(TelegramMethod[str]):
|
|||
"""
|
||||
|
||||
__returning__ = str
|
||||
__api_method__ = "exportChatInviteLink"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="exportChatInviteLink", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import Message
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class ForwardMessage(TelegramMethod[Message]):
|
||||
|
|
@ -17,6 +15,7 @@ class ForwardMessage(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "forwardMessage"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -28,10 +27,5 @@ 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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the forwarded message from forwarding and saving"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="forwardMessage", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from ..types import Chat
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetChat(TelegramMethod[Chat]):
|
||||
|
|
@ -17,11 +14,7 @@ class GetChat(TelegramMethod[Chat]):
|
|||
"""
|
||||
|
||||
__returning__ = Chat
|
||||
__api_method__ = "getChat"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup or channel (in the format :code:`@channelusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getChat", data=data)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Union
|
||||
from typing import TYPE_CHECKING, List, Union
|
||||
|
||||
from ..types import (
|
||||
ChatMemberAdministrator,
|
||||
|
|
@ -10,10 +10,7 @@ from ..types import (
|
|||
ChatMemberOwner,
|
||||
ChatMemberRestricted,
|
||||
)
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetChatAdministrators(
|
||||
|
|
@ -46,11 +43,7 @@ class GetChatAdministrators(
|
|||
ChatMemberBanned,
|
||||
]
|
||||
]
|
||||
__api_method__ = "getChatAdministrators"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup or channel (in the format :code:`@channelusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getChatAdministrators", data=data)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from ..types import (
|
||||
ChatMemberAdministrator,
|
||||
|
|
@ -10,10 +10,7 @@ from ..types import (
|
|||
ChatMemberOwner,
|
||||
ChatMemberRestricted,
|
||||
)
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetChatMember(
|
||||
|
|
@ -42,13 +39,9 @@ class GetChatMember(
|
|||
ChatMemberLeft,
|
||||
ChatMemberBanned,
|
||||
]
|
||||
__api_method__ = "getChatMember"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup or channel (in the format :code:`@channelusername`)"""
|
||||
user_id: int
|
||||
"""Unique identifier of the target user"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getChatMember", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetChatMemberCount(TelegramMethod[int]):
|
||||
|
|
@ -16,11 +13,7 @@ class GetChatMemberCount(TelegramMethod[int]):
|
|||
"""
|
||||
|
||||
__returning__ = int
|
||||
__api_method__ = "getChatMemberCount"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup or channel (in the format :code:`@channelusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getChatMemberCount", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetChatMenuButton(
|
||||
|
|
@ -19,11 +16,7 @@ class GetChatMenuButton(
|
|||
"""
|
||||
|
||||
__returning__ = Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands]
|
||||
__api_method__ = "getChatMenuButton"
|
||||
|
||||
chat_id: Optional[int] = None
|
||||
"""Unique identifier for the target private chat. If not specified, default bot's menu button will be returned"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getChatMenuButton", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
from ..types import Sticker
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetCustomEmojiStickers(TelegramMethod[List[Sticker]]):
|
||||
|
|
@ -17,11 +14,7 @@ class GetCustomEmojiStickers(TelegramMethod[List[Sticker]]):
|
|||
"""
|
||||
|
||||
__returning__ = List[Sticker]
|
||||
__api_method__ = "getCustomEmojiStickers"
|
||||
|
||||
custom_emoji_ids: List[str]
|
||||
"""List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getCustomEmojiStickers", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ..types import File
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetFile(TelegramMethod[File]):
|
||||
|
|
@ -18,11 +15,7 @@ class GetFile(TelegramMethod[File]):
|
|||
"""
|
||||
|
||||
__returning__ = File
|
||||
__api_method__ = "getFile"
|
||||
|
||||
file_id: str
|
||||
"""File identifier to get information about"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getFile", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
from ..types import Sticker
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetForumTopicIconStickers(TelegramMethod[List[Sticker]]):
|
||||
|
|
@ -17,8 +14,4 @@ class GetForumTopicIconStickers(TelegramMethod[List[Sticker]]):
|
|||
"""
|
||||
|
||||
__returning__ = List[Sticker]
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getForumTopicIconStickers", data=data)
|
||||
__api_method__ = "getForumTopicIconStickers"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from ..types import GameHighScore
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetGameHighScores(TelegramMethod[List[GameHighScore]]):
|
||||
|
|
@ -19,6 +16,7 @@ class GetGameHighScores(TelegramMethod[List[GameHighScore]]):
|
|||
"""
|
||||
|
||||
__returning__ = List[GameHighScore]
|
||||
__api_method__ = "getGameHighScores"
|
||||
|
||||
user_id: int
|
||||
"""Target user id"""
|
||||
|
|
@ -28,8 +26,3 @@ class GetGameHighScores(TelegramMethod[List[GameHighScore]]):
|
|||
"""Required if *inline_message_id* is not specified. Identifier of the sent message"""
|
||||
inline_message_id: Optional[str] = None
|
||||
"""Required if *chat_id* and *message_id* are not specified. Identifier of the inline message"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getGameHighScores", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ..types import User
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetMe(TelegramMethod[User]):
|
||||
|
|
@ -17,8 +14,4 @@ class GetMe(TelegramMethod[User]):
|
|||
"""
|
||||
|
||||
__returning__ = User
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getMe", data=data)
|
||||
__api_method__ = "getMe"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from ..types import BotCommand, BotCommandScope
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetMyCommands(TelegramMethod[List[BotCommand]]):
|
||||
|
|
@ -17,13 +14,9 @@ class GetMyCommands(TelegramMethod[List[BotCommand]]):
|
|||
"""
|
||||
|
||||
__returning__ = List[BotCommand]
|
||||
__api_method__ = "getMyCommands"
|
||||
|
||||
scope: Optional[BotCommandScope] = None
|
||||
"""A JSON-serialized object, describing scope of users. Defaults to :class:`aiogram.types.bot_command_scope_default.BotCommandScopeDefault`."""
|
||||
language_code: Optional[str] = None
|
||||
"""A two-letter ISO 639-1 language code or an empty string"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getMyCommands", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from ..types import ChatAdministratorRights
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetMyDefaultAdministratorRights(TelegramMethod[ChatAdministratorRights]):
|
||||
|
|
@ -17,11 +14,7 @@ class GetMyDefaultAdministratorRights(TelegramMethod[ChatAdministratorRights]):
|
|||
"""
|
||||
|
||||
__returning__ = ChatAdministratorRights
|
||||
__api_method__ = "getMyDefaultAdministratorRights"
|
||||
|
||||
for_channels: Optional[bool] = None
|
||||
"""Pass :code:`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."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getMyDefaultAdministratorRights", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from ..types import BotDescription
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetMyDescription(TelegramMethod[BotDescription]):
|
||||
|
|
@ -17,11 +14,7 @@ class GetMyDescription(TelegramMethod[BotDescription]):
|
|||
"""
|
||||
|
||||
__returning__ = BotDescription
|
||||
__api_method__ = "getMyDescription"
|
||||
|
||||
language_code: Optional[str] = None
|
||||
"""A two-letter ISO 639-1 language code or an empty string"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getMyDescription", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from ..types import BotShortDescription
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetMyShortDescription(TelegramMethod[BotShortDescription]):
|
||||
|
|
@ -17,11 +14,7 @@ class GetMyShortDescription(TelegramMethod[BotShortDescription]):
|
|||
"""
|
||||
|
||||
__returning__ = BotShortDescription
|
||||
__api_method__ = "getMyShortDescription"
|
||||
|
||||
language_code: Optional[str] = None
|
||||
"""A two-letter ISO 639-1 language code or an empty string"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getMyShortDescription", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ..types import StickerSet
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetStickerSet(TelegramMethod[StickerSet]):
|
||||
|
|
@ -17,11 +14,7 @@ class GetStickerSet(TelegramMethod[StickerSet]):
|
|||
"""
|
||||
|
||||
__returning__ = StickerSet
|
||||
__api_method__ = "getStickerSet"
|
||||
|
||||
name: str
|
||||
"""Name of the sticker set"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getStickerSet", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from ..types import Update
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetUpdates(TelegramMethod[List[Update]]):
|
||||
|
|
@ -23,6 +20,7 @@ class GetUpdates(TelegramMethod[List[Update]]):
|
|||
"""
|
||||
|
||||
__returning__ = List[Update]
|
||||
__api_method__ = "getUpdates"
|
||||
|
||||
offset: Optional[int] = None
|
||||
"""Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as :class:`aiogram.methods.get_updates.GetUpdates` is called with an *offset* higher than its *update_id*. The negative offset can be specified to retrieve updates starting from *-offset* update from the end of the updates queue. All previous updates will forgotten."""
|
||||
|
|
@ -32,8 +30,3 @@ class GetUpdates(TelegramMethod[List[Update]]):
|
|||
"""Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only."""
|
||||
allowed_updates: Optional[List[str]] = None
|
||||
"""A JSON-serialized list of the update types you want your bot to receive. For example, specify ['message', 'edited_channel_post', 'callback_query'] to only receive updates of these types. See :class:`aiogram.types.update.Update` for a complete list of available update types. Specify an empty list to receive all update types except *chat_member* (default). If not specified, the previous setting will be used."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getUpdates", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from ..types import UserProfilePhotos
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetUserProfilePhotos(TelegramMethod[UserProfilePhotos]):
|
||||
|
|
@ -17,6 +14,7 @@ class GetUserProfilePhotos(TelegramMethod[UserProfilePhotos]):
|
|||
"""
|
||||
|
||||
__returning__ = UserProfilePhotos
|
||||
__api_method__ = "getUserProfilePhotos"
|
||||
|
||||
user_id: int
|
||||
"""Unique identifier of the target user"""
|
||||
|
|
@ -24,8 +22,3 @@ class GetUserProfilePhotos(TelegramMethod[UserProfilePhotos]):
|
|||
"""Sequential number of the first photo to be returned. By default, all photos are returned."""
|
||||
limit: Optional[int] = None
|
||||
"""Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getUserProfilePhotos", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ..types import WebhookInfo
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetWebhookInfo(TelegramMethod[WebhookInfo]):
|
||||
|
|
@ -17,8 +14,4 @@ class GetWebhookInfo(TelegramMethod[WebhookInfo]):
|
|||
"""
|
||||
|
||||
__returning__ = WebhookInfo
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getWebhookInfo", data=data)
|
||||
__api_method__ = "getWebhookInfo"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class HideGeneralForumTopic(TelegramMethod[bool]):
|
||||
|
|
@ -16,11 +13,7 @@ class HideGeneralForumTopic(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "hideGeneralForumTopic"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="hideGeneralForumTopic", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class LeaveChat(TelegramMethod[bool]):
|
||||
|
|
@ -16,11 +13,7 @@ class LeaveChat(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "leaveChat"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup or channel (in the format :code:`@channelusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="leaveChat", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class LogOut(TelegramMethod[bool]):
|
||||
|
|
@ -16,8 +13,4 @@ class LogOut(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="logOut", data=data)
|
||||
__api_method__ = "logOut"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class PinChatMessage(TelegramMethod[bool]):
|
||||
|
|
@ -16,6 +13,7 @@ class PinChatMessage(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "pinChatMessage"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -23,8 +21,3 @@ class PinChatMessage(TelegramMethod[bool]):
|
|||
"""Identifier of a message to pin"""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Pass :code:`True` if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="pinChatMessage", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class PromoteChatMember(TelegramMethod[bool]):
|
||||
|
|
@ -16,6 +13,7 @@ class PromoteChatMember(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "promoteChatMember"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -45,8 +43,3 @@ class PromoteChatMember(TelegramMethod[bool]):
|
|||
"""Pass :code:`True` if the administrator can pin messages, supergroups only"""
|
||||
can_manage_topics: Optional[bool] = None
|
||||
"""Pass :code:`True` if the user is allowed to create, rename, close, and reopen forum topics, supergroups only"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="promoteChatMember", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class ReopenForumTopic(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class ReopenForumTopic(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "reopenForumTopic"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
message_thread_id: int
|
||||
"""Unique identifier for the target message thread of the forum topic"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="reopenForumTopic", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class ReopenGeneralForumTopic(TelegramMethod[bool]):
|
||||
|
|
@ -16,11 +13,7 @@ class ReopenGeneralForumTopic(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "reopenGeneralForumTopic"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="reopenGeneralForumTopic", data=data)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import ChatPermissions
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class RestrictChatMember(TelegramMethod[bool]):
|
||||
|
|
@ -18,6 +15,7 @@ class RestrictChatMember(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "restrictChatMember"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
|
@ -29,8 +27,3 @@ class RestrictChatMember(TelegramMethod[bool]):
|
|||
"""Pass :code:`True` if chat permissions are set independently. Otherwise, the *can_send_other_messages* and *can_add_web_page_previews* permissions will imply the *can_send_messages*, *can_send_audios*, *can_send_documents*, *can_send_photos*, *can_send_videos*, *can_send_video_notes*, and *can_send_voice_notes* permissions; the *can_send_polls* permission will imply the *can_send_messages* permission."""
|
||||
until_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
|
||||
"""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"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="restrictChatMember", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from ..types import ChatInviteLink
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class RevokeChatInviteLink(TelegramMethod[ChatInviteLink]):
|
||||
|
|
@ -17,13 +14,9 @@ class RevokeChatInviteLink(TelegramMethod[ChatInviteLink]):
|
|||
"""
|
||||
|
||||
__returning__ = ChatInviteLink
|
||||
__api_method__ = "revokeChatInviteLink"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier of the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
invite_link: str
|
||||
"""The invite link to revoke"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="revokeChatInviteLink", data=data)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
UNSET_PARSE_MODE,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -12,10 +12,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_file, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendAnimation(TelegramMethod[Message]):
|
||||
|
|
@ -26,6 +24,7 @@ class SendAnimation(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendAnimation"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -43,7 +42,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: Optional[str] = UNSET_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*"""
|
||||
|
|
@ -51,7 +50,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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -61,16 +60,3 @@ class SendAnimation(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"animation", "thumb"})
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="caption_entities"
|
||||
)
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="animation", value=self.animation)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendAnimation", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
UNSET_PARSE_MODE,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -12,10 +12,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_file, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendAudio(TelegramMethod[Message]):
|
||||
|
|
@ -27,6 +25,7 @@ class SendAudio(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendAudio"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -36,7 +35,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: Optional[str] = UNSET_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*"""
|
||||
|
|
@ -50,7 +49,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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -60,16 +59,3 @@ class SendAudio(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"audio", "thumb"})
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="caption_entities"
|
||||
)
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="audio", value=self.audio)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendAudio", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendChatAction(TelegramMethod[bool]):
|
||||
|
|
@ -20,6 +17,7 @@ class SendChatAction(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "sendChatAction"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -27,8 +25,3 @@ class SendChatAction(TelegramMethod[bool]):
|
|||
"""Type of action to broadcast. Choose one, depending on what the user is about to receive: *typing* for `text messages <https://core.telegram.org/bots/api#sendmessage>`_, *upload_photo* for `photos <https://core.telegram.org/bots/api#sendphoto>`_, *record_video* or *upload_video* for `videos <https://core.telegram.org/bots/api#sendvideo>`_, *record_voice* or *upload_voice* for `voice notes <https://core.telegram.org/bots/api#sendvoice>`_, *upload_document* for `general files <https://core.telegram.org/bots/api#senddocument>`_, *choose_sticker* for `stickers <https://core.telegram.org/bots/api#sendsticker>`_, *find_location* for `location data <https://core.telegram.org/bots/api#sendlocation>`_, *record_video_note* or *upload_video_note* for `video notes <https://core.telegram.org/bots/api#sendvideonote>`_."""
|
||||
message_thread_id: Optional[int] = None
|
||||
"""Unique identifier for the target message thread; supergroups only"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="sendChatAction", data=data)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
ForceReply,
|
||||
|
|
@ -9,10 +9,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendContact(TelegramMethod[Message]):
|
||||
|
|
@ -23,6 +21,7 @@ class SendContact(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendContact"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -38,7 +37,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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -48,8 +47,3 @@ class SendContact(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="sendContact", data=data)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
ForceReply,
|
||||
|
|
@ -9,10 +9,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendDice(TelegramMethod[Message]):
|
||||
|
|
@ -23,6 +21,7 @@ class SendDice(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendDice"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -32,7 +31,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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -42,8 +41,3 @@ class SendDice(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="sendDice", data=data)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
UNSET_PARSE_MODE,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -12,10 +12,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_file, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendDocument(TelegramMethod[Message]):
|
||||
|
|
@ -26,6 +24,7 @@ class SendDocument(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendDocument"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -37,7 +36,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: Optional[str] = UNSET_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*"""
|
||||
|
|
@ -45,7 +44,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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -55,16 +54,3 @@ class SendDocument(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"document", "thumb"})
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="caption_entities"
|
||||
)
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="document", value=self.document)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendDocument", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from ..types import InlineKeyboardMarkup, Message
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendGame(TelegramMethod[Message]):
|
||||
|
|
@ -17,6 +15,7 @@ class SendGame(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendGame"
|
||||
|
||||
chat_id: int
|
||||
"""Unique identifier for the target chat"""
|
||||
|
|
@ -26,7 +25,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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -34,8 +33,3 @@ class SendGame(TelegramMethod[Message]):
|
|||
"""Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="sendGame", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import InlineKeyboardMarkup, LabeledPrice, Message
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendInvoice(TelegramMethod[Message]):
|
||||
|
|
@ -17,6 +15,7 @@ class SendInvoice(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendInvoice"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -66,7 +65,7 @@ class SendInvoice(TelegramMethod[Message]):
|
|||
"""Pass :code:`True` if the final price depends on the shipping method"""
|
||||
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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -74,8 +73,3 @@ class SendInvoice(TelegramMethod[Message]):
|
|||
"""Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="sendInvoice", data=data)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
ForceReply,
|
||||
|
|
@ -9,10 +9,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendLocation(TelegramMethod[Message]):
|
||||
|
|
@ -23,6 +21,7 @@ class SendLocation(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendLocation"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -42,7 +41,7 @@ class SendLocation(TelegramMethod[Message]):
|
|||
"""For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified."""
|
||||
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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -52,8 +51,3 @@ class SendLocation(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="sendLocation", data=data)
|
||||
|
|
|
|||
|
|
@ -1,19 +1,16 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
InputFile,
|
||||
InputMediaAudio,
|
||||
InputMediaDocument,
|
||||
InputMediaPhoto,
|
||||
InputMediaVideo,
|
||||
Message,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_input_media, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendMediaGroup(TelegramMethod[List[Message]]):
|
||||
|
|
@ -24,6 +21,7 @@ class SendMediaGroup(TelegramMethod[List[Message]]):
|
|||
"""
|
||||
|
||||
__returning__ = List[Message]
|
||||
__api_method__ = "sendMediaGroup"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -33,18 +31,9 @@ class SendMediaGroup(TelegramMethod[List[Message]]):
|
|||
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Sends messages `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
|
||||
protect_content: Optional[bool] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent messages from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the messages are a reply, ID of the original message"""
|
||||
allow_sending_without_reply: Optional[bool] = None
|
||||
"""Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
prepare_parse_mode(bot, data["media"])
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_input_media(data, files)
|
||||
|
||||
return Request(method="sendMediaGroup", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
UNSET_PARSE_MODE,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
Message,
|
||||
|
|
@ -11,10 +11,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW, UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendMessage(TelegramMethod[Message]):
|
||||
|
|
@ -25,6 +23,7 @@ class SendMessage(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendMessage"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -32,15 +31,15 @@ class SendMessage(TelegramMethod[Message]):
|
|||
"""Text of the message to be sent, 1-4096 characters after entities parsing"""
|
||||
message_thread_id: Optional[int] = None
|
||||
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
parse_mode: Optional[str] = UNSET_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*"""
|
||||
disable_web_page_preview: Optional[bool] = None
|
||||
disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW
|
||||
"""Disables link previews for links in this message"""
|
||||
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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -50,12 +49,3 @@ class SendMessage(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="entities"
|
||||
)
|
||||
|
||||
return Request(method="sendMessage", data=data)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
UNSET_PARSE_MODE,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -12,10 +12,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_file, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendPhoto(TelegramMethod[Message]):
|
||||
|
|
@ -26,6 +24,7 @@ class SendPhoto(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendPhoto"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -35,7 +34,7 @@ class SendPhoto(TelegramMethod[Message]):
|
|||
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
|
||||
caption: Optional[str] = None
|
||||
"""Photo caption (may also be used when resending photos by *file_id*), 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
parse_mode: Optional[str] = UNSET_PARSE_MODE
|
||||
"""Mode for parsing entities in the photo 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*"""
|
||||
|
|
@ -43,7 +42,7 @@ class SendPhoto(TelegramMethod[Message]):
|
|||
"""Pass :code:`True` if the photo 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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -53,15 +52,3 @@ class SendPhoto(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"photo"})
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="caption_entities"
|
||||
)
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="photo", value=self.photo)
|
||||
|
||||
return Request(method="sendPhoto", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
UNSET_PARSE_MODE,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
Message,
|
||||
|
|
@ -12,10 +12,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendPoll(TelegramMethod[Message]):
|
||||
|
|
@ -26,6 +24,7 @@ class SendPoll(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendPoll"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -45,7 +44,7 @@ class SendPoll(TelegramMethod[Message]):
|
|||
"""0-based identifier of the correct answer option, required for polls in quiz mode"""
|
||||
explanation: Optional[str] = None
|
||||
"""Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing"""
|
||||
explanation_parse_mode: Optional[str] = UNSET
|
||||
explanation_parse_mode: Optional[str] = UNSET_PARSE_MODE
|
||||
"""Mode for parsing entities in the explanation. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
|
||||
explanation_entities: Optional[List[MessageEntity]] = None
|
||||
"""A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of *parse_mode*"""
|
||||
|
|
@ -57,7 +56,7 @@ class SendPoll(TelegramMethod[Message]):
|
|||
"""Pass :code:`True` if the poll needs to be immediately closed. This can be useful for poll preview."""
|
||||
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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -67,15 +66,3 @@ class SendPoll(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
prepare_parse_mode(
|
||||
bot,
|
||||
data,
|
||||
parse_mode_property="explanation_parse_mode",
|
||||
entities_property="explanation_entities",
|
||||
)
|
||||
|
||||
return Request(method="sendPoll", data=data)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
ForceReply,
|
||||
|
|
@ -10,10 +10,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_file
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendSticker(TelegramMethod[Message]):
|
||||
|
|
@ -24,6 +22,7 @@ class SendSticker(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendSticker"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -35,7 +34,7 @@ class SendSticker(TelegramMethod[Message]):
|
|||
"""Emoji associated with the sticker; only for just uploaded stickers"""
|
||||
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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -45,11 +44,3 @@ class SendSticker(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"sticker"})
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="sticker", value=self.sticker)
|
||||
|
||||
return Request(method="sendSticker", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
ForceReply,
|
||||
|
|
@ -9,10 +9,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendVenue(TelegramMethod[Message]):
|
||||
|
|
@ -23,6 +21,7 @@ class SendVenue(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendVenue"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -46,7 +45,7 @@ class SendVenue(TelegramMethod[Message]):
|
|||
"""Google Places type of the venue. (See `supported types <https://developers.google.com/places/web-service/supported_types>`_.)"""
|
||||
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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -56,8 +55,3 @@ class SendVenue(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="sendVenue", data=data)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
UNSET_PARSE_MODE,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -12,10 +12,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_file, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendVideo(TelegramMethod[Message]):
|
||||
|
|
@ -26,6 +24,7 @@ class SendVideo(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendVideo"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -43,7 +42,7 @@ class SendVideo(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
|
||||
"""Video caption (may also be used when resending videos by *file_id*), 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
parse_mode: Optional[str] = UNSET_PARSE_MODE
|
||||
"""Mode for parsing entities in the video 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 +52,7 @@ class SendVideo(TelegramMethod[Message]):
|
|||
"""Pass :code:`True` if the uploaded video is suitable for streaming"""
|
||||
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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -63,16 +62,3 @@ class SendVideo(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"video", "thumb"})
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="caption_entities"
|
||||
)
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="video", value=self.video)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendVideo", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
ForceReply,
|
||||
|
|
@ -10,10 +10,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_file
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendVideoNote(TelegramMethod[Message]):
|
||||
|
|
@ -24,6 +22,7 @@ class SendVideoNote(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendVideoNote"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -39,7 +38,7 @@ class SendVideoNote(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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -49,12 +48,3 @@ class SendVideoNote(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"video_note", "thumb"})
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="video_note", value=self.video_note)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendVideoNote", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
UNSET_PARSE_MODE,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -12,10 +12,8 @@ from ..types import (
|
|||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
)
|
||||
from .base import Request, TelegramMethod, prepare_file, prepare_parse_mode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from ..types.base import UNSET_PROTECT_CONTENT
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendVoice(TelegramMethod[Message]):
|
||||
|
|
@ -26,6 +24,7 @@ class SendVoice(TelegramMethod[Message]):
|
|||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendVoice"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
|
|
@ -35,7 +34,7 @@ class SendVoice(TelegramMethod[Message]):
|
|||
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
|
||||
caption: Optional[str] = None
|
||||
"""Voice message caption, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
parse_mode: Optional[str] = UNSET_PARSE_MODE
|
||||
"""Mode for parsing entities in the voice 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*"""
|
||||
|
|
@ -43,7 +42,7 @@ class SendVoice(TelegramMethod[Message]):
|
|||
"""Duration of the voice message in seconds"""
|
||||
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] = None
|
||||
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
"""If the message is a reply, ID of the original message"""
|
||||
|
|
@ -53,15 +52,3 @@ class SendVoice(TelegramMethod[Message]):
|
|||
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
|
||||
] = None
|
||||
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"voice"})
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data, parse_mode_property="parse_mode", entities_property="caption_entities"
|
||||
)
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="voice", value=self.voice)
|
||||
|
||||
return Request(method="sendVoice", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetChatAdministratorCustomTitle(TelegramMethod[bool]):
|
||||
|
|
@ -16,6 +13,7 @@ class SetChatAdministratorCustomTitle(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setChatAdministratorCustomTitle"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
|
@ -23,8 +21,3 @@ class SetChatAdministratorCustomTitle(TelegramMethod[bool]):
|
|||
"""Unique identifier of the target user"""
|
||||
custom_title: str
|
||||
"""New custom title for the administrator; 0-16 characters, emoji are not allowed"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setChatAdministratorCustomTitle", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetChatDescription(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class SetChatDescription(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setChatDescription"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
description: Optional[str] = None
|
||||
"""New chat description, 0-255 characters"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setChatDescription", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetChatMenuButton(TelegramMethod[bool]):
|
||||
|
|
@ -17,13 +14,9 @@ class SetChatMenuButton(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setChatMenuButton"
|
||||
|
||||
chat_id: Optional[int] = None
|
||||
"""Unique identifier for the target private chat. If not specified, default bot's menu button will be changed"""
|
||||
menu_button: Optional[Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands]] = None
|
||||
"""A JSON-serialized object for the bot's new menu button. Defaults to :class:`aiogram.types.menu_button_default.MenuButtonDefault`"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setChatMenuButton", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import ChatPermissions
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetChatPermissions(TelegramMethod[bool]):
|
||||
|
|
@ -17,6 +14,7 @@ class SetChatPermissions(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setChatPermissions"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
|
|
@ -24,8 +22,3 @@ class SetChatPermissions(TelegramMethod[bool]):
|
|||
"""A JSON-serialized object for new default chat permissions"""
|
||||
use_independent_chat_permissions: Optional[bool] = None
|
||||
"""Pass :code:`True` if chat permissions are set independently. Otherwise, the *can_send_other_messages* and *can_add_web_page_previews* permissions will imply the *can_send_messages*, *can_send_audios*, *can_send_documents*, *can_send_photos*, *can_send_videos*, *can_send_video_notes*, and *can_send_voice_notes* permissions; the *can_send_polls* permission will imply the *can_send_messages* permission."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setChatPermissions", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from ..types import InputFile
|
||||
from .base import Request, TelegramMethod, prepare_file
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetChatPhoto(TelegramMethod[bool]):
|
||||
|
|
@ -17,16 +14,9 @@ class SetChatPhoto(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setChatPhoto"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
photo: InputFile
|
||||
"""New chat photo, uploaded using multipart/form-data"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"photo"})
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="photo", value=self.photo)
|
||||
|
||||
return Request(method="setChatPhoto", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetChatStickerSet(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class SetChatStickerSet(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setChatStickerSet"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
|
||||
sticker_set_name: str
|
||||
"""Name of the sticker set to be set as the group sticker set"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setChatStickerSet", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetChatTitle(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class SetChatTitle(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setChatTitle"
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
title: str
|
||||
"""New chat title, 1-128 characters"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setChatTitle", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetCustomEmojiStickerSetThumbnail(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class SetCustomEmojiStickerSetThumbnail(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setCustomEmojiStickerSetThumbnail"
|
||||
|
||||
name: str
|
||||
"""Sticker set name"""
|
||||
custom_emoji_id: Optional[str] = None
|
||||
"""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."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setCustomEmojiStickerSetThumbnail", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from ..types import Message
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetGameScore(TelegramMethod[Union[Message, bool]]):
|
||||
|
|
@ -17,6 +14,7 @@ class SetGameScore(TelegramMethod[Union[Message, bool]]):
|
|||
"""
|
||||
|
||||
__returning__ = Union[Message, bool]
|
||||
__api_method__ = "setGameScore"
|
||||
|
||||
user_id: int
|
||||
"""User identifier"""
|
||||
|
|
@ -32,8 +30,3 @@ class SetGameScore(TelegramMethod[Union[Message, bool]]):
|
|||
"""Required if *inline_message_id* is not specified. Identifier of the sent message"""
|
||||
inline_message_id: Optional[str] = None
|
||||
"""Required if *chat_id* and *message_id* are not specified. Identifier of the inline message"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setGameScore", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from ..types import BotCommand, BotCommandScope
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetMyCommands(TelegramMethod[bool]):
|
||||
|
|
@ -17,6 +14,7 @@ class SetMyCommands(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setMyCommands"
|
||||
|
||||
commands: List[BotCommand]
|
||||
"""A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified."""
|
||||
|
|
@ -24,8 +22,3 @@ class SetMyCommands(TelegramMethod[bool]):
|
|||
"""A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to :class:`aiogram.types.bot_command_scope_default.BotCommandScopeDefault`."""
|
||||
language_code: Optional[str] = None
|
||||
"""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"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setMyCommands", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from ..types import ChatAdministratorRights
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetMyDefaultAdministratorRights(TelegramMethod[bool]):
|
||||
|
|
@ -17,13 +14,9 @@ class SetMyDefaultAdministratorRights(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setMyDefaultAdministratorRights"
|
||||
|
||||
rights: Optional[ChatAdministratorRights] = None
|
||||
"""A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared."""
|
||||
for_channels: Optional[bool] = None
|
||||
"""Pass :code:`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."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setMyDefaultAdministratorRights", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetMyDescription(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class SetMyDescription(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setMyDescription"
|
||||
|
||||
description: Optional[str] = None
|
||||
"""New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language."""
|
||||
language_code: Optional[str] = None
|
||||
"""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."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setMyDescription", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetMyShortDescription(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class SetMyShortDescription(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setMyShortDescription"
|
||||
|
||||
short_description: Optional[str] = None
|
||||
"""New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language."""
|
||||
language_code: Optional[str] = None
|
||||
"""A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setMyShortDescription", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
from ..types import PassportElementError
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetPassportDataErrors(TelegramMethod[bool]):
|
||||
|
|
@ -18,13 +15,9 @@ class SetPassportDataErrors(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setPassportDataErrors"
|
||||
|
||||
user_id: int
|
||||
"""User identifier"""
|
||||
errors: List[PassportElementError]
|
||||
"""A JSON-serialized array describing the errors"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setPassportDataErrors", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetStickerEmojiList(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class SetStickerEmojiList(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setStickerEmojiList"
|
||||
|
||||
sticker: str
|
||||
"""File identifier of the sticker"""
|
||||
emoji_list: List[str]
|
||||
"""A JSON-serialized list of 1-20 emoji associated with the sticker"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setStickerEmojiList", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetStickerKeywords(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class SetStickerKeywords(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setStickerKeywords"
|
||||
|
||||
sticker: str
|
||||
"""File identifier of the sticker"""
|
||||
keywords: Optional[List[str]] = None
|
||||
"""A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setStickerKeywords", data=data)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from ..types import MaskPosition
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetStickerMaskPosition(TelegramMethod[bool]):
|
||||
|
|
@ -17,13 +14,9 @@ class SetStickerMaskPosition(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setStickerMaskPosition"
|
||||
|
||||
sticker: str
|
||||
"""File identifier of the sticker"""
|
||||
mask_position: Optional[MaskPosition] = None
|
||||
"""A JSON-serialized object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setStickerMaskPosition", data=data)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SetStickerPositionInSet(TelegramMethod[bool]):
|
||||
|
|
@ -16,13 +13,9 @@ class SetStickerPositionInSet(TelegramMethod[bool]):
|
|||
"""
|
||||
|
||||
__returning__ = bool
|
||||
__api_method__ = "setStickerPositionInSet"
|
||||
|
||||
sticker: str
|
||||
"""File identifier of the sticker"""
|
||||
position: int
|
||||
"""New sticker position in the set, zero-based"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setStickerPositionInSet", data=data)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue