mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add missing Message methods (#1030)
* Add `Message.forward` method * Add docs * Add other methods * Fix * Add changes * Fix lints * Update CHANGES/1030.feature.rst Co-authored-by: Alex Root Junior <jroot.junior@gmail.com> Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
This commit is contained in:
parent
f4d3dbf3bf
commit
8b0ca520f3
9 changed files with 204 additions and 0 deletions
|
|
@ -16,7 +16,11 @@ if TYPE_CHECKING:
|
|||
DeleteMessage,
|
||||
EditMessageCaption,
|
||||
EditMessageReplyMarkup,
|
||||
EditMessageLiveLocation,
|
||||
EditMessageMedia,
|
||||
EditMessageText,
|
||||
ForwardMessage,
|
||||
PinChatMessage,
|
||||
SendAnimation,
|
||||
SendAudio,
|
||||
SendContact,
|
||||
|
|
@ -34,6 +38,8 @@ if TYPE_CHECKING:
|
|||
SendVideo,
|
||||
SendVideoNote,
|
||||
SendVoice,
|
||||
StopMessageLiveLocation,
|
||||
UnpinChatMessage,
|
||||
)
|
||||
from .animation import Animation
|
||||
from .audio import Audio
|
||||
|
|
@ -45,6 +51,7 @@ if TYPE_CHECKING:
|
|||
from .game import Game
|
||||
from .inline_keyboard_markup import InlineKeyboardMarkup
|
||||
from .input_file import InputFile
|
||||
from .input_media import InputMedia
|
||||
from .input_media_audio import InputMediaAudio
|
||||
from .input_media_document import InputMediaDocument
|
||||
from .input_media_photo import InputMediaPhoto
|
||||
|
|
@ -1822,6 +1829,36 @@ class Message(TelegramObject):
|
|||
reply_markup=reply_markup,
|
||||
)
|
||||
|
||||
def forward(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
disable_notification: Optional[bool] = None,
|
||||
protect_content: Optional[bool] = None,
|
||||
) -> ForwardMessage:
|
||||
from ..methods import ForwardMessage
|
||||
|
||||
return ForwardMessage(
|
||||
chat_id=chat_id,
|
||||
from_chat_id=self.chat.id,
|
||||
message_id=self.message_id,
|
||||
disable_notification=disable_notification,
|
||||
protect_content=protect_content,
|
||||
)
|
||||
|
||||
def edit_media(
|
||||
self,
|
||||
media: InputMedia,
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None,
|
||||
) -> EditMessageMedia:
|
||||
from ..methods import EditMessageMedia
|
||||
|
||||
return EditMessageMedia(
|
||||
media=media,
|
||||
chat_id=self.chat.id,
|
||||
message_id=self.message_id,
|
||||
reply_markup=reply_markup,
|
||||
)
|
||||
|
||||
def edit_reply_markup(
|
||||
self,
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None,
|
||||
|
|
@ -1837,6 +1874,40 @@ class Message(TelegramObject):
|
|||
def delete_reply_markup(self) -> EditMessageReplyMarkup:
|
||||
return self.edit_reply_markup(reply_markup=None)
|
||||
|
||||
def edit_live_location(
|
||||
self,
|
||||
latitude: float,
|
||||
longitude: float,
|
||||
horizontal_accuracy: Optional[float] = None,
|
||||
heading: Optional[int] = None,
|
||||
proximity_alert_radius: Optional[int] = None,
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None,
|
||||
) -> EditMessageLiveLocation:
|
||||
from ..methods import EditMessageLiveLocation
|
||||
|
||||
return EditMessageLiveLocation(
|
||||
latitude=latitude,
|
||||
longitude=longitude,
|
||||
chat_id=self.chat.id,
|
||||
message_id=self.message_id,
|
||||
horizontal_accuracy=horizontal_accuracy,
|
||||
heading=heading,
|
||||
proximity_alert_radius=proximity_alert_radius,
|
||||
reply_markup=reply_markup,
|
||||
)
|
||||
|
||||
def stop_live_location(
|
||||
self,
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None,
|
||||
) -> StopMessageLiveLocation:
|
||||
from ..methods import StopMessageLiveLocation
|
||||
|
||||
return StopMessageLiveLocation(
|
||||
chat_id=self.chat.id,
|
||||
message_id=self.message_id,
|
||||
reply_markup=reply_markup,
|
||||
)
|
||||
|
||||
def edit_caption(
|
||||
self,
|
||||
caption: str,
|
||||
|
|
@ -1860,6 +1931,26 @@ class Message(TelegramObject):
|
|||
|
||||
return DeleteMessage(chat_id=self.chat.id, message_id=self.message_id)
|
||||
|
||||
def pin(
|
||||
self,
|
||||
disable_notification: Optional[bool] = None,
|
||||
) -> PinChatMessage:
|
||||
from ..methods import PinChatMessage
|
||||
|
||||
return PinChatMessage(
|
||||
chat_id=self.chat.id,
|
||||
message_id=self.message_id,
|
||||
disable_notification=disable_notification,
|
||||
)
|
||||
|
||||
def unpin(self) -> UnpinChatMessage:
|
||||
from ..methods import UnpinChatMessage
|
||||
|
||||
return UnpinChatMessage(
|
||||
chat_id=self.chat.id,
|
||||
message_id=self.message_id,
|
||||
)
|
||||
|
||||
def get_url(self, force_private: bool = False) -> Optional[str]:
|
||||
"""
|
||||
Returns message URL. Cannot be used in private (one-to-one) chats.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue