F
F
From Prog2021-08-03 16:16:30
Python
From Prog, 2021-08-03 16:16:30

aiogram.utils.exceptions.BadRequest: Unsupported parse_mode?

The code:

@dptr.message_handler(state=Finance_states.to_convert)
async def answer_for_act_to_small(message: types.Message, state: FSMContext):
  can_do = True
  await state.update_data(text=message.text)
  data = await state.get_data()
  global currency_for_currency_converter
  currency_for_currency_converter = data['text']
  if currency_for_currency_converter != ' RUB' and currency_for_currency_converter != ' USD' and currency_for_currency_converter != ' EUR' and currency_for_currency_converter != ' GBP' and currency_for_currency_converter != ' JPY' and currency_for_currency_converter != ' AED' and currency_for_currency_converter != ' CHF' and currency_for_currency_converter != ' CNY' and currency_for_currency_converter != ' KZT' and currency_for_currency_converter != ' THB' and currency_for_currency_converter != ' AZN' and currency_for_currency_converter != ' CAD':
    if users_id_and_selected_language[message.chat.id] == 'ru':
      try:
        await state.finish()
      except KeyError:
        await message.answer(message.chat.id, 'Такой валюты нет в списке, выберите валюту', reply_markup=currency_converterkbd)
        await Finance_states.to_convert.set()
    elif users_id_and_selected_language[message.chat.id] == 'en':
      try:
        await state.finish()
      except KeyError:
        await message.answer(message.chat.id, "This currency is not on the list, choose currency", reply_markup=currency_converterkbd_en)
    can_do = False

We ask the user for the currency, and go to this handler, if the currency is not in the list, then the code is executed, and an error occurs:try: await state.finish()
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-46' coro=<Dispatcher._process_polling_updates() done, defined at C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\dispatcher.py:409> exception=BadRequest('Unsupported parse_mode')>
Traceback (most recent call last):
  File "H:\my_second_python_bot_for_telegram\main.py", line 289, in answer_for_act_to_small
    await state.finish()
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\storage.py", line 322, in finish
    await self.storage.finish(chat=self.chat, user=self.user)
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\storage.py", line 202, in finish
    await self.reset_state(chat=chat, user=user, with_data=True)
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\contrib\fsm_storage\memory.py", line 78, in reset_state
    self._cleanup(chat, user)
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\contrib\fsm_storage\memory.py", line 108, in _cleanup
    if self.data[chat][user] == {'state': None, 'data': {}, 'bucket': {}}:
KeyError: 627976213

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 417, in _process_polling_updates
    for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 238, in process_updates
    return await asyncio.gather(*tasks)
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 259, in process_update
    return await self.message_handlers.notify(update.message)
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "H:\my_second_python_bot_for_telegram\main.py", line 291, in answer_for_act_to_small
    await message.answer(message.chat.id, 'Такой валюты нет в списке, выберите валюту', reply_markup=currency_converterkbd)
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\types\message.py", line 361, in answer
    return await self.bot.send_message(
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\bot.py", line 314, in send_message
    result = await self.request(api.Methods.SEND_MESSAGE, payload)
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\base.py", line 208, in request
    return await api.make_request(self.session, self.server, self.__token, method, data, files,
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\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\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\api.py", line 115, in check_result
    exceptions.BadRequest.detect(description)
  File "C:\Users\v3011\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\utils\exceptions.py", line 141, in detect
    raise cls(description)
aiogram.utils.exceptions.BadRequest: Unsupported parse_mode


If you need anything else, I can send

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
From Prog, 2021-08-03
@FromProg

The error was in another, corrected

A
alternativshik, 2021-08-03
@alternativshik

KeyError: 627976213

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question