mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-06 07:50:32 +00:00
Feature/aliases inaccessible message (#1575)
* feature: add aliases for InaccessibleMessage type * add changelog * fix changelog * remove methods that may not be accessible for the InaccessibleMessage type, add tests * apply black isort * update docs with InaccessibleMessage aliases
This commit is contained in:
parent
e8fc890809
commit
386fc44a98
22 changed files with 3247 additions and 36 deletions
202
.butcher/types/InaccessibleMessage/aliases.yml
Normal file
202
.butcher/types/InaccessibleMessage/aliases.yml
Normal file
|
|
@ -0,0 +1,202 @@
|
||||||
|
answer:
|
||||||
|
method: sendMessage
|
||||||
|
code: &assert-chat |
|
||||||
|
assert self.chat is not None, "This method can be used only if chat is present in the message."
|
||||||
|
fill: &fill-answer
|
||||||
|
chat_id: self.chat.id
|
||||||
|
|
||||||
|
reply:
|
||||||
|
method: sendMessage
|
||||||
|
code: *assert-chat
|
||||||
|
fill: &fill-reply
|
||||||
|
<<: *fill-answer
|
||||||
|
reply_parameters: self.as_reply_parameters()
|
||||||
|
ignore: &ignore-reply
|
||||||
|
- reply_to_message_id
|
||||||
|
|
||||||
|
answer_animation:
|
||||||
|
method: sendAnimation
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_animation:
|
||||||
|
method: sendAnimation
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_audio:
|
||||||
|
method: sendAudio
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_audio:
|
||||||
|
method: sendAudio
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_contact:
|
||||||
|
method: sendContact
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_contact:
|
||||||
|
method: sendContact
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_document:
|
||||||
|
method: sendDocument
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_document:
|
||||||
|
method: sendDocument
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_game:
|
||||||
|
method: sendGame
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_game:
|
||||||
|
method: sendGame
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_invoice:
|
||||||
|
method: sendInvoice
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_invoice:
|
||||||
|
method: sendInvoice
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_location:
|
||||||
|
method: sendLocation
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_location:
|
||||||
|
method: sendLocation
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_media_group:
|
||||||
|
method: sendMediaGroup
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_media_group:
|
||||||
|
method: sendMediaGroup
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_photo:
|
||||||
|
method: sendPhoto
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_photo:
|
||||||
|
method: sendPhoto
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_poll:
|
||||||
|
method: sendPoll
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_poll:
|
||||||
|
method: sendPoll
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_dice:
|
||||||
|
method: sendDice
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_dice:
|
||||||
|
method: sendDice
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_sticker:
|
||||||
|
method: sendSticker
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_sticker:
|
||||||
|
method: sendSticker
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_venue:
|
||||||
|
method: sendVenue
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_venue:
|
||||||
|
method: sendVenue
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_video:
|
||||||
|
method: sendVideo
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_video:
|
||||||
|
method: sendVideo
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_video_note:
|
||||||
|
method: sendVideoNote
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_video_note:
|
||||||
|
method: sendVideoNote
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_voice:
|
||||||
|
method: sendVoice
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_voice:
|
||||||
|
method: sendVoice
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
|
|
||||||
|
answer_paid_media:
|
||||||
|
method: sendPaidMedia
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-answer
|
||||||
|
|
||||||
|
reply_paid_media:
|
||||||
|
method: sendPaidMedia
|
||||||
|
code: *assert-chat
|
||||||
|
fill: *fill-reply
|
||||||
|
ignore: *ignore-reply
|
||||||
2
CHANGES/1574.feature.rst
Normal file
2
CHANGES/1574.feature.rst
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
Added missing method aliases such as `.answer()`, `.reply()`, and others to `InaccessibleMessage`.
|
||||||
|
This change ensures consistency and improves usability by aligning the functionality of `InaccessibleMessage` with the `Message` type.
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_animation`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_animation`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_animation`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_animation`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_animation_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_animation_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_animation`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_animation`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_animation`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_animation`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_animation`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_animation`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_audio`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_audio`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_audio`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_audio`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_audio_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_audio_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_audio`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_audio`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_audio`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_audio`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_audio`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_audio`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_contact`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_contact`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_contact`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_contact`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_contact_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_contact_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_contact`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_contact`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_contact`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_contact`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_contact`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_contact`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_dice`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_dice`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_dice`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_dice`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_dice_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_dice_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_dice`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_dice`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_dice`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_dice`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_dice`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_dice`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_document`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_document`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_document`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_document`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_document_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_document_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_document`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_document`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_document`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_document`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_document`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_document`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_game`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_game`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_game`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_game`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_game_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_game_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_game`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_game`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_game`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_game`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_game`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_game`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_invoice`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_invoice`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_invoice`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_invoice`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_invoice_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_invoice_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_invoice`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_invoice`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_invoice`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_invoice`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_invoice`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_invoice`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_location`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_location`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_location`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_location`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_location_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_location_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_location`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_location`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_location`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_location`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_location`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_location`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_media_group`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_media_group`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_media_group`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_media_group`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_media_group_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_media_group_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_media_group`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_media_group`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_media_group`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_media_group`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_media_group`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_media_group`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply`
|
||||||
|
|
|
||||||
|
|
@ -48,5 +48,7 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_paid_media`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_paid_media`
|
||||||
- :meth:`aiogram.types.message.Message.answer_paid_media`
|
- :meth:`aiogram.types.message.Message.answer_paid_media`
|
||||||
- :meth:`aiogram.types.message.Message.reply_paid_media`
|
- :meth:`aiogram.types.message.Message.reply_paid_media`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_photo`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_photo`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_photo`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_photo`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_photo_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_photo_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_photo`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_photo`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_photo`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_photo`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_photo`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_photo`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_poll`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_poll`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_poll`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_poll`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_poll_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_poll_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_poll`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_poll`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_poll`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_poll`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_poll`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_poll`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_sticker`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_sticker`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_sticker`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_sticker`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_sticker_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_sticker_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_sticker`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_sticker`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_sticker`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_sticker`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_sticker`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_sticker`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_venue`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_venue`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_venue`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_venue`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_venue_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_venue_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_venue`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_venue`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_venue`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_venue`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_venue`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_venue`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_video`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_video`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_video`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_video`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_video_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_video_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_video`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_video`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_video`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_video`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_video`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_video`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_video_note`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_video_note`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_video_note`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_video_note`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_video_note_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_video_note_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_video_note`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_video_note`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_video_note`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_video_note`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_video_note`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_video_note`
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ As reply into Webhook in handler
|
||||||
As shortcut from received object
|
As shortcut from received object
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
- :meth:`aiogram.types.message.Message.answer_voice`
|
|
||||||
- :meth:`aiogram.types.message.Message.reply_voice`
|
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_voice`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_voice`
|
||||||
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_voice_pm`
|
- :meth:`aiogram.types.chat_join_request.ChatJoinRequest.answer_voice_pm`
|
||||||
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_voice`
|
- :meth:`aiogram.types.chat_member_updated.ChatMemberUpdated.answer_voice`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.answer_voice`
|
||||||
|
- :meth:`aiogram.types.inaccessible_message.InaccessibleMessage.reply_voice`
|
||||||
|
- :meth:`aiogram.types.message.Message.answer_voice`
|
||||||
|
- :meth:`aiogram.types.message.Message.reply_voice`
|
||||||
|
|
|
||||||
152
tests/test_api/test_types/test_inaccessible_message.py
Normal file
152
tests/test_api/test_types/test_inaccessible_message.py
Normal file
|
|
@ -0,0 +1,152 @@
|
||||||
|
from typing import Any, Dict, Type, Union
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from aiogram.methods import (
|
||||||
|
SendAnimation,
|
||||||
|
SendAudio,
|
||||||
|
SendContact,
|
||||||
|
SendDice,
|
||||||
|
SendDocument,
|
||||||
|
SendGame,
|
||||||
|
SendInvoice,
|
||||||
|
SendLocation,
|
||||||
|
SendMediaGroup,
|
||||||
|
SendMessage,
|
||||||
|
SendPaidMedia,
|
||||||
|
SendPhoto,
|
||||||
|
SendPoll,
|
||||||
|
SendSticker,
|
||||||
|
SendVenue,
|
||||||
|
SendVideo,
|
||||||
|
SendVideoNote,
|
||||||
|
SendVoice,
|
||||||
|
)
|
||||||
|
from aiogram.types import Chat
|
||||||
|
from aiogram.types.inaccessible_message import InaccessibleMessage
|
||||||
|
from aiogram.types.message import ContentType
|
||||||
|
|
||||||
|
TEST_MESSAGE_UNKNOWN = InaccessibleMessage(
|
||||||
|
message_id=42,
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
)
|
||||||
|
|
||||||
|
MESSAGES_AND_CONTENT_TYPES = [
|
||||||
|
[TEST_MESSAGE_UNKNOWN, ContentType.UNKNOWN],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class TestMessage:
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"message,content_type",
|
||||||
|
MESSAGES_AND_CONTENT_TYPES,
|
||||||
|
)
|
||||||
|
def test_as_reply_parameters(self, message, content_type):
|
||||||
|
reply_parameters = message.as_reply_parameters()
|
||||||
|
assert reply_parameters.message_id == message.message_id
|
||||||
|
assert reply_parameters.chat_id == message.chat.id
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"alias_for_method,kwargs,method_class",
|
||||||
|
[
|
||||||
|
["animation", dict(animation="animation"), SendAnimation],
|
||||||
|
["audio", dict(audio="audio"), SendAudio],
|
||||||
|
["contact", dict(phone_number="+000000000000", first_name="Test"), SendContact],
|
||||||
|
["document", dict(document="document"), SendDocument],
|
||||||
|
["game", dict(game_short_name="game"), SendGame],
|
||||||
|
[
|
||||||
|
"invoice",
|
||||||
|
dict(
|
||||||
|
title="title",
|
||||||
|
description="description",
|
||||||
|
payload="payload",
|
||||||
|
provider_token="provider_token",
|
||||||
|
start_parameter="start_parameter",
|
||||||
|
currency="currency",
|
||||||
|
prices=[],
|
||||||
|
),
|
||||||
|
SendInvoice,
|
||||||
|
],
|
||||||
|
["location", dict(latitude=0.42, longitude=0.42), SendLocation],
|
||||||
|
["media_group", dict(media=[]), SendMediaGroup],
|
||||||
|
["", dict(text="test"), SendMessage],
|
||||||
|
["photo", dict(photo="photo"), SendPhoto],
|
||||||
|
["poll", dict(question="Q?", options=[]), SendPoll],
|
||||||
|
["dice", dict(), SendDice],
|
||||||
|
["sticker", dict(sticker="sticker"), SendSticker],
|
||||||
|
["sticker", dict(sticker="sticker"), SendSticker],
|
||||||
|
[
|
||||||
|
"venue",
|
||||||
|
dict(
|
||||||
|
latitude=0.42,
|
||||||
|
longitude=0.42,
|
||||||
|
title="title",
|
||||||
|
address="address",
|
||||||
|
),
|
||||||
|
SendVenue,
|
||||||
|
],
|
||||||
|
["video", dict(video="video"), SendVideo],
|
||||||
|
["video_note", dict(video_note="video_note"), SendVideoNote],
|
||||||
|
["voice", dict(voice="voice"), SendVoice],
|
||||||
|
["paid_media", dict(media=[], star_count=42), SendPaidMedia],
|
||||||
|
],
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize("alias_type", ["reply", "answer"])
|
||||||
|
def test_reply_answer_aliases(
|
||||||
|
self,
|
||||||
|
alias_for_method: str,
|
||||||
|
alias_type: str,
|
||||||
|
kwargs: Dict[str, Any],
|
||||||
|
method_class: Type[
|
||||||
|
Union[
|
||||||
|
SendAnimation,
|
||||||
|
SendAudio,
|
||||||
|
SendContact,
|
||||||
|
SendDocument,
|
||||||
|
SendGame,
|
||||||
|
SendInvoice,
|
||||||
|
SendLocation,
|
||||||
|
SendMediaGroup,
|
||||||
|
SendMessage,
|
||||||
|
SendPhoto,
|
||||||
|
SendPoll,
|
||||||
|
SendSticker,
|
||||||
|
SendSticker,
|
||||||
|
SendVenue,
|
||||||
|
SendVideo,
|
||||||
|
SendVideoNote,
|
||||||
|
SendVoice,
|
||||||
|
SendPaidMedia,
|
||||||
|
]
|
||||||
|
],
|
||||||
|
):
|
||||||
|
message = InaccessibleMessage(
|
||||||
|
message_id=42,
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
)
|
||||||
|
alias_name = "_".join(item for item in [alias_type, alias_for_method] if item)
|
||||||
|
|
||||||
|
alias = getattr(message, alias_name)
|
||||||
|
assert callable(alias)
|
||||||
|
|
||||||
|
api_method = alias(**kwargs)
|
||||||
|
assert isinstance(api_method, method_class)
|
||||||
|
|
||||||
|
assert api_method.chat_id == message.chat.id
|
||||||
|
if alias_type == "reply":
|
||||||
|
assert api_method.reply_parameters
|
||||||
|
assert api_method.reply_parameters.message_id == message.message_id
|
||||||
|
assert api_method.reply_parameters.chat_id == message.chat.id
|
||||||
|
else:
|
||||||
|
assert api_method.reply_parameters is None
|
||||||
|
|
||||||
|
if hasattr(api_method, "reply_parameters"):
|
||||||
|
if alias_type == "reply":
|
||||||
|
assert api_method.reply_parameters is not None
|
||||||
|
assert api_method.reply_parameters.message_id == message.message_id
|
||||||
|
assert api_method.reply_parameters.chat_id == message.chat.id
|
||||||
|
else:
|
||||||
|
assert api_method.reply_parameters is None
|
||||||
|
|
||||||
|
for key, value in kwargs.items():
|
||||||
|
assert getattr(api_method, key) == value
|
||||||
Loading…
Add table
Add a link
Reference in a new issue