Пофиксил баг. Если написать текст не относящийся к валюте, то бот будет игнорировать

This commit is contained in:
Данил 2024-09-26 16:09:47 +03:00
parent e3f5396d1a
commit 5b79f6699b

View file

@ -16,7 +16,7 @@ dp = Dispatcher()
@dp.message() @dp.message()
@dp.inline_query() @dp.inline_query()
async def currency(query: types.Message | types.InlineQuery) -> None: async def currency(query: types.Message | types.InlineQuery) -> None:
global result global result, from_currency_alias, conv_currency_alias
try: try:
currency_json = json.load(open('currency.json', 'r', encoding='utf-8')) currency_json = json.load(open('currency.json', 'r', encoding='utf-8'))
@ -26,6 +26,7 @@ async def currency(query: types.Message | types.InlineQuery) -> None:
conv = Converter() conv = Converter()
if len(args) <= 1: if len(args) <= 1:
if query.chat.type not in ['supergroup', 'group']:
return await reply(result_id, return await reply(result_id,
"2 or 3 arguments are required.", "2 or 3 arguments are required.",
"@shirino_bot USD RUB " "@shirino_bot USD RUB "
@ -43,6 +44,7 @@ async def currency(query: types.Message | types.InlineQuery) -> None:
from_currency_alias = args[0].lower() from_currency_alias = args[0].lower()
conv_currency_alias = args[1].lower() conv_currency_alias = args[1].lower()
else: else:
if query.chat.type not in ['supergroup', 'group']:
return await reply(result_id, 'The source and target currency could not be determined.', None, query) return await reply(result_id, 'The source and target currency could not be determined.', None, query)
from_currency, conv_currency = None, None from_currency, conv_currency = None, None