Archived
1
0
Fork 0
This commit is contained in:
多羅狼 2024-01-31 17:58:30 +08:00 committed by GitHub
parent 9c1a26ee0f
commit 4769aed84a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,7 +13,7 @@ no_solution = ['无解', '無解', 'none', 'n/a']
def calc(expr):
expr = expr.replace("\\", "")
try:
return round(simple_eval(expr))
return simple_eval(expr)
except Exception:
return None
@ -124,7 +124,8 @@ async def _(msg: Bot.MessageSession):
await answer.finish(send)
elif check_valid(expr):
result = calc(expr)
if result == 24 and contains_all_numbers(expr, numbers):
if (result == 24 or 24 - result < 1e-13 ) \
and contains_all_numbers(expr, numbers):
send = msg.locale.t('twenty_four.message.correct')
if (g_msg := await gained_petal(msg, 2)):
send += '\n' + g_msg