diff --git a/aiogram/client/bot.py b/aiogram/client/bot.py index 06cae1c4..93faa6aa 100644 --- a/aiogram/client/bot.py +++ b/aiogram/client/bot.py @@ -297,6 +297,36 @@ class Bot: self.__token = token self._me: Optional[User] = None + @property + def parse_mode(self) -> Optional[str]: + warnings.warn( + "Accessing `parse_mode` from Bot instance is deprecated. This attribute will be removed in 3.5.0 version\n" + "Use `bot.default.parse_mode` instead.", + category=DeprecationWarning, + stacklevel=2, + ) + return self.default.parse_mode + + @property + def disable_web_page_preview(self) -> Optional[bool]: + warnings.warn( + "Accessing `disable_web_page_preview` from Bot instance is deprecated. This attribute will be removed in 3.5.0 version\n" + "Use `bot.default.link_preview_is_disabled` instead.", + category=DeprecationWarning, + stacklevel=2, + ) + return self.default.link_preview_is_disabled + + @property + def protect_content(self) -> Optional[bool]: + warnings.warn( + "Accessing `protect_content` from Bot instance is deprecated. This attribute will be removed in 3.5.0 version\n" + "Use `bot.default.protect_content` instead.", + category=DeprecationWarning, + stacklevel=2, + ) + return self.default.protect_content + @property def token(self) -> str: return self.__token diff --git a/tests/test_api/test_client/test_bot.py b/tests/test_api/test_client/test_bot.py index 901beac2..bdac9ed9 100644 --- a/tests/test_api/test_client/test_bot.py +++ b/tests/test_api/test_client/test_bot.py @@ -49,6 +49,30 @@ class TestBot: ): bot = Bot(token="42:Test", parse_mode="HTML") + def test_deprecated_parse_mode(self): + with check_deprecated( + max_version="3.5.0", + exception=AttributeError, + ): + bot = Bot(token="42:Test", parse_mode="HTML") + assert bot.parse_mode == "HTML" + + def test_disable_web_page_preview(self): + with check_deprecated( + max_version="3.5.0", + exception=TypeError, + ): + bot = Bot(token="42:Test", disable_web_page_preview=True) + assert bot.disable_web_page_preview is True + + def test_deprecated_protect_content(self): + with check_deprecated( + max_version="3.5.0", + exception=AttributeError, + ): + bot = Bot(token="42:Test", protect_content=True) + assert bot.protect_content is True + def test_hashable(self): bot = Bot("42:TEST") assert hash(bot) == hash("42:TEST")