From 0b69f5e5781fb2ad159a8f04a81e643afe54bd1e Mon Sep 17 00:00:00 2001 From: akchonya Date: Sun, 31 Mar 2024 22:20:53 +0300 Subject: [PATCH] add default bot properties and clean imports --- examples/echo_bot.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/echo_bot.py b/examples/echo_bot.py index 7cb1babe..2808de7f 100644 --- a/examples/echo_bot.py +++ b/examples/echo_bot.py @@ -3,11 +3,11 @@ import logging import sys from os import getenv -from aiogram import Bot, Dispatcher, Router, types +from aiogram import Bot, Dispatcher, html +from aiogram.client.default import DefaultBotProperties from aiogram.enums import ParseMode from aiogram.filters import CommandStart from aiogram.types import Message -from aiogram.utils.markdown import hbold # Bot token can be obtained via https://t.me/BotFather TOKEN = getenv("BOT_TOKEN") @@ -26,11 +26,11 @@ async def command_start_handler(message: Message) -> None: # and the target chat will be passed to :ref:`aiogram.methods.send_message.SendMessage` # method automatically or call API method directly via # Bot instance: `bot.send_message(chat_id=message.chat.id, ...)` - await message.answer(f"Hello, {hbold(message.from_user.full_name)}!") + await message.answer(f"Hello, {html.bold(message.from_user.full_name)}!") @dp.message() -async def echo_handler(message: types.Message) -> None: +async def echo_handler(message: Message) -> None: """ Handler will forward receive a message back to the sender @@ -45,8 +45,8 @@ async def echo_handler(message: types.Message) -> None: async def main() -> None: - # Initialize Bot instance with a default parse mode which will be passed to all API calls - bot = Bot(TOKEN, parse_mode=ParseMode.HTML) + # Initialize Bot instance with default bot properties which will be passed to all API calls + bot = Bot(token=TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML)) # And the run events dispatching await dp.start_polling(bot)