mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-24 11:13:37 +00:00
rate 修复API (#20)
This commit is contained in:
parent
0d6191470a
commit
7e14c2232e
@ -82,7 +82,7 @@
|
||||
},
|
||||
{
|
||||
"name": "rate",
|
||||
"version": "1.411",
|
||||
"version": "1.412",
|
||||
"section": "daily",
|
||||
"maintainer": "fruitymelon",
|
||||
"size": "3.4 kb",
|
||||
|
6
rate.py
6
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))
|
||||
|
Loading…
Reference in New Issue
Block a user