import logging
from aiogram import Bot, Dispatcher, types
from aiogram.utils import executor
token = "тут токен"
bot = Bot(token)
dp = Dispatcher(bot)
logging.basicConfig(level=logging.INFO)
x = "f'@{message.chat.username}'" # глобальное переменная с тегом в телеграмме
@dp.message_handler(commands="help")
async def test1(message: types.Message):
await bot.send_message(message.chat.id, "Если нужно отойти на перерыв напиши /timeout Когда вернёшься напиши /vse")
@dp.message_handler(commands="timeout")
async def test2(message: types.Message):
await bot.send_message(message.chat.id,
f'@{message.chat.username} отошёл на перезарядку, кто прикроет пацана? Жмите /ok')
@dp.message_handler(commands="ok")
async def test3(message: types.Message):
await bot.send_message(message.chat.id,
x, 'пока последит за аллертами. Дежурный пропиши /vse как вернёшься') # по идее тегает человека, но сейчас не работает
@dp.message_handler(commands="vse")
async def test4(message: types.Message):
await bot.send_message(message.chat.id,
x, 'вернулся на пост') # по идее должно тегнуть того же человека, что и в функции выше
executor.start_polling(dp, skip_updates=True)
Подскажите, пожалуйста, что делаю не так? Возникает ошибка
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-14' coro=<Dispatcher._process_polling_updates() done, defined at C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py:407> exception=BadRequest('Unsupported parse_mode')>
Traceback (most recent call last):
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 415, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\smit\PycharmProjects\pythonProject\bot.py", line 29, in test3
await bot.send_message(message.chat.id,
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\bot.py", line 327, in send_message
result = await self.request(api.Methods.SEND_MESSAGE, payload)
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\base.py", line 226, in request
return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\api.py", line 140, in make_request
return check_result(method, response.content_type, response.status, await response.text())
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\api.py", line 115, in check_result
exceptions.BadRequest.detect(description)
File "C:\Users\smit\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\utils\exceptions.py", line 141, in detect
raise cls(description)
aiogram.utils.exceptions.BadRequest: Unsupported parse_mode