Дамы и господа, у нас 10 новых багов

This commit is contained in:
Данил 2023-10-28 22:02:29 +03:00
parent 45b19fbdcf
commit 53c861698b

12
main.py
View file

@ -7,6 +7,7 @@ import logging
import string import string
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
import aiohttp.client_exceptions
import requests import requests
from pydantic.v1 import BaseSettings from pydantic.v1 import BaseSettings
@ -125,14 +126,16 @@ class CurrencyConverter:
log.debug(data) log.debug(data)
# If the currency does not exist # If the currency does not exist
error = data.get('to')[0].get('quotecurrency') error = data.get('to')
if error is None:
if len(error) == 0:
return False return False
# Otherwise # Otherwise
conv: Dict[str, str] = data.get('to')[0] conv: Dict[str, str] = data.get('to')[0]
conv_amount = conv.get('mid') conv_amount = conv.get('mid')
if conv_amount is None:
if not conv_amount:
raise RuntimeError('Ошибка при конвертации через DDG') raise RuntimeError('Ошибка при конвертации через DDG')
self.conv_amount = float(conv_amount) self.conv_amount = float(conv_amount)
@ -215,6 +218,9 @@ async def currency(inline_query: types.InlineQuery) -> None:
f'{conv.conv_amount} {conv.conv_currency}' f'{conv.conv_amount} {conv.conv_currency}'
) )
except aiohttp.client_exceptions.ClientError:
result = "Рейт-лимит от api telegram, попробуйте позже"
except Exception as ex: except Exception as ex:
result = f'{type(ex).__name__}: {ex}' result = f'{type(ex).__name__}: {ex}'