Archived
1
0
Fork 0

Update convert

This commit is contained in:
多羅狼 2023-05-31 23:31:01 +08:00 committed by GitHub
parent 0225dafa96
commit 65f15ebc5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,10 @@ i = module('convert', alias=('conv', 'unit'), desc='{convert.help.desc}',
async def _(msg: Bot.MessageSession):
from_val = msg.parsed_msg['<from_val>']
to_unit = msg.parsed_msg['<to_unit>']
ori = ureg.parse_expression(from_val)
res = ureg.parse_expression(from_val).to(to_unit)
try:
ori = ureg.parse_expression(from_val)
res = ureg.parse_expression(from_val).to(to_unit)
except:
await msg.finish(msg.locale.t("convert.message.error"))
await msg.finish(f"{ori:~Pg} = {res:~Pg}")