PoC: Mount objects to the Bot instance, bind shortcuts to configured instance

This commit is contained in:
Alex Root Junior 2023-07-08 03:00:58 +03:00
parent c39a803747
commit 7ea168a84b
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
12 changed files with 123 additions and 93 deletions

View file

@ -0,0 +1,22 @@
from typing import TYPE_CHECKING, Any, Optional
from pydantic import BaseModel, PrivateAttr
from typing_extensions import Self
if TYPE_CHECKING:
from aiogram.client.bot import Bot
class BotContextController(BaseModel):
_bot: Optional["Bot"] = PrivateAttr()
def model_post_init(self, __context: Any) -> None:
if not __context:
self._bot = None
else:
self._bot = __context.get("bot")
def as_(self, bot: "Bot") -> Self:
"""Bind object to a bot instance."""
self._bot = bot
return self

View file

@ -167,7 +167,9 @@ class AiohttpSession(BaseSession):
raise TelegramNetworkError(method=method, message="Request timeout error") raise TelegramNetworkError(method=method, message="Request timeout error")
except ClientError as e: except ClientError as e:
raise TelegramNetworkError(method=method, message=f"{type(e).__name__}: {e}") raise TelegramNetworkError(method=method, message=f"{type(e).__name__}: {e}")
response = self.check_response(method=method, status_code=resp.status, content=raw_result) response = self.check_response(
bot=bot, method=method, status_code=resp.status, content=raw_result
)
return cast(TelegramType, response.result) return cast(TelegramType, response.result)
async def stream_content( async def stream_content(

View file

@ -75,7 +75,7 @@ class BaseSession(abc.ABC):
self.middleware = RequestMiddlewareManager() self.middleware = RequestMiddlewareManager()
def check_response( def check_response(
self, method: TelegramMethod[TelegramType], status_code: int, content: str self, bot: Bot, method: TelegramMethod[TelegramType], status_code: int, content: str
) -> Response[TelegramType]: ) -> Response[TelegramType]:
""" """
Check response status Check response status
@ -89,7 +89,9 @@ class BaseSession(abc.ABC):
raise ClientDecodeError("Failed to decode object", e, content) raise ClientDecodeError("Failed to decode object", e, content)
try: try:
response = method.build_response(json_data) response = Response[method.__returning__].model_validate(
json_data, context={"bot": bot}
)
except ValidationError as e: except ValidationError as e:
raise ClientDecodeError("Failed to deserialize object", e, json_data) raise ClientDecodeError("Failed to deserialize object", e, json_data)

View file

@ -6,6 +6,8 @@ from typing import TYPE_CHECKING, Any, Dict, Generator, Generic, Optional, TypeV
from pydantic import BaseModel, ConfigDict from pydantic import BaseModel, ConfigDict
from pydantic.functional_validators import model_validator from pydantic.functional_validators import model_validator
from aiogram.client.context_controller import BotContextController
from ..types import InputFile, ResponseParameters from ..types import InputFile, ResponseParameters
from ..types.base import UNSET_TYPE from ..types.base import UNSET_TYPE
@ -32,7 +34,7 @@ class Response(BaseModel, Generic[TelegramType]):
parameters: Optional[ResponseParameters] = None parameters: Optional[ResponseParameters] = None
class TelegramMethod(BaseModel, Generic[TelegramType], ABC): class TelegramMethod(BotContextController, BaseModel, Generic[TelegramType], ABC):
model_config = ConfigDict( model_config = ConfigDict(
extra="allow", extra="allow",
populate_by_name=True, populate_by_name=True,
@ -40,6 +42,7 @@ class TelegramMethod(BaseModel, Generic[TelegramType], ABC):
) )
@model_validator(mode="before") @model_validator(mode="before")
@classmethod
def remove_unset(cls, values: Dict[str, Any]) -> Dict[str, Any]: def remove_unset(cls, values: Dict[str, Any]) -> Dict[str, Any]:
""" """
Remove UNSET before fields validation. Remove UNSET before fields validation.
@ -53,7 +56,7 @@ class TelegramMethod(BaseModel, Generic[TelegramType], ABC):
@property @property
@abstractmethod @abstractmethod
def __returning__(self) -> type: # pragma: no cover def __returning__(self) -> type:
pass pass
@property @property
@ -61,15 +64,16 @@ class TelegramMethod(BaseModel, Generic[TelegramType], ABC):
def __api_method__(self) -> str: def __api_method__(self) -> str:
pass pass
def build_response(self, data: Dict[str, Any]) -> Response[TelegramType]:
# noinspection PyTypeChecker
return Response[self.__returning__](**data) # type: ignore
async def emit(self, bot: Bot) -> TelegramType: async def emit(self, bot: Bot) -> TelegramType:
return await bot(self) return await bot(self)
def __await__(self) -> Generator[Any, None, TelegramType]: def __await__(self) -> Generator[Any, None, TelegramType]:
from aiogram.client.bot import Bot bot = self._bot
if not bot:
bot = Bot.get_current(no_error=False) raise RuntimeError(
"This method is not mounted to a any bot instance, please call it explicilty "
"with bot instance `await bot(method)`\n"
"or mount method to a bot instance `method.as_(bot)` "
"and then call it `await method()`"
)
return self.emit(bot).__await__() return self.emit(bot).__await__()

View file

@ -3,10 +3,10 @@ from unittest.mock import sentinel
from pydantic import BaseModel, ConfigDict from pydantic import BaseModel, ConfigDict
from aiogram.utils.mixins import ContextInstanceMixin from aiogram.client.context_controller import BotContextController
class TelegramObject(ContextInstanceMixin["TelegramObject"], BaseModel): class TelegramObject(BotContextController, BaseModel):
model_config = ConfigDict( model_config = ConfigDict(
use_enum_values=True, use_enum_values=True,
extra="allow", extra="allow",

View file

@ -74,4 +74,4 @@ class CallbackQuery(TelegramObject):
url=url, url=url,
cache_time=cache_time, cache_time=cache_time,
**kwargs, **kwargs,
) ).as_(self._bot)

View file

@ -164,7 +164,7 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
sender_chat_id=sender_chat_id, sender_chat_id=sender_chat_id,
**kwargs, **kwargs,
) ).as_(self._bot)
def unban_sender_chat( def unban_sender_chat(
self, self,
@ -193,7 +193,7 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
sender_chat_id=sender_chat_id, sender_chat_id=sender_chat_id,
**kwargs, **kwargs,
) ).as_(self._bot)
def get_administrators( def get_administrators(
self, self,
@ -219,7 +219,7 @@ class Chat(TelegramObject):
return GetChatAdministrators( return GetChatAdministrators(
chat_id=self.id, chat_id=self.id,
**kwargs, **kwargs,
) ).as_(self._bot)
def delete_message( def delete_message(
self, self,
@ -266,7 +266,7 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
message_id=message_id, message_id=message_id,
**kwargs, **kwargs,
) ).as_(self._bot)
def revoke_invite_link( def revoke_invite_link(
self, self,
@ -295,7 +295,7 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
invite_link=invite_link, invite_link=invite_link,
**kwargs, **kwargs,
) ).as_(self._bot)
def edit_invite_link( def edit_invite_link(
self, self,
@ -336,7 +336,7 @@ class Chat(TelegramObject):
member_limit=member_limit, member_limit=member_limit,
creates_join_request=creates_join_request, creates_join_request=creates_join_request,
**kwargs, **kwargs,
) ).as_(self._bot)
def create_invite_link( def create_invite_link(
self, self,
@ -374,7 +374,7 @@ class Chat(TelegramObject):
member_limit=member_limit, member_limit=member_limit,
creates_join_request=creates_join_request, creates_join_request=creates_join_request,
**kwargs, **kwargs,
) ).as_(self._bot)
def export_invite_link( def export_invite_link(
self, self,
@ -402,7 +402,7 @@ class Chat(TelegramObject):
return ExportChatInviteLink( return ExportChatInviteLink(
chat_id=self.id, chat_id=self.id,
**kwargs, **kwargs,
) ).as_(self._bot)
def do( def do(
self, self,
@ -438,7 +438,7 @@ class Chat(TelegramObject):
action=action, action=action,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
**kwargs, **kwargs,
) ).as_(self._bot)
def delete_sticker_set( def delete_sticker_set(
self, self,
@ -464,7 +464,7 @@ class Chat(TelegramObject):
return DeleteChatStickerSet( return DeleteChatStickerSet(
chat_id=self.id, chat_id=self.id,
**kwargs, **kwargs,
) ).as_(self._bot)
def set_sticker_set( def set_sticker_set(
self, self,
@ -493,7 +493,7 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
sticker_set_name=sticker_set_name, sticker_set_name=sticker_set_name,
**kwargs, **kwargs,
) ).as_(self._bot)
def get_member( def get_member(
self, self,
@ -522,7 +522,7 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
user_id=user_id, user_id=user_id,
**kwargs, **kwargs,
) ).as_(self._bot)
def get_member_count( def get_member_count(
self, self,
@ -548,7 +548,7 @@ class Chat(TelegramObject):
return GetChatMemberCount( return GetChatMemberCount(
chat_id=self.id, chat_id=self.id,
**kwargs, **kwargs,
) ).as_(self._bot)
def leave( def leave(
self, self,
@ -574,7 +574,7 @@ class Chat(TelegramObject):
return LeaveChat( return LeaveChat(
chat_id=self.id, chat_id=self.id,
**kwargs, **kwargs,
) ).as_(self._bot)
def unpin_all_messages( def unpin_all_messages(
self, self,
@ -600,7 +600,7 @@ class Chat(TelegramObject):
return UnpinAllChatMessages( return UnpinAllChatMessages(
chat_id=self.id, chat_id=self.id,
**kwargs, **kwargs,
) ).as_(self._bot)
def unpin_message( def unpin_message(
self, self,
@ -629,7 +629,7 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
message_id=message_id, message_id=message_id,
**kwargs, **kwargs,
) ).as_(self._bot)
def pin_message( def pin_message(
self, self,
@ -661,7 +661,7 @@ class Chat(TelegramObject):
message_id=message_id, message_id=message_id,
disable_notification=disable_notification, disable_notification=disable_notification,
**kwargs, **kwargs,
) ).as_(self._bot)
def set_administrator_custom_title( def set_administrator_custom_title(
self, self,
@ -693,7 +693,7 @@ class Chat(TelegramObject):
user_id=user_id, user_id=user_id,
custom_title=custom_title, custom_title=custom_title,
**kwargs, **kwargs,
) ).as_(self._bot)
def set_permissions( def set_permissions(
self, self,
@ -725,7 +725,7 @@ class Chat(TelegramObject):
permissions=permissions, permissions=permissions,
use_independent_chat_permissions=use_independent_chat_permissions, use_independent_chat_permissions=use_independent_chat_permissions,
**kwargs, **kwargs,
) ).as_(self._bot)
def promote( def promote(
self, self,
@ -790,7 +790,7 @@ class Chat(TelegramObject):
can_pin_messages=can_pin_messages, can_pin_messages=can_pin_messages,
can_manage_topics=can_manage_topics, can_manage_topics=can_manage_topics,
**kwargs, **kwargs,
) ).as_(self._bot)
def restrict( def restrict(
self, self,
@ -828,7 +828,7 @@ class Chat(TelegramObject):
use_independent_chat_permissions=use_independent_chat_permissions, use_independent_chat_permissions=use_independent_chat_permissions,
until_date=until_date, until_date=until_date,
**kwargs, **kwargs,
) ).as_(self._bot)
def unban( def unban(
self, self,
@ -860,7 +860,7 @@ class Chat(TelegramObject):
user_id=user_id, user_id=user_id,
only_if_banned=only_if_banned, only_if_banned=only_if_banned,
**kwargs, **kwargs,
) ).as_(self._bot)
def ban( def ban(
self, self,
@ -895,7 +895,7 @@ class Chat(TelegramObject):
until_date=until_date, until_date=until_date,
revoke_messages=revoke_messages, revoke_messages=revoke_messages,
**kwargs, **kwargs,
) ).as_(self._bot)
def set_description( def set_description(
self, self,
@ -924,7 +924,7 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
description=description, description=description,
**kwargs, **kwargs,
) ).as_(self._bot)
def set_title( def set_title(
self, self,
@ -953,7 +953,7 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
title=title, title=title,
**kwargs, **kwargs,
) ).as_(self._bot)
def delete_photo( def delete_photo(
self, self,
@ -979,7 +979,7 @@ class Chat(TelegramObject):
return DeleteChatPhoto( return DeleteChatPhoto(
chat_id=self.id, chat_id=self.id,
**kwargs, **kwargs,
) ).as_(self._bot)
def set_photo( def set_photo(
self, self,
@ -1008,4 +1008,4 @@ class Chat(TelegramObject):
chat_id=self.id, chat_id=self.id,
photo=photo, photo=photo,
**kwargs, **kwargs,
) ).as_(self._bot)

View file

@ -62,7 +62,7 @@ class ChatJoinRequest(TelegramObject):
chat_id=self.chat.id, chat_id=self.chat.id,
user_id=self.from_user.id, user_id=self.from_user.id,
**kwargs, **kwargs,
) ).as_(self._bot)
def decline( def decline(
self, self,
@ -90,4 +90,4 @@ class ChatJoinRequest(TelegramObject):
chat_id=self.chat.id, chat_id=self.chat.id,
user_id=self.from_user.id, user_id=self.from_user.id,
**kwargs, **kwargs,
) ).as_(self._bot)

View file

@ -81,4 +81,4 @@ class InlineQuery(TelegramObject):
switch_pm_parameter=switch_pm_parameter, switch_pm_parameter=switch_pm_parameter,
switch_pm_text=switch_pm_text, switch_pm_text=switch_pm_text,
**kwargs, **kwargs,
) ).as_(self._bot)

View file

@ -418,7 +418,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_animation( def answer_animation(
self, self,
@ -490,7 +490,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_audio( def reply_audio(
self, self,
@ -559,7 +559,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_audio( def answer_audio(
self, self,
@ -629,7 +629,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_contact( def reply_contact(
self, self,
@ -685,7 +685,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_contact( def answer_contact(
self, self,
@ -742,7 +742,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_document( def reply_document(
self, self,
@ -804,7 +804,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_document( def answer_document(
self, self,
@ -867,7 +867,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_game( def reply_game(
self, self,
@ -912,7 +912,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_game( def answer_game(
self, self,
@ -958,7 +958,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_invoice( def reply_invoice(
self, self,
@ -1063,7 +1063,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_invoice( def answer_invoice(
self, self,
@ -1169,7 +1169,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_location( def reply_location(
self, self,
@ -1231,7 +1231,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_location( def answer_location(
self, self,
@ -1294,7 +1294,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_media_group( def reply_media_group(
self, self,
@ -1336,7 +1336,7 @@ class Message(TelegramObject):
protect_content=protect_content, protect_content=protect_content,
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_media_group( def answer_media_group(
self, self,
@ -1379,7 +1379,7 @@ class Message(TelegramObject):
reply_to_message_id=reply_to_message_id, reply_to_message_id=reply_to_message_id,
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply( def reply(
self, self,
@ -1435,7 +1435,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer( def answer(
self, self,
@ -1492,7 +1492,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_photo( def reply_photo(
self, self,
@ -1551,7 +1551,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_photo( def answer_photo(
self, self,
@ -1611,7 +1611,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_poll( def reply_poll(
self, self,
@ -1691,7 +1691,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_poll( def answer_poll(
self, self,
@ -1772,7 +1772,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_dice( def reply_dice(
self, self,
@ -1819,7 +1819,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_dice( def answer_dice(
self, self,
@ -1867,7 +1867,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_sticker( def reply_sticker(
self, self,
@ -1917,7 +1917,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_sticker( def answer_sticker(
self, self,
@ -1968,7 +1968,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_venue( def reply_venue(
self, self,
@ -2036,7 +2036,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_venue( def answer_venue(
self, self,
@ -2105,7 +2105,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_video( def reply_video(
self, self,
@ -2179,7 +2179,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_video( def answer_video(
self, self,
@ -2254,7 +2254,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_video_note( def reply_video_note(
self, self,
@ -2310,7 +2310,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_video_note( def answer_video_note(
self, self,
@ -2367,7 +2367,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def reply_voice( def reply_voice(
self, self,
@ -2426,7 +2426,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def answer_voice( def answer_voice(
self, self,
@ -2486,7 +2486,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def send_copy( # noqa: C901 def send_copy( # noqa: C901
self: Message, self: Message,
@ -2684,7 +2684,7 @@ class Message(TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def edit_text( def edit_text(
self, self,
@ -2730,7 +2730,7 @@ class Message(TelegramObject):
disable_web_page_preview=disable_web_page_preview, disable_web_page_preview=disable_web_page_preview,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def forward( def forward(
self, self,
@ -2770,7 +2770,7 @@ class Message(TelegramObject):
disable_notification=disable_notification, disable_notification=disable_notification,
protect_content=protect_content, protect_content=protect_content,
**kwargs, **kwargs,
) ).as_(self._bot)
def edit_media( def edit_media(
self, self,
@ -2807,7 +2807,7 @@ class Message(TelegramObject):
inline_message_id=inline_message_id, inline_message_id=inline_message_id,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def edit_reply_markup( def edit_reply_markup(
self, self,
@ -2841,7 +2841,7 @@ class Message(TelegramObject):
inline_message_id=inline_message_id, inline_message_id=inline_message_id,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def delete_reply_markup(self) -> EditMessageReplyMarkup: def delete_reply_markup(self) -> EditMessageReplyMarkup:
return self.edit_reply_markup(reply_markup=None) return self.edit_reply_markup(reply_markup=None)
@ -2893,7 +2893,7 @@ class Message(TelegramObject):
proximity_alert_radius=proximity_alert_radius, proximity_alert_radius=proximity_alert_radius,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def stop_live_location( def stop_live_location(
self, self,
@ -2927,7 +2927,7 @@ class Message(TelegramObject):
inline_message_id=inline_message_id, inline_message_id=inline_message_id,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def edit_caption( def edit_caption(
self, self,
@ -2970,7 +2970,7 @@ class Message(TelegramObject):
caption_entities=caption_entities, caption_entities=caption_entities,
reply_markup=reply_markup, reply_markup=reply_markup,
**kwargs, **kwargs,
) ).as_(self._bot)
def delete( def delete(
self, self,
@ -3016,7 +3016,7 @@ class Message(TelegramObject):
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id, message_id=self.message_id,
**kwargs, **kwargs,
) ).as_(self._bot)
def pin( def pin(
self, self,
@ -3047,7 +3047,7 @@ class Message(TelegramObject):
message_id=self.message_id, message_id=self.message_id,
disable_notification=disable_notification, disable_notification=disable_notification,
**kwargs, **kwargs,
) ).as_(self._bot)
def unpin( def unpin(
self, self,
@ -3075,7 +3075,7 @@ class Message(TelegramObject):
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id, message_id=self.message_id,
**kwargs, **kwargs,
) ).as_(self._bot)
def get_url(self, force_private: bool = False) -> Optional[str]: def get_url(self, force_private: bool = False) -> Optional[str]:
""" """

View file

@ -76,7 +76,7 @@ class Sticker(TelegramObject):
sticker=self.file_id, sticker=self.file_id,
position=position, position=position,
**kwargs, **kwargs,
) ).as_(self._bot)
def delete_from_set( def delete_from_set(
self, self,
@ -102,4 +102,4 @@ class Sticker(TelegramObject):
return DeleteStickerFromSet( return DeleteStickerFromSet(
sticker=self.file_id, sticker=self.file_id,
**kwargs, **kwargs,
) ).as_(self._bot)

View file

@ -90,4 +90,4 @@ class User(TelegramObject):
offset=offset, offset=offset,
limit=limit, limit=limit,
**kwargs, **kwargs,
) ).as_(self._bot)