mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 07:08:18 +00:00
💩 rate 顺序错误
This commit is contained in:
parent
fca2ec442c
commit
a0c6ae52bc
@ -92,7 +92,7 @@
|
||||
},
|
||||
{
|
||||
"name": "rate",
|
||||
"version": "1.0",
|
||||
"version": "1.1",
|
||||
"section": "daily",
|
||||
"maintainer": "fruitymelon",
|
||||
"size": "1.7 kb",
|
||||
|
14
rate.py
14
rate.py
@ -3,8 +3,6 @@
|
||||
import asyncio, json
|
||||
from json.decoder import JSONDecodeError
|
||||
import urllib.request
|
||||
|
||||
from pagermaid import bot, log
|
||||
from pagermaid.listener import listener
|
||||
|
||||
API = "https://api.exchangeratesapi.io/latest"
|
||||
@ -13,6 +11,7 @@ data = {}
|
||||
|
||||
inited = False
|
||||
|
||||
|
||||
def init():
|
||||
with urllib.request.urlopen(API) as response:
|
||||
result = response.read()
|
||||
@ -28,8 +27,10 @@ def init():
|
||||
global inited
|
||||
inited = True
|
||||
|
||||
|
||||
init()
|
||||
|
||||
|
||||
@listener(is_plugin=True, outgoing=True, command="rate",
|
||||
description="Currency exchange rate plugin.",
|
||||
parameters="<FROM> <TO>")
|
||||
@ -37,7 +38,8 @@ async def rate(context):
|
||||
while not inited:
|
||||
await asyncio.sleep(1)
|
||||
if not context.parameter:
|
||||
await context.edit(f"This is the currency exchange rate plugin.\n\nUsage: `-rate <FROM> <TO>`\n\nAvailable currencies: {', '.join(currencies)}")
|
||||
await context.edit(
|
||||
f"This is the currency exchange rate plugin.\n\nUsage: `-rate <FROM> <TO>`\n\nAvailable currencies: {', '.join(currencies)}")
|
||||
return
|
||||
if len(context.parameter) != 2:
|
||||
await context.edit(f"Usage: `-rate <FROM> <TO>`\n\n`{', '.join(currencies)}`")
|
||||
@ -45,10 +47,10 @@ async def rate(context):
|
||||
FROM = context.parameter[0].upper().strip()
|
||||
TO = context.parameter[1].upper().strip()
|
||||
if currencies.count(FROM) == 0:
|
||||
await context.edit(f"Currency type {FROM} is not supported. Choose one among `{', '.join(currencies)}` instead.")
|
||||
await context.edit(
|
||||
f"Currency type {FROM} is not supported. Choose one among `{', '.join(currencies)}` instead.")
|
||||
return
|
||||
if currencies.count(TO) == 0:
|
||||
await context.edit(f"Currency type {TO} is not supported. Choose one among `{', '.join(currencies)}` instead.")
|
||||
return
|
||||
await context.edit(f'{FROM} : {TO} = 1 : {int(10000*data["rates"][FROM]/data["rates"][TO])/10000}')
|
||||
|
||||
await context.edit(f'{FROM} : {TO} = 1 : {int(10000*data["rates"][TO]/data["rates"][FROM])/10000}')
|
||||
|
Loading…
Reference in New Issue
Block a user