From fc133973f1b5919b7a40cfe655ca9c371be735dc Mon Sep 17 00:00:00 2001 From: Aleksei Krugliak Date: Sun, 24 Apr 2022 00:04:48 +0400 Subject: [PATCH] add currencies code --- handlers/users/currencies.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 handlers/users/currencies.py diff --git a/handlers/users/currencies.py b/handlers/users/currencies.py new file mode 100644 index 0000000..ac119d0 --- /dev/null +++ b/handlers/users/currencies.py @@ -0,0 +1,22 @@ +from aiogram import types +from loader import dp +import json + + +@dp.message_handler(commands="currencies") +async def get_currencies(message: types.Message): + import requests + import datetime + url = 'https://nbg.gov.ge/gw/api/ct/monetarypolicy/currencies/en/json/' + date = datetime.date.today().isoformat() + payload = {'currencies': ['USD', 'EUR'], 'date': date} + r = requests.get(url, params=payload) + print(r.text) + usd = json.loads(r.text) + for elem in usd: + # print(elem['currencies']) + for each in elem['currencies']: + # print(each) + # print(each['code'] + " " + each['rateFormated']) + await message.answer(each['code'] + " " + each['rateFormated']) + # print(r.status_code)