diff --git a/.apiversion b/.apiversion index 341291e5..21afad37 100644 --- a/.apiversion +++ b/.apiversion @@ -1 +1 @@ -6.7 +6.8 diff --git a/.butcher/methods/unpinAllGeneralForumTopicMessages/entity.json b/.butcher/methods/unpinAllGeneralForumTopicMessages/entity.json new file mode 100644 index 00000000..c6130087 --- /dev/null +++ b/.butcher/methods/unpinAllGeneralForumTopicMessages/entity.json @@ -0,0 +1,25 @@ +{ + "meta": {}, + "group": { + "title": "Available methods", + "anchor": "available-methods" + }, + "object": { + "anchor": "unpinallgeneralforumtopicmessages", + "name": "unpinAllGeneralForumTopicMessages", + "description": "Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.", + "html_description": "

Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.

", + "rst_description": "Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the *can_pin_messages* administrator right in the supergroup. Returns :code:`True` on success.", + "annotations": [ + { + "type": "Integer or String", + "required": true, + "description": "Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)", + "html_description": "Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)", + "rst_description": "Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)\n", + "name": "chat_id" + } + ], + "category": "methods" + } +} diff --git a/.butcher/schema/schema.json b/.butcher/schema/schema.json index fa7a76d3..d4ec9ad1 100644 --- a/.butcher/schema/schema.json +++ b/.butcher/schema/schema.json @@ -1,7 +1,7 @@ { "api": { - "version": "6.7", - "release_date": "2023-04-21" + "version": "6.8", + "release_date": "2023-08-18" }, "items": [ { @@ -547,6 +547,14 @@ "name": "emoji_status_custom_emoji_id", "required": false }, + { + "type": "Integer", + "description": "Expiration date of the emoji status of the other party in a private chat, if any. Returned only in getChat.", + "html_description": "Optional. Expiration date of the emoji status of the other party in a private chat, if any. Returned only in getChat.", + "rst_description": "*Optional*. Expiration date of the emoji status of the other party in a private chat, if any. Returned only in :class:`aiogram.methods.get_chat.GetChat`.\n", + "name": "emoji_status_expiration_date", + "required": false + }, { "type": "String", "description": "Bio of the other party in a private chat. Returned only in getChat.", @@ -917,6 +925,14 @@ "name": "sticker", "required": false }, + { + "type": "Story", + "description": "Message is a forwarded story", + "html_description": "Optional. Message is a forwarded story", + "rst_description": "*Optional*. Message is a forwarded story\n", + "name": "story", + "required": false + }, { "type": "Video", "description": "Message is a video, information about the video", @@ -1628,6 +1644,15 @@ ], "category": "types" }, + { + "anchor": "story", + "name": "Story", + "description": "This object represents a message about a forwarded story in the chat. Currently holds no information.", + "html_description": "

This object represents a message about a forwarded story in the chat. Currently holds no information.

", + "rst_description": "This object represents a message about a forwarded story in the chat. Currently holds no information.", + "annotations": [], + "category": "types" + }, { "anchor": "video", "name": "Video", @@ -1935,19 +1960,27 @@ "name": "poll_id", "required": true }, + { + "type": "Chat", + "description": "The chat that changed the answer to the poll, if the voter is anonymous", + "html_description": "Optional. The chat that changed the answer to the poll, if the voter is anonymous", + "rst_description": "*Optional*. The chat that changed the answer to the poll, if the voter is anonymous\n", + "name": "voter_chat", + "required": false + }, { "type": "User", - "description": "The user, who changed the answer to the poll", - "html_description": "The user, who changed the answer to the poll", - "rst_description": "The user, who changed the answer to the poll\n", + "description": "The user that changed the answer to the poll, if the voter isn't anonymous", + "html_description": "Optional. The user that changed the answer to the poll, if the voter isn't anonymous", + "rst_description": "*Optional*. The user that changed the answer to the poll, if the voter isn't anonymous\n", "name": "user", - "required": true + "required": false }, { "type": "Array of Integer", - "description": "0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.", - "html_description": "0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.", - "rst_description": "0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.\n", + "description": "0-based identifiers of chosen answer options. May be empty if the vote was retracted.", + "html_description": "0-based identifiers of chosen answer options. May be empty if the vote was retracted.", + "rst_description": "0-based identifiers of chosen answer options. May be empty if the vote was retracted.\n", "name": "option_ids", "required": true } @@ -7945,6 +7978,24 @@ ], "category": "methods" }, + { + "anchor": "unpinallgeneralforumtopicmessages", + "name": "unpinAllGeneralForumTopicMessages", + "description": "Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.", + "html_description": "

Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.

", + "rst_description": "Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the *can_pin_messages* administrator right in the supergroup. Returns :code:`True` on success.", + "annotations": [ + { + "type": "Integer or String", + "required": true, + "description": "Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)", + "html_description": "Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)", + "rst_description": "Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)\n", + "name": "chat_id" + } + ], + "category": "methods" + }, { "anchor": "answercallbackquery", "name": "answerCallbackQuery", diff --git a/.butcher/types/Chat/aliases.yml b/.butcher/types/Chat/aliases.yml index 4538f7e1..89b5843c 100644 --- a/.butcher/types/Chat/aliases.yml +++ b/.butcher/types/Chat/aliases.yml @@ -106,3 +106,7 @@ delete_photo: set_photo: method: setChatPhoto fill: *self + +unpin_all_general_forum_topic_messages: + method: unpinAllGeneralForumTopicMessages + fill: *self diff --git a/.butcher/types/Chat/entity.json b/.butcher/types/Chat/entity.json index 7aa42c18..4bc1fb60 100644 --- a/.butcher/types/Chat/entity.json +++ b/.butcher/types/Chat/entity.json @@ -91,6 +91,14 @@ "name": "emoji_status_custom_emoji_id", "required": false }, + { + "type": "Integer", + "description": "Expiration date of the emoji status of the other party in a private chat, if any. Returned only in getChat.", + "html_description": "Optional. Expiration date of the emoji status of the other party in a private chat, if any. Returned only in getChat.", + "rst_description": "*Optional*. Expiration date of the emoji status of the other party in a private chat, if any. Returned only in :class:`aiogram.methods.get_chat.GetChat`.\n", + "name": "emoji_status_expiration_date", + "required": false + }, { "type": "String", "description": "Bio of the other party in a private chat. Returned only in getChat.", diff --git a/.butcher/types/Chat/replace.yml b/.butcher/types/Chat/replace.yml new file mode 100644 index 00000000..93d76533 --- /dev/null +++ b/.butcher/types/Chat/replace.yml @@ -0,0 +1,5 @@ +annotations: + emoji_status_expiration_date: + parsed_type: + type: std + name: datetime.datetime diff --git a/.butcher/types/Message/entity.json b/.butcher/types/Message/entity.json index cd5e27cb..ef639796 100644 --- a/.butcher/types/Message/entity.json +++ b/.butcher/types/Message/entity.json @@ -227,6 +227,14 @@ "name": "sticker", "required": false }, + { + "type": "Story", + "description": "Message is a forwarded story", + "html_description": "Optional. Message is a forwarded story", + "rst_description": "*Optional*. Message is a forwarded story\n", + "name": "story", + "required": false + }, { "type": "Video", "description": "Message is a video, information about the video", diff --git a/.butcher/types/Message/replace.yml b/.butcher/types/Message/replace.yml index 9a3a2842..93a8f17e 100644 --- a/.butcher/types/Message/replace.yml +++ b/.butcher/types/Message/replace.yml @@ -3,3 +3,7 @@ annotations: parsed_type: type: std name: datetime.datetime + forward_date: + parsed_type: + type: std + name: datetime.datetime diff --git a/.butcher/types/PollAnswer/entity.json b/.butcher/types/PollAnswer/entity.json index 9081b30c..3b14d6dc 100644 --- a/.butcher/types/PollAnswer/entity.json +++ b/.butcher/types/PollAnswer/entity.json @@ -19,19 +19,27 @@ "name": "poll_id", "required": true }, + { + "type": "Chat", + "description": "The chat that changed the answer to the poll, if the voter is anonymous", + "html_description": "Optional. The chat that changed the answer to the poll, if the voter is anonymous", + "rst_description": "*Optional*. The chat that changed the answer to the poll, if the voter is anonymous\n", + "name": "voter_chat", + "required": false + }, { "type": "User", - "description": "The user, who changed the answer to the poll", - "html_description": "The user, who changed the answer to the poll", - "rst_description": "The user, who changed the answer to the poll\n", + "description": "The user that changed the answer to the poll, if the voter isn't anonymous", + "html_description": "Optional. The user that changed the answer to the poll, if the voter isn't anonymous", + "rst_description": "*Optional*. The user that changed the answer to the poll, if the voter isn't anonymous\n", "name": "user", - "required": true + "required": false }, { "type": "Array of Integer", - "description": "0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.", - "html_description": "0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.", - "rst_description": "0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.\n", + "description": "0-based identifiers of chosen answer options. May be empty if the vote was retracted.", + "html_description": "0-based identifiers of chosen answer options. May be empty if the vote was retracted.", + "rst_description": "0-based identifiers of chosen answer options. May be empty if the vote was retracted.\n", "name": "option_ids", "required": true } diff --git a/.butcher/types/Story/entity.json b/.butcher/types/Story/entity.json new file mode 100644 index 00000000..77ab9bea --- /dev/null +++ b/.butcher/types/Story/entity.json @@ -0,0 +1,16 @@ +{ + "meta": {}, + "group": { + "title": "Available types", + "anchor": "available-types" + }, + "object": { + "anchor": "story", + "name": "Story", + "description": "This object represents a message about a forwarded story in the chat. Currently holds no information.", + "html_description": "

This object represents a message about a forwarded story in the chat. Currently holds no information.

", + "rst_description": "This object represents a message about a forwarded story in the chat. Currently holds no information.", + "annotations": [], + "category": "types" + } +} diff --git a/CHANGES/1275.misc.rst b/CHANGES/1275.misc.rst new file mode 100644 index 00000000..581fe321 --- /dev/null +++ b/CHANGES/1275.misc.rst @@ -0,0 +1 @@ +Added support for `Bot API 6.8 `_ diff --git a/README.rst b/README.rst index 7c66c6e2..8975139c 100644 --- a/README.rst +++ b/README.rst @@ -52,7 +52,7 @@ Features - Asynchronous (`asyncio docs `_, :pep:`492`) - Has type hints (:pep:`484`) and can be used with `mypy `_ - Supports `PyPy `_ -- Supports `Telegram Bot API 6.7 `_ and gets fast updates to the latest versions of the Bot API +- Supports `Telegram Bot API 6.8 `_ and gets fast updates to the latest versions of the Bot API - Telegram Bot API integration code was `autogenerated `_ and can be easily re-generated when API gets updated - Updates router (Blueprints) - Has Finite State Machine diff --git a/aiogram/__meta__.py b/aiogram/__meta__.py index 97342ec3..24e07b53 100644 --- a/aiogram/__meta__.py +++ b/aiogram/__meta__.py @@ -1,2 +1,2 @@ __version__ = "3.0.0rc2" -__api_version__ = "6.7" +__api_version__ = "6.8" diff --git a/aiogram/client/bot.py b/aiogram/client/bot.py index b7cda3ea..1bf48356 100644 --- a/aiogram/client/bot.py +++ b/aiogram/client/bot.py @@ -134,6 +134,7 @@ from ..methods import ( UnhideGeneralForumTopic, UnpinAllChatMessages, UnpinAllForumTopicMessages, + UnpinAllGeneralForumTopicMessages, UnpinChatMessage, UploadStickerFile, ) @@ -4086,3 +4087,23 @@ class Bot: language_code=language_code, ) return await self(call, request_timeout=request_timeout) + + async def unpin_all_general_forum_topic_messages( + self, + chat_id: Union[int, str], + request_timeout: Optional[int] = None, + ) -> bool: + """ + Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the *can_pin_messages* administrator right in the supergroup. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`) + :param request_timeout: Request timeout + :return: Returns :code:`True` on success. + """ + + call = UnpinAllGeneralForumTopicMessages( + chat_id=chat_id, + ) + return await self(call, request_timeout=request_timeout) diff --git a/aiogram/enums/content_type.py b/aiogram/enums/content_type.py index 52a9bfed..d34d878e 100644 --- a/aiogram/enums/content_type.py +++ b/aiogram/enums/content_type.py @@ -14,6 +14,7 @@ class ContentType(str, Enum): DOCUMENT = "document" PHOTO = "photo" STICKER = "sticker" + STORY = "story" VIDEO = "video" VIDEO_NOTE = "video_note" VOICE = "voice" diff --git a/aiogram/methods/__init__.py b/aiogram/methods/__init__.py index fd887d7e..32909f4a 100644 --- a/aiogram/methods/__init__.py +++ b/aiogram/methods/__init__.py @@ -110,6 +110,7 @@ from .unban_chat_sender_chat import UnbanChatSenderChat from .unhide_general_forum_topic import UnhideGeneralForumTopic from .unpin_all_chat_messages import UnpinAllChatMessages from .unpin_all_forum_topic_messages import UnpinAllForumTopicMessages +from .unpin_all_general_forum_topic_messages import UnpinAllGeneralForumTopicMessages from .unpin_chat_message import UnpinChatMessage from .upload_sticker_file import UploadStickerFile @@ -228,6 +229,7 @@ __all__ = ( "UnhideGeneralForumTopic", "UnpinAllChatMessages", "UnpinAllForumTopicMessages", + "UnpinAllGeneralForumTopicMessages", "UnpinChatMessage", "UploadStickerFile", ) diff --git a/aiogram/methods/unpin_all_general_forum_topic_messages.py b/aiogram/methods/unpin_all_general_forum_topic_messages.py new file mode 100644 index 00000000..be76c198 --- /dev/null +++ b/aiogram/methods/unpin_all_general_forum_topic_messages.py @@ -0,0 +1,30 @@ +from typing import TYPE_CHECKING, Any, Union + +from aiogram.methods import TelegramMethod + + +class UnpinAllGeneralForumTopicMessages(TelegramMethod[bool]): + """ + Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the *can_pin_messages* administrator right in the supergroup. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages + """ + + __returning__ = bool + __api_method__ = "unpinAllGeneralForumTopicMessages" + + chat_id: Union[int, str] + """Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)""" + + if TYPE_CHECKING: + # DO NOT EDIT MANUALLY!!! + # This section was auto-generated via `butcher` + + def __init__( + __pydantic__self__, *, chat_id: Union[int, str], **__pydantic_kwargs: Any + ) -> None: + # DO NOT EDIT MANUALLY!!! + # This method was auto-generated via `butcher` + # Is needed only for type checking and IDE support without any additional plugins + + super().__init__(chat_id=chat_id, **__pydantic_kwargs) diff --git a/aiogram/types/__init__.py b/aiogram/types/__init__.py index a669cbe8..bf9c02ee 100644 --- a/aiogram/types/__init__.py +++ b/aiogram/types/__init__.py @@ -140,6 +140,7 @@ from .shipping_option import ShippingOption from .shipping_query import ShippingQuery from .sticker import Sticker from .sticker_set import StickerSet +from .story import Story from .successful_payment import SuccessfulPayment from .switch_inline_query_chosen_chat import SwitchInlineQueryChosenChat from .update import Update @@ -298,6 +299,7 @@ __all__ = ( "ShippingQuery", "Sticker", "StickerSet", + "Story", "SuccessfulPayment", "SwitchInlineQueryChosenChat", "TelegramObject", diff --git a/aiogram/types/chat.py b/aiogram/types/chat.py index 6c36ae5a..2046eca8 100644 --- a/aiogram/types/chat.py +++ b/aiogram/types/chat.py @@ -34,6 +34,7 @@ if TYPE_CHECKING: UnbanChatSenderChat, UnpinAllChatMessages, UnpinChatMessage, + UnpinAllGeneralForumTopicMessages, ) from .chat_location import ChatLocation from .chat_permissions import ChatPermissions @@ -69,6 +70,8 @@ class Chat(TelegramObject): """*Optional*. If non-empty, the list of all `active chat usernames `_; for private chats, supergroups and channels. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" emoji_status_custom_emoji_id: Optional[str] = None """*Optional*. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" + emoji_status_expiration_date: Optional[datetime.datetime] = None + """*Optional*. Expiration date of the emoji status of the other party in a private chat, if any. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" bio: Optional[str] = None """*Optional*. Bio of the other party in a private chat. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" has_private_forwards: Optional[bool] = None @@ -123,6 +126,7 @@ class Chat(TelegramObject): photo: Optional[ChatPhoto] = None, active_usernames: Optional[List[str]] = None, emoji_status_custom_emoji_id: Optional[str] = None, + emoji_status_expiration_date: Optional[datetime.datetime] = None, bio: Optional[str] = None, has_private_forwards: Optional[bool] = None, has_restricted_voice_and_video_messages: Optional[bool] = None, @@ -158,6 +162,7 @@ class Chat(TelegramObject): photo=photo, active_usernames=active_usernames, emoji_status_custom_emoji_id=emoji_status_custom_emoji_id, + emoji_status_expiration_date=emoji_status_expiration_date, bio=bio, has_private_forwards=has_private_forwards, has_restricted_voice_and_video_messages=has_restricted_voice_and_video_messages, @@ -1082,3 +1087,29 @@ class Chat(TelegramObject): photo=photo, **kwargs, ).as_(self._bot) + + def unpin_all_general_forum_topic_messages( + self, + **kwargs: Any, + ) -> UnpinAllGeneralForumTopicMessages: + """ + Shortcut for method :class:`aiogram.methods.unpin_all_general_forum_topic_messages.UnpinAllGeneralForumTopicMessages` + will automatically fill method attributes: + + - :code:`chat_id` + + Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the *can_pin_messages* administrator right in the supergroup. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages + + :return: instance of method :class:`aiogram.methods.unpin_all_general_forum_topic_messages.UnpinAllGeneralForumTopicMessages` + """ + # DO NOT EDIT MANUALLY!!! + # This method was auto-generated via `butcher` + + from aiogram.methods import UnpinAllGeneralForumTopicMessages + + return UnpinAllGeneralForumTopicMessages( + chat_id=self.id, + **kwargs, + ).as_(self._bot) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index c8fd7c5a..7e9c282a 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -84,6 +84,7 @@ if TYPE_CHECKING: from .reply_keyboard_markup import ReplyKeyboardMarkup from .reply_keyboard_remove import ReplyKeyboardRemove from .sticker import Sticker + from .story import Story from .successful_payment import SuccessfulPayment from .user import User from .user_shared import UserShared @@ -128,7 +129,7 @@ class Message(TelegramObject): """*Optional*. For forwarded messages that were originally sent in channels or by an anonymous chat administrator, signature of the message sender if present""" forward_sender_name: Optional[str] = None """*Optional*. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages""" - forward_date: Optional[int] = None + forward_date: Optional[datetime.datetime] = None """*Optional*. For forwarded messages, date the original message was sent in Unix time""" is_topic_message: Optional[bool] = None """*Optional*. :code:`True`, if the message is sent to a forum topic""" @@ -160,6 +161,8 @@ class Message(TelegramObject): """*Optional*. Message is a photo, available sizes of the photo""" sticker: Optional[Sticker] = None """*Optional*. Message is a sticker, information about the sticker""" + story: Optional[Story] = None + """*Optional*. Message is a forwarded story""" video: Optional[Video] = None """*Optional*. Message is a video, information about the video""" video_note: Optional[VideoNote] = None @@ -267,7 +270,7 @@ class Message(TelegramObject): forward_from_message_id: Optional[int] = None, forward_signature: Optional[str] = None, forward_sender_name: Optional[str] = None, - forward_date: Optional[int] = None, + forward_date: Optional[datetime.datetime] = None, is_topic_message: Optional[bool] = None, is_automatic_forward: Optional[bool] = None, reply_to_message: Optional[Message] = None, @@ -283,6 +286,7 @@ class Message(TelegramObject): document: Optional[Document] = None, photo: Optional[List[PhotoSize]] = None, sticker: Optional[Sticker] = None, + story: Optional[Story] = None, video: Optional[Video] = None, video_note: Optional[VideoNote] = None, voice: Optional[Voice] = None, @@ -361,6 +365,7 @@ class Message(TelegramObject): document=document, photo=photo, sticker=sticker, + story=story, video=video, video_note=video_note, voice=voice, @@ -496,6 +501,8 @@ class Message(TelegramObject): return ContentType.USER_SHARED if self.chat_shared: return ContentType.CHAT_SHARED + if self.story: + return ContentType.STORY return ContentType.UNKNOWN diff --git a/aiogram/types/poll_answer.py b/aiogram/types/poll_answer.py index beb6ef09..c12be34f 100644 --- a/aiogram/types/poll_answer.py +++ b/aiogram/types/poll_answer.py @@ -1,10 +1,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, List +from typing import TYPE_CHECKING, Any, List, Optional from .base import TelegramObject if TYPE_CHECKING: + from .chat import Chat from .user import User @@ -17,10 +18,12 @@ class PollAnswer(TelegramObject): poll_id: str """Unique poll identifier""" - user: User - """The user, who changed the answer to the poll""" option_ids: List[int] - """0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.""" + """0-based identifiers of chosen answer options. May be empty if the vote was retracted.""" + voter_chat: Optional[Chat] = None + """*Optional*. The chat that changed the answer to the poll, if the voter is anonymous""" + user: Optional[User] = None + """*Optional*. The user that changed the answer to the poll, if the voter isn't anonymous""" if TYPE_CHECKING: # DO NOT EDIT MANUALLY!!! @@ -30,8 +33,9 @@ class PollAnswer(TelegramObject): __pydantic__self__, *, poll_id: str, - user: User, option_ids: List[int], + voter_chat: Optional[Chat] = None, + user: Optional[User] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! @@ -39,5 +43,9 @@ class PollAnswer(TelegramObject): # Is needed only for type checking and IDE support without any additional plugins super().__init__( - poll_id=poll_id, user=user, option_ids=option_ids, **__pydantic_kwargs + poll_id=poll_id, + option_ids=option_ids, + voter_chat=voter_chat, + user=user, + **__pydantic_kwargs, ) diff --git a/aiogram/types/story.py b/aiogram/types/story.py new file mode 100644 index 00000000..dc92c575 --- /dev/null +++ b/aiogram/types/story.py @@ -0,0 +1,9 @@ +from aiogram.types import TelegramObject + + +class Story(TelegramObject): + """ + This object represents a message about a forwarded story in the chat. Currently holds no information. + + Source: https://core.telegram.org/bots/api#story + """ diff --git a/docs/api/methods/index.rst b/docs/api/methods/index.rst index 4a7f4b01..e63e35b7 100644 --- a/docs/api/methods/index.rst +++ b/docs/api/methods/index.rst @@ -86,6 +86,7 @@ Available methods unhide_general_forum_topic unpin_all_chat_messages unpin_all_forum_topic_messages + unpin_all_general_forum_topic_messages unpin_chat_message Payments diff --git a/docs/api/methods/unpin_all_general_forum_topic_messages.rst b/docs/api/methods/unpin_all_general_forum_topic_messages.rst new file mode 100644 index 00000000..b71da566 --- /dev/null +++ b/docs/api/methods/unpin_all_general_forum_topic_messages.rst @@ -0,0 +1,51 @@ +################################# +unpinAllGeneralForumTopicMessages +################################# + +Returns: :obj:`bool` + +.. automodule:: aiogram.methods.unpin_all_general_forum_topic_messages + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: bool = await bot.unpin_all_general_forum_topic_messages(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.unpin_all_general_forum_topic_messages import UnpinAllGeneralForumTopicMessages` +- alias: :code:`from aiogram.methods import UnpinAllGeneralForumTopicMessages` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: bool = await bot(UnpinAllGeneralForumTopicMessages(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return UnpinAllGeneralForumTopicMessages(...) + + +As shortcut from received object +-------------------------------- + +- :meth:`aiogram.types.chat.Chat.unpin_all_general_forum_topic_messages` diff --git a/docs/api/types/index.rst b/docs/api/types/index.rst index 930e9354..20d71e22 100644 --- a/docs/api/types/index.rst +++ b/docs/api/types/index.rst @@ -123,6 +123,7 @@ Available types reply_keyboard_markup reply_keyboard_remove response_parameters + story switch_inline_query_chosen_chat user user_profile_photos diff --git a/docs/api/types/story.rst b/docs/api/types/story.rst new file mode 100644 index 00000000..68565b39 --- /dev/null +++ b/docs/api/types/story.rst @@ -0,0 +1,10 @@ +##### +Story +##### + + +.. automodule:: aiogram.types.story + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields diff --git a/tests/test_api/test_methods/test_unpin_all_general_forum_topic_messages.py b/tests/test_api/test_methods/test_unpin_all_general_forum_topic_messages.py new file mode 100644 index 00000000..406a98a7 --- /dev/null +++ b/tests/test_api/test_methods/test_unpin_all_general_forum_topic_messages.py @@ -0,0 +1,15 @@ +from aiogram.methods import Request, UnpinAllForumTopicMessages, UnpinAllGeneralForumTopicMessages +from tests.mocked_bot import MockedBot + + +class TestUnpinAllForumTopicMessages: + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + UnpinAllGeneralForumTopicMessages, ok=True, result=True + ) + + response: bool = await bot.unpin_all_general_forum_topic_messages( + chat_id=42, + ) + request = bot.get_request() + assert response == prepare_result.result diff --git a/tests/test_api/test_types/test_chat.py b/tests/test_api/test_types/test_chat.py index 03cb8963..14cc3dc2 100644 --- a/tests/test_api/test_types/test_chat.py +++ b/tests/test_api/test_types/test_chat.py @@ -207,3 +207,9 @@ class TestChat: ): chat = Chat(id=42, first_name=first, last_name=last, title=title, type=chat_type) assert chat.full_name == result + + def test_unpin_all_general_forum_topic_messages(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.unpin_all_general_forum_topic_messages() + assert method.chat_id == chat.id diff --git a/tests/test_api/test_types/test_message.py b/tests/test_api/test_types/test_message.py index f0a34b09..9d3835b6 100644 --- a/tests/test_api/test_types/test_message.py +++ b/tests/test_api/test_types/test_message.py @@ -73,6 +73,7 @@ from aiogram.types import ( VideoNote, Voice, WebAppData, + Story, ) from aiogram.types.message import ContentType, Message @@ -455,6 +456,15 @@ TEST_CHAT_SHARED = Message( from_user=User(id=42, is_bot=False, first_name="Test"), chat_shared=ChatShared(request_id=42, chat_id=42), ) +TEST_MESSAGE_STORY = Message( + message_id=42, + date=datetime.datetime.now(), + chat=Chat(id=42, type="private"), + from_user=User(id=42, is_bot=False, first_name="Test"), + story=Story(), + forward_signature="Test", + forward_date=datetime.datetime.now(), +) TEST_MESSAGE_UNKNOWN = Message( message_id=42, date=datetime.datetime.now(), @@ -516,6 +526,7 @@ class TestMessage: [TEST_FORUM_TOPIC_REOPENED, ContentType.FORUM_TOPIC_REOPENED], [TEST_USER_SHARED, ContentType.USER_SHARED], [TEST_CHAT_SHARED, ContentType.CHAT_SHARED], + [TEST_MESSAGE_STORY, ContentType.STORY], [TEST_MESSAGE_UNKNOWN, ContentType.UNKNOWN], ], )