From 7e14c2232eaed47f570543f59617efafefcf6730 Mon Sep 17 00:00:00 2001 From: LTY_CK_TS Date: Mon, 4 Mar 2024 00:44:34 +0000 Subject: [PATCH] =?UTF-8?q?rate=20=E4=BF=AE=E5=A4=8DAPI=20(#20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 2 +- rate.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/list.json b/list.json index 227a342..394003a 100644 --- a/list.json +++ b/list.json @@ -82,7 +82,7 @@ }, { "name": "rate", - "version": "1.411", + "version": "1.412", "section": "daily", "maintainer": "fruitymelon", "size": "3.4 kb", diff --git a/rate.py b/rate.py index 761fef2..545be54 100644 --- a/rate.py +++ b/rate.py @@ -21,7 +21,7 @@ if config["application_language"] == "en": "notice": "Data are updated daily, for encrypted currencies we recommend to use the `bc` plugin.", "warning": "Data are updated daily"} -API = "https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies.json" +API = "https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies.json" currencies = [] data = {} @@ -88,12 +88,12 @@ async def rate(context): if currencies.count(TO) == 0: await context.edit(f"{TO}{lang_rate['nc']}{', '.join(currencies)}`") return - endpoint = f"https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/{FROM.lower()}/{TO.lower()}.json" + endpoint = f"https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/{FROM.lower()}.json" with urllib.request.urlopen(endpoint) as response: result = response.read() try: rate_data = json.loads(result) await context.edit( - f'`{FROM} : {TO} = {NB} : {round(NB * rate_data[TO.lower()], 4)}`\n\n{lang_rate["warning"]}') + f'`{FROM} : {TO} = {NB} : {round(NB * rate_data[FROM.lower()][TO.lower()], 4)}`\n\n{lang_rate["warning"]}') except Exception as e: await context.edit(str(e))