🤔
This commit is contained in:
parent
76c2359e70
commit
cf7d71bf2e
1 changed files with 7 additions and 3 deletions
|
@ -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))
|
Reference in a new issue