mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Update default parse_mode propagation.
This commit is contained in:
parent
4d631a3069
commit
f5684aef07
80 changed files with 552 additions and 185 deletions
|
|
@ -147,6 +147,10 @@ class Bot(ContextInstanceMixin["Bot"]):
|
||||||
self.parse_mode = parse_mode
|
self.parse_mode = parse_mode
|
||||||
self.__token = token
|
self.__token = token
|
||||||
|
|
||||||
|
@property
|
||||||
|
def token(self) -> str:
|
||||||
|
return self.__token
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self) -> int:
|
def id(self) -> int:
|
||||||
"""
|
"""
|
||||||
|
|
@ -278,7 +282,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
||||||
:param method:
|
:param method:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
return await self.session.make_request(self.__token, method, timeout=request_timeout)
|
return await self.session.make_request(self, method, timeout=request_timeout)
|
||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self) -> int:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import (
|
from typing import (
|
||||||
|
TYPE_CHECKING,
|
||||||
Any,
|
Any,
|
||||||
AsyncGenerator,
|
AsyncGenerator,
|
||||||
Dict,
|
Dict,
|
||||||
|
|
@ -20,6 +21,9 @@ from aiogram.api.methods import Request, TelegramMethod
|
||||||
|
|
||||||
from .base import BaseSession
|
from .base import BaseSession
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..bot import Bot
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
_ProxyBasic = Union[str, Tuple[str, BasicAuth]]
|
_ProxyBasic = Union[str, Tuple[str, BasicAuth]]
|
||||||
_ProxyChain = Iterable[_ProxyBasic]
|
_ProxyChain = Iterable[_ProxyBasic]
|
||||||
|
|
@ -126,12 +130,12 @@ class AiohttpSession(BaseSession):
|
||||||
return form
|
return form
|
||||||
|
|
||||||
async def make_request(
|
async def make_request(
|
||||||
self, token: str, call: TelegramMethod[T], timeout: Optional[int] = None
|
self, bot: Bot, call: TelegramMethod[T], timeout: Optional[int] = None
|
||||||
) -> T:
|
) -> T:
|
||||||
session = await self.create_session()
|
session = await self.create_session()
|
||||||
|
|
||||||
request = call.build_request()
|
request = call.build_request(bot)
|
||||||
url = self.api.api_url(token=token, method=request.method)
|
url = self.api.api_url(token=bot.token, method=request.method)
|
||||||
form = self.build_form_data(request)
|
form = self.build_form_data(request)
|
||||||
|
|
||||||
async with session.post(
|
async with session.post(
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,17 @@ import abc
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import Any, AsyncGenerator, Callable, ClassVar, Optional, Type, TypeVar, Union
|
from typing import (
|
||||||
|
TYPE_CHECKING,
|
||||||
|
Any,
|
||||||
|
AsyncGenerator,
|
||||||
|
Callable,
|
||||||
|
ClassVar,
|
||||||
|
Optional,
|
||||||
|
Type,
|
||||||
|
TypeVar,
|
||||||
|
Union,
|
||||||
|
)
|
||||||
|
|
||||||
from aiogram.utils.exceptions import TelegramAPIError
|
from aiogram.utils.exceptions import TelegramAPIError
|
||||||
|
|
||||||
|
|
@ -13,6 +23,9 @@ from ...methods import Response, TelegramMethod
|
||||||
from ...types import UNSET
|
from ...types import UNSET
|
||||||
from ..telegram import PRODUCTION, TelegramAPIServer
|
from ..telegram import PRODUCTION, TelegramAPIServer
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..bot import Bot
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
_JsonLoads = Callable[..., Any]
|
_JsonLoads = Callable[..., Any]
|
||||||
_JsonDumps = Callable[..., str]
|
_JsonDumps = Callable[..., str]
|
||||||
|
|
@ -37,7 +50,7 @@ class BaseSession(abc.ABC):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
async def make_request(
|
async def make_request(
|
||||||
self, token: str, method: TelegramMethod[T], timeout: Optional[int] = UNSET
|
self, bot: Bot, method: TelegramMethod[T], timeout: Optional[int] = UNSET
|
||||||
) -> T: # pragma: no cover
|
) -> T: # pragma: no cover
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import InputFile, MaskPosition
|
from ..types import InputFile, MaskPosition
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class AddStickerToSet(TelegramMethod[bool]):
|
class AddStickerToSet(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -34,7 +39,7 @@ class AddStickerToSet(TelegramMethod[bool]):
|
||||||
mask_position: Optional[MaskPosition] = None
|
mask_position: Optional[MaskPosition] = None
|
||||||
"""A JSON-serialized object for position where the mask should be placed on faces"""
|
"""A JSON-serialized object for position where the mask should be placed on faces"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker"})
|
data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class AnswerCallbackQuery(TelegramMethod[bool]):
|
class AnswerCallbackQuery(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -33,7 +38,7 @@ class AnswerCallbackQuery(TelegramMethod[bool]):
|
||||||
"""The maximum amount of time in seconds that the result of the callback query may be cached
|
"""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."""
|
client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="answerCallbackQuery", data=data)
|
return Request(method="answerCallbackQuery", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||||
|
|
||||||
from ..types import InlineQueryResult
|
from ..types import InlineQueryResult
|
||||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class AnswerInlineQuery(TelegramMethod[bool]):
|
class AnswerInlineQuery(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -36,8 +41,8 @@ class AnswerInlineQuery(TelegramMethod[bool]):
|
||||||
"""Deep-linking parameter for the /start message sent to the bot when user presses the switch
|
"""Deep-linking parameter for the /start message sent to the bot when user presses the switch
|
||||||
button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed."""
|
button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
prepare_parse_mode(data["results"])
|
prepare_parse_mode(bot, data["results"])
|
||||||
|
|
||||||
return Request(method="answerInlineQuery", data=data)
|
return Request(method="answerInlineQuery", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class AnswerPreCheckoutQuery(TelegramMethod[bool]):
|
class AnswerPreCheckoutQuery(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -26,7 +31,7 @@ class AnswerPreCheckoutQuery(TelegramMethod[bool]):
|
||||||
amazing black T-shirts while you were busy filling out your payment details. Please choose
|
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."""
|
a different color or garment!"). Telegram will display this message to the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="answerPreCheckoutQuery", data=data)
|
return Request(method="answerPreCheckoutQuery", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||||
|
|
||||||
from ..types import ShippingOption
|
from ..types import ShippingOption
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class AnswerShippingQuery(TelegramMethod[bool]):
|
class AnswerShippingQuery(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -27,7 +32,7 @@ class AnswerShippingQuery(TelegramMethod[bool]):
|
||||||
impossible to complete the order (e.g. "Sorry, delivery to your desired address is
|
impossible to complete the order (e.g. "Sorry, delivery to your desired address is
|
||||||
unavailable'). Telegram will display this message to the user."""
|
unavailable'). Telegram will display this message to the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="answerShippingQuery", data=data)
|
return Request(method="answerShippingQuery", data=data)
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[T]):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def build_request(self) -> Request: # pragma: no cover
|
def build_request(self, bot: Bot) -> Request: # pragma: no cover
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def dict(self, **kwargs: Any) -> Any:
|
def dict(self, **kwargs: Any) -> Any:
|
||||||
|
|
@ -125,7 +125,7 @@ def prepare_media_file(data: Dict[str, Any], files: Dict[str, InputFile]) -> Non
|
||||||
data["media"]["media"] = f"attach://{tag}"
|
data["media"]["media"] = f"attach://{tag}"
|
||||||
|
|
||||||
|
|
||||||
def prepare_parse_mode(root: Any, parse_mode_property: str = "parse_mode") -> None:
|
def prepare_parse_mode(bot: Bot, root: Any, parse_mode_property: str = "parse_mode") -> None:
|
||||||
"""
|
"""
|
||||||
Find and set parse_mode with highest priority.
|
Find and set parse_mode with highest priority.
|
||||||
|
|
||||||
|
|
@ -136,14 +136,9 @@ def prepare_parse_mode(root: Any, parse_mode_property: str = "parse_mode") -> No
|
||||||
"""
|
"""
|
||||||
if isinstance(root, list):
|
if isinstance(root, list):
|
||||||
for item in root:
|
for item in root:
|
||||||
prepare_parse_mode(item, parse_mode_property=parse_mode_property)
|
prepare_parse_mode(bot=bot, root=item, parse_mode_property=parse_mode_property)
|
||||||
return
|
elif root.get(parse_mode_property, UNSET) is UNSET:
|
||||||
|
if bot.parse_mode:
|
||||||
if root.get(parse_mode_property, UNSET) is UNSET:
|
|
||||||
from ..client.bot import Bot
|
|
||||||
|
|
||||||
bot = Bot.get_current(no_error=True)
|
|
||||||
if bot and bot.parse_mode:
|
|
||||||
root[parse_mode_property] = bot.parse_mode
|
root[parse_mode_property] = bot.parse_mode
|
||||||
else:
|
else:
|
||||||
root[parse_mode_property] = None
|
root[parse_mode_property] = None
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import InputFile, MaskPosition
|
from ..types import InputFile, MaskPosition
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class CreateNewStickerSet(TelegramMethod[bool]):
|
class CreateNewStickerSet(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -40,7 +45,7 @@ class CreateNewStickerSet(TelegramMethod[bool]):
|
||||||
mask_position: Optional[MaskPosition] = None
|
mask_position: Optional[MaskPosition] = None
|
||||||
"""A JSON-serialized object for position where the mask should be placed on faces"""
|
"""A JSON-serialized object for position where the mask should be placed on faces"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker"})
|
data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class DeleteChatPhoto(TelegramMethod[bool]):
|
class DeleteChatPhoto(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -18,7 +23,7 @@ class DeleteChatPhoto(TelegramMethod[bool]):
|
||||||
"""Unique identifier for the target chat or username of the target channel (in the format
|
"""Unique identifier for the target chat or username of the target channel (in the format
|
||||||
@channelusername)"""
|
@channelusername)"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="deleteChatPhoto", data=data)
|
return Request(method="deleteChatPhoto", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class DeleteChatStickerSet(TelegramMethod[bool]):
|
class DeleteChatStickerSet(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -19,7 +24,7 @@ class DeleteChatStickerSet(TelegramMethod[bool]):
|
||||||
"""Unique identifier for the target chat or username of the target supergroup (in the format
|
"""Unique identifier for the target chat or username of the target supergroup (in the format
|
||||||
@supergroupusername)"""
|
@supergroupusername)"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="deleteChatStickerSet", data=data)
|
return Request(method="deleteChatStickerSet", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class DeleteMessage(TelegramMethod[bool]):
|
class DeleteMessage(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -28,7 +33,7 @@ class DeleteMessage(TelegramMethod[bool]):
|
||||||
message_id: int
|
message_id: int
|
||||||
"""Identifier of the message to delete"""
|
"""Identifier of the message to delete"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="deleteMessage", data=data)
|
return Request(method="deleteMessage", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class DeleteStickerFromSet(TelegramMethod[bool]):
|
class DeleteStickerFromSet(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -15,7 +20,7 @@ class DeleteStickerFromSet(TelegramMethod[bool]):
|
||||||
sticker: str
|
sticker: str
|
||||||
"""File identifier of the sticker"""
|
"""File identifier of the sticker"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="deleteStickerFromSet", data=data)
|
return Request(method="deleteStickerFromSet", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class DeleteWebhook(TelegramMethod[bool]):
|
class DeleteWebhook(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -13,7 +18,7 @@ class DeleteWebhook(TelegramMethod[bool]):
|
||||||
|
|
||||||
__returning__ = bool
|
__returning__ = bool
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="deleteWebhook", data=data)
|
return Request(method="deleteWebhook", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import UNSET, InlineKeyboardMarkup, Message
|
from ..types import UNSET, InlineKeyboardMarkup, Message
|
||||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
|
class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -28,8 +33,8 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
|
||||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||||
"""A JSON-serialized object for an inline keyboard."""
|
"""A JSON-serialized object for an inline keyboard."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
prepare_parse_mode(data)
|
prepare_parse_mode(bot, data)
|
||||||
|
|
||||||
return Request(method="editMessageCaption", data=data)
|
return Request(method="editMessageCaption", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import InlineKeyboardMarkup, Message
|
from ..types import InlineKeyboardMarkup, Message
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class EditMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
class EditMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -30,7 +35,7 @@ class EditMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
||||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||||
"""A JSON-serialized object for a new inline keyboard."""
|
"""A JSON-serialized object for a new inline keyboard."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="editMessageLiveLocation", data=data)
|
return Request(method="editMessageLiveLocation", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import InlineKeyboardMarkup, InputFile, InputMedia, Message
|
from ..types import InlineKeyboardMarkup, InputFile, InputMedia, Message
|
||||||
from .base import Request, TelegramMethod, prepare_media_file, prepare_parse_mode
|
from .base import Request, TelegramMethod, prepare_media_file, prepare_parse_mode
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class EditMessageMedia(TelegramMethod[Union[Message, bool]]):
|
class EditMessageMedia(TelegramMethod[Union[Message, bool]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -30,9 +35,9 @@ class EditMessageMedia(TelegramMethod[Union[Message, bool]]):
|
||||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||||
"""A JSON-serialized object for a new inline keyboard."""
|
"""A JSON-serialized object for a new inline keyboard."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
prepare_parse_mode(data["media"])
|
prepare_parse_mode(bot, data["media"])
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
prepare_media_file(data=data, files=files)
|
prepare_media_file(data=data, files=files)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import InlineKeyboardMarkup, Message
|
from ..types import InlineKeyboardMarkup, Message
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class EditMessageReplyMarkup(TelegramMethod[Union[Message, bool]]):
|
class EditMessageReplyMarkup(TelegramMethod[Union[Message, bool]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -24,7 +29,7 @@ class EditMessageReplyMarkup(TelegramMethod[Union[Message, bool]]):
|
||||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||||
"""A JSON-serialized object for an inline keyboard."""
|
"""A JSON-serialized object for an inline keyboard."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="editMessageReplyMarkup", data=data)
|
return Request(method="editMessageReplyMarkup", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import UNSET, InlineKeyboardMarkup, Message
|
from ..types import UNSET, InlineKeyboardMarkup, Message
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class EditMessageText(TelegramMethod[Union[Message, bool]]):
|
class EditMessageText(TelegramMethod[Union[Message, bool]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -30,7 +35,7 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
|
||||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||||
"""A JSON-serialized object for an inline keyboard."""
|
"""A JSON-serialized object for an inline keyboard."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="editMessageText", data=data)
|
return Request(method="editMessageText", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class ExportChatInviteLink(TelegramMethod[str]):
|
class ExportChatInviteLink(TelegramMethod[str]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -23,7 +28,7 @@ class ExportChatInviteLink(TelegramMethod[str]):
|
||||||
"""Unique identifier for the target chat or username of the target channel (in the format
|
"""Unique identifier for the target chat or username of the target channel (in the format
|
||||||
@channelusername)"""
|
@channelusername)"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="exportChatInviteLink", data=data)
|
return Request(method="exportChatInviteLink", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import Message
|
from ..types import Message
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class ForwardMessage(TelegramMethod[Message]):
|
class ForwardMessage(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -24,7 +29,7 @@ class ForwardMessage(TelegramMethod[Message]):
|
||||||
disable_notification: Optional[bool] = None
|
disable_notification: Optional[bool] = None
|
||||||
"""Sends the message silently. Users will receive a notification with no sound."""
|
"""Sends the message silently. Users will receive a notification with no sound."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="forwardMessage", data=data)
|
return Request(method="forwardMessage", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from ..types import Chat
|
from ..types import Chat
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetChat(TelegramMethod[Chat]):
|
class GetChat(TelegramMethod[Chat]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -19,7 +24,7 @@ class GetChat(TelegramMethod[Chat]):
|
||||||
"""Unique identifier for the target chat or username of the target supergroup or channel (in
|
"""Unique identifier for the target chat or username of the target supergroup or channel (in
|
||||||
the format @channelusername)"""
|
the format @channelusername)"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getChat", data=data)
|
return Request(method="getChat", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List, Union
|
||||||
|
|
||||||
from ..types import ChatMember
|
from ..types import ChatMember
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetChatAdministrators(TelegramMethod[List[ChatMember]]):
|
class GetChatAdministrators(TelegramMethod[List[ChatMember]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -20,7 +25,7 @@ class GetChatAdministrators(TelegramMethod[List[ChatMember]]):
|
||||||
"""Unique identifier for the target chat or username of the target supergroup or channel (in
|
"""Unique identifier for the target chat or username of the target supergroup or channel (in
|
||||||
the format @channelusername)"""
|
the format @channelusername)"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getChatAdministrators", data=data)
|
return Request(method="getChatAdministrators", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from ..types import ChatMember
|
from ..types import ChatMember
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetChatMember(TelegramMethod[ChatMember]):
|
class GetChatMember(TelegramMethod[ChatMember]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -20,7 +25,7 @@ class GetChatMember(TelegramMethod[ChatMember]):
|
||||||
user_id: int
|
user_id: int
|
||||||
"""Unique identifier of the target user"""
|
"""Unique identifier of the target user"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getChatMember", data=data)
|
return Request(method="getChatMember", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetChatMembersCount(TelegramMethod[int]):
|
class GetChatMembersCount(TelegramMethod[int]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -16,7 +21,7 @@ class GetChatMembersCount(TelegramMethod[int]):
|
||||||
"""Unique identifier for the target chat or username of the target supergroup or channel (in
|
"""Unique identifier for the target chat or username of the target supergroup or channel (in
|
||||||
the format @channelusername)"""
|
the format @channelusername)"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getChatMembersCount", data=data)
|
return Request(method="getChatMembersCount", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict
|
||||||
|
|
||||||
from ..types import File
|
from ..types import File
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetFile(TelegramMethod[File]):
|
class GetFile(TelegramMethod[File]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -22,7 +27,7 @@ class GetFile(TelegramMethod[File]):
|
||||||
file_id: str
|
file_id: str
|
||||||
"""File identifier to get info about"""
|
"""File identifier to get info about"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getFile", data=data)
|
return Request(method="getFile", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||||
|
|
||||||
from ..types import GameHighScore
|
from ..types import GameHighScore
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetGameHighScores(TelegramMethod[List[GameHighScore]]):
|
class GetGameHighScores(TelegramMethod[List[GameHighScore]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -27,7 +32,7 @@ class GetGameHighScores(TelegramMethod[List[GameHighScore]]):
|
||||||
inline_message_id: Optional[str] = None
|
inline_message_id: Optional[str] = None
|
||||||
"""Required if chat_id and message_id are not specified. Identifier of the inline message"""
|
"""Required if chat_id and message_id are not specified. Identifier of the inline message"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getGameHighScores", data=data)
|
return Request(method="getGameHighScores", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict
|
||||||
|
|
||||||
from ..types import User
|
from ..types import User
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetMe(TelegramMethod[User]):
|
class GetMe(TelegramMethod[User]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -14,7 +19,7 @@ class GetMe(TelegramMethod[User]):
|
||||||
|
|
||||||
__returning__ = User
|
__returning__ = User
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getMe", data=data)
|
return Request(method="getMe", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List
|
||||||
|
|
||||||
from ..types import BotCommand
|
from ..types import BotCommand
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetMyCommands(TelegramMethod[List[BotCommand]]):
|
class GetMyCommands(TelegramMethod[List[BotCommand]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -14,7 +19,7 @@ class GetMyCommands(TelegramMethod[List[BotCommand]]):
|
||||||
|
|
||||||
__returning__ = List[BotCommand]
|
__returning__ = List[BotCommand]
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getMyCommands", data=data)
|
return Request(method="getMyCommands", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict
|
||||||
|
|
||||||
from ..types import StickerSet
|
from ..types import StickerSet
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetStickerSet(TelegramMethod[StickerSet]):
|
class GetStickerSet(TelegramMethod[StickerSet]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -16,7 +21,7 @@ class GetStickerSet(TelegramMethod[StickerSet]):
|
||||||
name: str
|
name: str
|
||||||
"""Name of the sticker set"""
|
"""Name of the sticker set"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getStickerSet", data=data)
|
return Request(method="getStickerSet", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||||
|
|
||||||
from ..types import Update
|
from ..types import Update
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetUpdates(TelegramMethod[List[Update]]):
|
class GetUpdates(TelegramMethod[List[Update]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -37,7 +42,7 @@ class GetUpdates(TelegramMethod[List[Update]]):
|
||||||
list to receive all updates regardless of type (default). If not specified, the previous
|
list to receive all updates regardless of type (default). If not specified, the previous
|
||||||
setting will be used."""
|
setting will be used."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getUpdates", data=data)
|
return Request(method="getUpdates", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||||
|
|
||||||
from ..types import UserProfilePhotos
|
from ..types import UserProfilePhotos
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetUserProfilePhotos(TelegramMethod[UserProfilePhotos]):
|
class GetUserProfilePhotos(TelegramMethod[UserProfilePhotos]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -22,7 +27,7 @@ class GetUserProfilePhotos(TelegramMethod[UserProfilePhotos]):
|
||||||
"""Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to
|
"""Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to
|
||||||
100."""
|
100."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getUserProfilePhotos", data=data)
|
return Request(method="getUserProfilePhotos", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict
|
||||||
|
|
||||||
from ..types import WebhookInfo
|
from ..types import WebhookInfo
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class GetWebhookInfo(TelegramMethod[WebhookInfo]):
|
class GetWebhookInfo(TelegramMethod[WebhookInfo]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -15,7 +20,7 @@ class GetWebhookInfo(TelegramMethod[WebhookInfo]):
|
||||||
|
|
||||||
__returning__ = WebhookInfo
|
__returning__ = WebhookInfo
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="getWebhookInfo", data=data)
|
return Request(method="getWebhookInfo", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Any, Dict, Optional, Union
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class KickChatMember(TelegramMethod[bool]):
|
class KickChatMember(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -25,7 +30,7 @@ class KickChatMember(TelegramMethod[bool]):
|
||||||
"""Date when the user will be unbanned, unix time. If user is banned for more than 366 days or
|
"""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"""
|
less than 30 seconds from the current time they are considered to be banned forever"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="kickChatMember", data=data)
|
return Request(method="kickChatMember", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class LeaveChat(TelegramMethod[bool]):
|
class LeaveChat(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -16,7 +21,7 @@ class LeaveChat(TelegramMethod[bool]):
|
||||||
"""Unique identifier for the target chat or username of the target supergroup or channel (in
|
"""Unique identifier for the target chat or username of the target supergroup or channel (in
|
||||||
the format @channelusername)"""
|
the format @channelusername)"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="leaveChat", data=data)
|
return Request(method="leaveChat", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class PinChatMessage(TelegramMethod[bool]):
|
class PinChatMessage(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -23,7 +28,7 @@ class PinChatMessage(TelegramMethod[bool]):
|
||||||
"""Pass True, if it is not necessary to send a notification to all chat members about the new
|
"""Pass 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."""
|
pinned message. Notifications are always disabled in channels."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="pinChatMessage", data=data)
|
return Request(method="pinChatMessage", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class PromoteChatMember(TelegramMethod[bool]):
|
class PromoteChatMember(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -39,7 +44,7 @@ class PromoteChatMember(TelegramMethod[bool]):
|
||||||
privileges or demote administrators that he has promoted, directly or indirectly (promoted
|
privileges or demote administrators that he has promoted, directly or indirectly (promoted
|
||||||
by administrators that were appointed by him)"""
|
by administrators that were appointed by him)"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="promoteChatMember", data=data)
|
return Request(method="promoteChatMember", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,14 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Any, Dict, Optional, Union
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import ChatPermissions
|
from ..types import ChatPermissions
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class RestrictChatMember(TelegramMethod[bool]):
|
class RestrictChatMember(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -28,7 +33,7 @@ class RestrictChatMember(TelegramMethod[bool]):
|
||||||
more than 366 days or less than 30 seconds from the current time, they are considered to be
|
more than 366 days or less than 30 seconds from the current time, they are considered to be
|
||||||
restricted forever"""
|
restricted forever"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="restrictChatMember", data=data)
|
return Request(method="restrictChatMember", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
UNSET,
|
UNSET,
|
||||||
|
|
@ -11,6 +13,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendAnimation(TelegramMethod[Message]):
|
class SendAnimation(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -59,7 +64,7 @@ class SendAnimation(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"animation", "thumb"})
|
data: Dict[str, Any] = self.dict(exclude={"animation", "thumb"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
UNSET,
|
UNSET,
|
||||||
|
|
@ -11,6 +13,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendAudio(TelegramMethod[Message]):
|
class SendAudio(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -59,7 +64,7 @@ class SendAudio(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"audio", "thumb"})
|
data: Dict[str, Any] = self.dict(exclude={"audio", "thumb"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendChatAction(TelegramMethod[bool]):
|
class SendChatAction(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -29,7 +34,7 @@ class SendChatAction(TelegramMethod[bool]):
|
||||||
record_audio or upload_audio for audio files, upload_document for general files,
|
record_audio or upload_audio for audio files, upload_document for general files,
|
||||||
find_location for location data, record_video_note or upload_video_note for video notes."""
|
find_location for location data, record_video_note or upload_video_note for video notes."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="sendChatAction", data=data)
|
return Request(method="sendChatAction", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
ForceReply,
|
ForceReply,
|
||||||
|
|
@ -9,6 +11,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendContact(TelegramMethod[Message]):
|
class SendContact(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -40,7 +45,7 @@ class SendContact(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove keyboard or to force a reply from the user."""
|
keyboard, instructions to remove keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="sendContact", data=data)
|
return Request(method="sendContact", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
ForceReply,
|
ForceReply,
|
||||||
|
|
@ -9,6 +11,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendDice(TelegramMethod[Message]):
|
class SendDice(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -36,7 +41,7 @@ class SendDice(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="sendDice", data=data)
|
return Request(method="sendDice", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
UNSET,
|
UNSET,
|
||||||
|
|
@ -11,6 +13,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendDocument(TelegramMethod[Message]):
|
class SendDocument(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -52,7 +57,7 @@ class SendDocument(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"document", "thumb"})
|
data: Dict[str, Any] = self.dict(exclude={"document", "thumb"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||||
|
|
||||||
from ..types import InlineKeyboardMarkup, Message
|
from ..types import InlineKeyboardMarkup, Message
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendGame(TelegramMethod[Message]):
|
class SendGame(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -26,7 +31,7 @@ class SendGame(TelegramMethod[Message]):
|
||||||
"""A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button
|
"""A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button
|
||||||
will be shown. If not empty, the first button must launch the game."""
|
will be shown. If not empty, the first button must launch the game."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="sendGame", data=data)
|
return Request(method="sendGame", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||||
|
|
||||||
from ..types import InlineKeyboardMarkup, LabeledPrice, Message
|
from ..types import InlineKeyboardMarkup, LabeledPrice, Message
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendInvoice(TelegramMethod[Message]):
|
class SendInvoice(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -66,7 +71,7 @@ class SendInvoice(TelegramMethod[Message]):
|
||||||
"""A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button
|
"""A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button
|
||||||
will be shown. If not empty, the first button must be a Pay button."""
|
will be shown. If not empty, the first button must be a Pay button."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="sendInvoice", data=data)
|
return Request(method="sendInvoice", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
ForceReply,
|
ForceReply,
|
||||||
|
|
@ -9,6 +11,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendLocation(TelegramMethod[Message]):
|
class SendLocation(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -39,7 +44,7 @@ class SendLocation(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="sendLocation", data=data)
|
return Request(method="sendLocation", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
from ..types import InputFile, InputMediaPhoto, InputMediaVideo, Message
|
from ..types import InputFile, InputMediaPhoto, InputMediaVideo, Message
|
||||||
from .base import Request, TelegramMethod, prepare_input_media, prepare_parse_mode
|
from .base import Request, TelegramMethod, prepare_input_media, prepare_parse_mode
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendMediaGroup(TelegramMethod[List[Message]]):
|
class SendMediaGroup(TelegramMethod[List[Message]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -24,9 +29,9 @@ class SendMediaGroup(TelegramMethod[List[Message]]):
|
||||||
reply_to_message_id: Optional[int] = None
|
reply_to_message_id: Optional[int] = None
|
||||||
"""If the messages are a reply, ID of the original message"""
|
"""If the messages are a reply, ID of the original message"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
prepare_parse_mode(data["media"])
|
prepare_parse_mode(bot, data["media"])
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
prepare_input_media(data, files)
|
prepare_input_media(data, files)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
UNSET,
|
UNSET,
|
||||||
|
|
@ -10,6 +12,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendMessage(TelegramMethod[Message]):
|
class SendMessage(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -39,8 +44,8 @@ class SendMessage(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
prepare_parse_mode(data)
|
prepare_parse_mode(bot, data)
|
||||||
|
|
||||||
return Request(method="sendMessage", data=data)
|
return Request(method="sendMessage", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
UNSET,
|
UNSET,
|
||||||
|
|
@ -11,6 +13,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendPhoto(TelegramMethod[Message]):
|
class SendPhoto(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -43,7 +48,7 @@ class SendPhoto(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"photo"})
|
data: Dict[str, Any] = self.dict(exclude={"photo"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
ForceReply,
|
ForceReply,
|
||||||
|
|
@ -10,6 +12,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendPoll(TelegramMethod[Message]):
|
class SendPoll(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -59,8 +64,8 @@ class SendPoll(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
prepare_parse_mode(data, parse_mode_property="explanation_parse_mode")
|
prepare_parse_mode(bot, data, parse_mode_property="explanation_parse_mode")
|
||||||
|
|
||||||
return Request(method="sendPoll", data=data)
|
return Request(method="sendPoll", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
ForceReply,
|
ForceReply,
|
||||||
|
|
@ -10,6 +12,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendSticker(TelegramMethod[Message]):
|
class SendSticker(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -38,7 +43,7 @@ class SendSticker(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"sticker"})
|
data: Dict[str, Any] = self.dict(exclude={"sticker"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
ForceReply,
|
ForceReply,
|
||||||
|
|
@ -9,6 +11,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendVenue(TelegramMethod[Message]):
|
class SendVenue(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -45,7 +50,7 @@ class SendVenue(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="sendVenue", data=data)
|
return Request(method="sendVenue", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
UNSET,
|
UNSET,
|
||||||
|
|
@ -11,6 +13,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendVideo(TelegramMethod[Message]):
|
class SendVideo(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -60,7 +65,7 @@ class SendVideo(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"video", "thumb"})
|
data: Dict[str, Any] = self.dict(exclude={"video", "thumb"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
ForceReply,
|
ForceReply,
|
||||||
|
|
@ -10,6 +12,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendVideoNote(TelegramMethod[Message]):
|
class SendVideoNote(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -49,7 +54,7 @@ class SendVideoNote(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"video_note", "thumb"})
|
data: Dict[str, Any] = self.dict(exclude={"video_note", "thumb"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import (
|
from ..types import (
|
||||||
UNSET,
|
UNSET,
|
||||||
|
|
@ -11,6 +13,9 @@ from ..types import (
|
||||||
)
|
)
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SendVoice(TelegramMethod[Message]):
|
class SendVoice(TelegramMethod[Message]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -49,7 +54,7 @@ class SendVoice(TelegramMethod[Message]):
|
||||||
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
|
||||||
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"voice"})
|
data: Dict[str, Any] = self.dict(exclude={"voice"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetChatAdministratorCustomTitle(TelegramMethod[bool]):
|
class SetChatAdministratorCustomTitle(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -21,7 +26,7 @@ class SetChatAdministratorCustomTitle(TelegramMethod[bool]):
|
||||||
custom_title: str
|
custom_title: str
|
||||||
"""New custom title for the administrator; 0-16 characters, emoji are not allowed"""
|
"""New custom title for the administrator; 0-16 characters, emoji are not allowed"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="setChatAdministratorCustomTitle", data=data)
|
return Request(method="setChatAdministratorCustomTitle", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetChatDescription(TelegramMethod[bool]):
|
class SetChatDescription(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -20,7 +25,7 @@ class SetChatDescription(TelegramMethod[bool]):
|
||||||
description: Optional[str] = None
|
description: Optional[str] = None
|
||||||
"""New chat description, 0-255 characters"""
|
"""New chat description, 0-255 characters"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="setChatDescription", data=data)
|
return Request(method="setChatDescription", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from ..types import ChatPermissions
|
from ..types import ChatPermissions
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetChatPermissions(TelegramMethod[bool]):
|
class SetChatPermissions(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -21,7 +26,7 @@ class SetChatPermissions(TelegramMethod[bool]):
|
||||||
permissions: ChatPermissions
|
permissions: ChatPermissions
|
||||||
"""New default chat permissions"""
|
"""New default chat permissions"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="setChatPermissions", data=data)
|
return Request(method="setChatPermissions", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from ..types import InputFile
|
from ..types import InputFile
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetChatPhoto(TelegramMethod[bool]):
|
class SetChatPhoto(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -21,7 +26,7 @@ class SetChatPhoto(TelegramMethod[bool]):
|
||||||
photo: InputFile
|
photo: InputFile
|
||||||
"""New chat photo, uploaded using multipart/form-data"""
|
"""New chat photo, uploaded using multipart/form-data"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"photo"})
|
data: Dict[str, Any] = self.dict(exclude={"photo"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetChatStickerSet(TelegramMethod[bool]):
|
class SetChatStickerSet(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -21,7 +26,7 @@ class SetChatStickerSet(TelegramMethod[bool]):
|
||||||
sticker_set_name: str
|
sticker_set_name: str
|
||||||
"""Name of the sticker set to be set as the group sticker set"""
|
"""Name of the sticker set to be set as the group sticker set"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="setChatStickerSet", data=data)
|
return Request(method="setChatStickerSet", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetChatTitle(TelegramMethod[bool]):
|
class SetChatTitle(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -20,7 +25,7 @@ class SetChatTitle(TelegramMethod[bool]):
|
||||||
title: str
|
title: str
|
||||||
"""New chat title, 1-255 characters"""
|
"""New chat title, 1-255 characters"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="setChatTitle", data=data)
|
return Request(method="setChatTitle", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import Message
|
from ..types import Message
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetGameScore(TelegramMethod[Union[Message, bool]]):
|
class SetGameScore(TelegramMethod[Union[Message, bool]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -32,7 +37,7 @@ class SetGameScore(TelegramMethod[Union[Message, bool]]):
|
||||||
inline_message_id: Optional[str] = None
|
inline_message_id: Optional[str] = None
|
||||||
"""Required if chat_id and message_id are not specified. Identifier of the inline message"""
|
"""Required if chat_id and message_id are not specified. Identifier of the inline message"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="setGameScore", data=data)
|
return Request(method="setGameScore", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List
|
||||||
|
|
||||||
from ..types import BotCommand
|
from ..types import BotCommand
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetMyCommands(TelegramMethod[bool]):
|
class SetMyCommands(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -17,7 +22,7 @@ class SetMyCommands(TelegramMethod[bool]):
|
||||||
"""A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most
|
"""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."""
|
100 commands can be specified."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="setMyCommands", data=data)
|
return Request(method="setMyCommands", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List
|
||||||
|
|
||||||
from ..types import PassportElementError
|
from ..types import PassportElementError
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetPassportDataErrors(TelegramMethod[bool]):
|
class SetPassportDataErrors(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -24,7 +29,7 @@ class SetPassportDataErrors(TelegramMethod[bool]):
|
||||||
errors: List[PassportElementError]
|
errors: List[PassportElementError]
|
||||||
"""A JSON-serialized array describing the errors"""
|
"""A JSON-serialized array describing the errors"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="setPassportDataErrors", data=data)
|
return Request(method="setPassportDataErrors", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetStickerPositionInSet(TelegramMethod[bool]):
|
class SetStickerPositionInSet(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -18,7 +23,7 @@ class SetStickerPositionInSet(TelegramMethod[bool]):
|
||||||
position: int
|
position: int
|
||||||
"""New sticker position in the set, zero-based"""
|
"""New sticker position in the set, zero-based"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="setStickerPositionInSet", data=data)
|
return Request(method="setStickerPositionInSet", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import InputFile
|
from ..types import InputFile
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetStickerSetThumb(TelegramMethod[bool]):
|
class SetStickerSetThumb(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -27,7 +32,7 @@ class SetStickerSetThumb(TelegramMethod[bool]):
|
||||||
Internet, or upload a new one using multipart/form-data.. Animated sticker set thumbnail
|
Internet, or upload a new one using multipart/form-data.. Animated sticker set thumbnail
|
||||||
can't be uploaded via HTTP URL."""
|
can't be uploaded via HTTP URL."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"thumb"})
|
data: Dict[str, Any] = self.dict(exclude={"thumb"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, List, Optional
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||||
|
|
||||||
from ..types import InputFile
|
from ..types import InputFile
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class SetWebhook(TelegramMethod[bool]):
|
class SetWebhook(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -43,7 +48,7 @@ class SetWebhook(TelegramMethod[bool]):
|
||||||
list to receive all updates regardless of type (default). If not specified, the previous
|
list to receive all updates regardless of type (default). If not specified, the previous
|
||||||
setting will be used."""
|
setting will be used."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"certificate"})
|
data: Dict[str, Any] = self.dict(exclude={"certificate"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import InlineKeyboardMarkup, Message
|
from ..types import InlineKeyboardMarkup, Message
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class StopMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
class StopMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -26,7 +31,7 @@ class StopMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
||||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||||
"""A JSON-serialized object for a new inline keyboard."""
|
"""A JSON-serialized object for a new inline keyboard."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="stopMessageLiveLocation", data=data)
|
return Request(method="stopMessageLiveLocation", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict, Optional, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from ..types import InlineKeyboardMarkup, Poll
|
from ..types import InlineKeyboardMarkup, Poll
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class StopPoll(TelegramMethod[Poll]):
|
class StopPoll(TelegramMethod[Poll]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -22,7 +27,7 @@ class StopPoll(TelegramMethod[Poll]):
|
||||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||||
"""A JSON-serialized object for a new message inline keyboard."""
|
"""A JSON-serialized object for a new message inline keyboard."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="stopPoll", data=data)
|
return Request(method="stopPoll", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class UnbanChatMember(TelegramMethod[bool]):
|
class UnbanChatMember(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -20,7 +25,7 @@ class UnbanChatMember(TelegramMethod[bool]):
|
||||||
user_id: int
|
user_id: int
|
||||||
"""Unique identifier of the target user"""
|
"""Unique identifier of the target user"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="unbanChatMember", data=data)
|
return Request(method="unbanChatMember", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
from typing import Any, Dict, Union
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||||
|
|
||||||
from .base import Request, TelegramMethod
|
from .base import Request, TelegramMethod
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class UnpinChatMessage(TelegramMethod[bool]):
|
class UnpinChatMessage(TelegramMethod[bool]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -18,7 +23,7 @@ class UnpinChatMessage(TelegramMethod[bool]):
|
||||||
"""Unique identifier for the target chat or username of the target channel (in the format
|
"""Unique identifier for the target chat or username of the target channel (in the format
|
||||||
@channelusername)"""
|
@channelusername)"""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict()
|
data: Dict[str, Any] = self.dict()
|
||||||
|
|
||||||
return Request(method="unpinChatMessage", data=data)
|
return Request(method="unpinChatMessage", data=data)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
from typing import Any, Dict
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict
|
||||||
|
|
||||||
from ..types import File, InputFile
|
from ..types import File, InputFile
|
||||||
from .base import Request, TelegramMethod, prepare_file
|
from .base import Request, TelegramMethod, prepare_file
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..client.bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class UploadStickerFile(TelegramMethod[File]):
|
class UploadStickerFile(TelegramMethod[File]):
|
||||||
"""
|
"""
|
||||||
|
|
@ -20,7 +25,7 @@ class UploadStickerFile(TelegramMethod[File]):
|
||||||
"""PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed
|
"""PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed
|
||||||
512px, and either width or height must be exactly 512px."""
|
512px, and either width or height must be exactly 512px."""
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
data: Dict[str, Any] = self.dict(exclude={"png_sticker"})
|
data: Dict[str, Any] = self.dict(exclude={"png_sticker"})
|
||||||
|
|
||||||
files: Dict[str, InputFile] = {}
|
files: Dict[str, InputFile] = {}
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ class Dispatcher(Router):
|
||||||
# TODO: handle exceptions
|
# TODO: handle exceptions
|
||||||
response: Any = process_updates.result()
|
response: Any = process_updates.result()
|
||||||
if isinstance(response, TelegramMethod):
|
if isinstance(response, TelegramMethod):
|
||||||
request = response.build_request()
|
request = response.build_request(bot=bot)
|
||||||
return request.render_webhook_request()
|
return request.render_webhook_request()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ class MockedSession(BaseSession):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def make_request(
|
async def make_request(
|
||||||
self, token: str, method: TelegramMethod[T], timeout: Optional[int] = UNSET
|
self, bot: Bot, method: TelegramMethod[T], timeout: Optional[int] = UNSET
|
||||||
) -> T:
|
) -> T:
|
||||||
self.requests.append(method.build_request())
|
self.requests.append(method.build_request(bot))
|
||||||
response: Response[T] = self.responses.pop()
|
response: Response[T] = self.responses.pop()
|
||||||
self.raise_for_status(response)
|
self.raise_for_status(response)
|
||||||
return response.result # type: ignore
|
return response.result # type: ignore
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,13 @@ class TestBot:
|
||||||
new_callable=CoroutineMock,
|
new_callable=CoroutineMock,
|
||||||
) as mocked_make_request:
|
) as mocked_make_request:
|
||||||
await bot(method)
|
await bot(method)
|
||||||
mocked_make_request.assert_awaited_with("42:TEST", method)
|
mocked_make_request.assert_awaited_with(bot, method, timeout=None)
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_close(self):
|
async def test_close(self):
|
||||||
bot = Bot("42:TEST", session=AiohttpSession())
|
session = AiohttpSession()
|
||||||
await bot.session.create_session()
|
bot = Bot("42:TEST", session=session)
|
||||||
|
await session.create_session()
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"aiogram.api.client.session.aiohttp.AiohttpSession.close", new_callable=CoroutineMock
|
"aiogram.api.client.session.aiohttp.AiohttpSession.close", new_callable=CoroutineMock
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,11 @@ import aiohttp_socks
|
||||||
import pytest
|
import pytest
|
||||||
from aresponses import ResponsesMockServer
|
from aresponses import ResponsesMockServer
|
||||||
|
|
||||||
|
from aiogram import Bot
|
||||||
from aiogram.api.client.session.aiohttp import AiohttpSession
|
from aiogram.api.client.session.aiohttp import AiohttpSession
|
||||||
from aiogram.api.methods import Request, TelegramMethod
|
from aiogram.api.methods import Request, TelegramMethod
|
||||||
from aiogram.api.types import InputFile
|
from aiogram.api.types import InputFile
|
||||||
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from asynctest import CoroutineMock, patch
|
from asynctest import CoroutineMock, patch
|
||||||
|
|
@ -147,7 +149,7 @@ class TestAiohttpSession:
|
||||||
assert isinstance(fields[1][2], BareInputFile)
|
assert isinstance(fields[1][2], BareInputFile)
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_make_request(self, aresponses: ResponsesMockServer):
|
async def test_make_request(self, bot: MockedBot, aresponses: ResponsesMockServer):
|
||||||
aresponses.add(
|
aresponses.add(
|
||||||
aresponses.ANY,
|
aresponses.ANY,
|
||||||
"/bot42:TEST/method",
|
"/bot42:TEST/method",
|
||||||
|
|
@ -164,14 +166,14 @@ class TestAiohttpSession:
|
||||||
class TestMethod(TelegramMethod[int]):
|
class TestMethod(TelegramMethod[int]):
|
||||||
__returning__ = int
|
__returning__ = int
|
||||||
|
|
||||||
def build_request(self) -> Request:
|
def build_request(self, bot: Bot) -> Request:
|
||||||
return Request(method="method", data={})
|
return Request(method="method", data={})
|
||||||
|
|
||||||
call = TestMethod()
|
call = TestMethod()
|
||||||
with patch(
|
with patch(
|
||||||
"aiogram.api.client.session.base.BaseSession.raise_for_status"
|
"aiogram.api.client.session.base.BaseSession.raise_for_status"
|
||||||
) as patched_raise_for_status:
|
) as patched_raise_for_status:
|
||||||
result = await session.make_request("42:TEST", call)
|
result = await session.make_request(bot, call)
|
||||||
assert isinstance(result, int)
|
assert isinstance(result, int)
|
||||||
assert result == 42
|
assert result == 42
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,17 +29,14 @@ class TestAnswerInlineQuery:
|
||||||
assert request.method == "answerInlineQuery"
|
assert request.method == "answerInlineQuery"
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
def test_parse_mode(self):
|
def test_parse_mode(self, bot: MockedBot):
|
||||||
query = AnswerInlineQuery(
|
query = AnswerInlineQuery(
|
||||||
inline_query_id="query id",
|
inline_query_id="query id",
|
||||||
results=[InlineQueryResultPhoto(id="result id", photo_url="photo", thumb_url="thumb")],
|
results=[InlineQueryResultPhoto(id="result id", photo_url="photo", thumb_url="thumb")],
|
||||||
)
|
)
|
||||||
request = query.build_request()
|
request = query.build_request(bot)
|
||||||
assert request.data["results"][0]["parse_mode"] is None
|
assert request.data["results"][0]["parse_mode"] is None
|
||||||
|
|
||||||
token = Bot.set_current(Bot(token="42:TEST", parse_mode="HTML"))
|
new_bot = Bot(token="42:TEST", parse_mode="HTML")
|
||||||
try:
|
request = query.build_request(new_bot)
|
||||||
request = query.build_request()
|
assert request.data["results"][0]["parse_mode"] == "HTML"
|
||||||
assert request.data["results"][0]["parse_mode"] == "HTML"
|
|
||||||
finally:
|
|
||||||
Bot.reset_current(token)
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import pytest
|
||||||
|
|
||||||
from aiogram import Bot
|
from aiogram import Bot
|
||||||
from aiogram.api.methods.base import prepare_parse_mode
|
from aiogram.api.methods.base import prepare_parse_mode
|
||||||
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
class TestPrepareFile:
|
class TestPrepareFile:
|
||||||
|
|
@ -35,19 +36,19 @@ class TestPrepareParseMode:
|
||||||
)
|
)
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_default_parse_mode(
|
async def test_default_parse_mode(
|
||||||
self, parse_mode: str, data: Dict[str, str], result: Optional[str]
|
self, bot: MockedBot, parse_mode: str, data: Dict[str, str], result: Optional[str]
|
||||||
):
|
):
|
||||||
async with Bot(token="42:TEST", parse_mode=parse_mode).context() as bot:
|
async with Bot(token="42:TEST", parse_mode=parse_mode).context() as bot:
|
||||||
assert bot.parse_mode == parse_mode
|
assert bot.parse_mode == parse_mode
|
||||||
prepare_parse_mode(data)
|
prepare_parse_mode(bot, data)
|
||||||
assert data.get("parse_mode") == result
|
assert data.get("parse_mode") == result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_list(self):
|
async def test_list(self):
|
||||||
data = [{}] * 2
|
data = [{}] * 2
|
||||||
data.append({"parse_mode": "HTML"})
|
data.append({"parse_mode": "HTML"})
|
||||||
async with Bot(token="42:TEST", parse_mode="Markdown").context():
|
bot = Bot(token="42:TEST", parse_mode="Markdown")
|
||||||
prepare_parse_mode(data)
|
prepare_parse_mode(bot, data)
|
||||||
|
|
||||||
assert isinstance(data, list)
|
assert isinstance(data, list)
|
||||||
assert len(data) == 3
|
assert len(data) == 3
|
||||||
|
|
@ -56,7 +57,7 @@ class TestPrepareParseMode:
|
||||||
assert data[1]["parse_mode"] == "Markdown"
|
assert data[1]["parse_mode"] == "Markdown"
|
||||||
assert data[2]["parse_mode"] == "HTML"
|
assert data[2]["parse_mode"] == "HTML"
|
||||||
|
|
||||||
def test_bot_not_in_context(self):
|
def test_bot_not_in_context(self, bot: MockedBot):
|
||||||
data = {}
|
data = {}
|
||||||
prepare_parse_mode(data)
|
prepare_parse_mode(bot, data)
|
||||||
assert data["parse_mode"] is None
|
assert data["parse_mode"] is None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue