Archived
1
0
Fork 0
This commit is contained in:
多羅狼 2023-05-21 22:23:10 +08:00 committed by GitHub
parent 76c2359e70
commit cf7d71bf2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,10 +66,14 @@ async def exchange(base_currency, target_currency, amount: float, msg):
@excr.regex(r"(\d+(\.\d+)?)([a-zA-Z]{3})[至|到| to ]([a-zA-Z]{3})", desc='{exchange_rate.help.regex}')
@excr.regex(r"(\d+(\.\d+)? )?([a-zA-Z]{3})(到|兑| to )([a-zA-Z]{3})", desc='{exchange_rate.help.regex}')
async def _(msg: Bot.MessageSession):
groups = msg.matched_msg.groups()
amount = groups[0] if groups[0] else '1'
amount = groups[0]
try:
float(amount)
except ValueError:
amount = '1'
base = groups[2].upper()
target = groups[3].upper()
target = groups[4].upper()
await msg.finish(await exchange(base, target, amount, msg))