diff --git a/aiogram/types/chat.py b/aiogram/types/chat.py index ad005583..0021eb23 100644 --- a/aiogram/types/chat.py +++ b/aiogram/types/chat.py @@ -11,7 +11,7 @@ from .chat_permissions import ChatPermissions from .chat_photo import ChatPhoto from .input_file import InputFile from ..utils import helper, markdown -from ..utils.deprecated import deprecated +from ..utils.deprecated import deprecated, DeprecatedReadOnlyClassVar class Chat(base.TelegramObject): @@ -550,6 +550,7 @@ class ChatType(helper.Helper): :key: PRIVATE :key: GROUP :key: SUPER_GROUP + :key: SUPERGROUP :key: CHANNEL """ @@ -557,9 +558,14 @@ class ChatType(helper.Helper): PRIVATE = helper.Item() # private GROUP = helper.Item() # group - SUPER_GROUP = helper.Item() # supergroup + SUPERGROUP = helper.Item() # supergroup CHANNEL = helper.Item() # channel + SUPER_GROUP: DeprecatedReadOnlyClassVar[ChatType, helper.Item] \ + = DeprecatedReadOnlyClassVar( + "SUPER_GROUP chat type is deprecated, use SUPERGROUP instead.", + new_value_getter=lambda cls: cls.SUPERGROUP) + @staticmethod def _check(obj, chat_types) -> bool: if hasattr(obj, 'chat'): @@ -599,7 +605,7 @@ class ChatType(helper.Helper): :param obj: :return: """ - return cls._check(obj, [cls.SUPER_GROUP]) + return cls._check(obj, [cls.SUPER_GROUP, cls.SUPERGROUP]) @classmethod @deprecated("This filter was moved to ChatTypeFilter, and will be removed in aiogram v3.0") @@ -610,7 +616,7 @@ class ChatType(helper.Helper): :param obj: :return: """ - return cls._check(obj, [cls.GROUP, cls.SUPER_GROUP]) + return cls._check(obj, [cls.GROUP, cls.SUPER_GROUP, cls.SUPERGROUP]) @classmethod @deprecated("This filter was moved to ChatTypeFilter, and will be removed in aiogram v3.0") diff --git a/aiogram/types/input_file.py b/aiogram/types/input_file.py index 3c397395..3a78c499 100644 --- a/aiogram/types/input_file.py +++ b/aiogram/types/input_file.py @@ -4,6 +4,8 @@ import io import logging import os import secrets +from pathlib import Path +from typing import Union import aiohttp @@ -25,7 +27,7 @@ class InputFile(base.TelegramObject): https://core.telegram.org/bots/api#inputfile """ - def __init__(self, path_or_bytesio, filename=None, conf=None): + def __init__(self, path_or_bytesio: Union[str, io.IOBase, Path], filename=None, conf=None): """ :param path_or_bytesio: @@ -45,6 +47,12 @@ class InputFile(base.TelegramObject): elif isinstance(path_or_bytesio, _WebPipe): self._path = None self._file = path_or_bytesio + + elif isinstance(path_or_bytesio, Path): + self._file = path_or_bytesio.open("rb") + self._path = path_or_bytesio.resolve() + if filename is None: + filename = path_or_bytesio.name else: raise TypeError('Not supported file type.') diff --git a/docs/source/quick_start.rst b/docs/source/quick_start.rst index 319886ce..eb8551db 100644 --- a/docs/source/quick_start.rst +++ b/docs/source/quick_start.rst @@ -24,7 +24,7 @@ Next step: interaction with bots starts with one command. Register your first co :language: python :lines: 20-25 -If you want to handle all messages in the chat simply add handler without filters: +If you want to handle all text messages in the chat simply add handler without filters: .. literalinclude:: ../../examples/echo_bot.py :language: python