Compare commits

...

2 commits

2 changed files with 15 additions and 9 deletions

View file

@ -1,4 +1,8 @@
{ {
"RUB": ["руб", "рубли", "рубля", "рублей", "рубль", "rub", "rouble", "roubles"], "RUB": ["руб", "рубли", "рубля", "рублей", "рубль", "российский рубль", "rub", "rouble", "roubles", "russian rouble"],
"USD": ["доллары", "доллар", "доллара", "зеленых", "usd", "dollar", "dollars"] "USD": ["доллары", "доллар", "доллара", "долларах", "долларов", "зеленых", "бакса", "баксов", "usd", "dollar", "dollars"],
"UAH": ["гривны", "гривен", "гривен", "hryvnia"],
"EUR": ["евро", "eur", "euro", "euros"],
"KZT": ["тенге", "казахстанский тенге", "kazakhstani tenge", "tenge"],
"TRY": ["турецкая лира", "турецких лир", "try", "tl", "Turkish lira", "lira"]
} }

16
main.py
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,11 +26,12 @@ async def currency(query: types.Message | types.InlineQuery) -> None:
conv = Converter() conv = Converter()
if len(args) <= 1: if len(args) <= 1:
return await reply(result_id, if query.chat.type not in ['supergroup', 'group']:
"2 or 3 arguments are required.", return await reply(result_id,
"@shirino_bot USD RUB " "2 or 3 arguments are required.",
"\n@shirino_bot 12 USD RUB", "@shirino_bot USD RUB "
query) "\n@shirino_bot 12 USD RUB",
query)
if len(args) == 4: if len(args) == 4:
conv.amount = float(args[0]) conv.amount = float(args[0])
from_currency_alias = args[1].lower() from_currency_alias = args[1].lower()
@ -43,7 +44,8 @@ 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:
return await reply(result_id, 'The source and target currency could not be determined.', None, query) if query.chat.type not in ['supergroup', 'group']:
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