logic mistake fix

This commit is contained in:
Kellermann 2022-06-01 19:53:09 +02:00
parent 6f827e1c7a
commit d4ca82e5fd

View File

@ -597,23 +597,27 @@ def get_user_guess(message, start_time):
end_time = time.time() end_time = time.time()
user_id = int(message.from_user.id) user_id = int(message.from_user.id)
found = False
if message.text.count(",") == 0: if message.text.count(",") == 0:
try: try:
user_guess = float(message.text) user_guess = float(message.text)
found = True
except ValueError: except ValueError:
bot.send_message(chat_id=user_id, text="Please type a number (or float with '.' )") bot.send_message(chat_id=user_id, text="Please type a number (or float with '.' )")
bot.register_next_step_handler(message, get_user_guess, start_time) bot.register_next_step_handler(message, get_user_guess, start_time)
return return
if message.text.count(",") == 1: if message.text.count(",") == 1 and found is False:
try: try:
user_guess = float(message.text.replace(",", ".")) user_guess = float(message.text.replace(",", "."))
found = True
except ValueError: except ValueError:
bot.send_message(chat_id=user_id, text="Please type a number of float") bot.send_message(chat_id=user_id, text="Please type a number of float")
bot.register_next_step_handler(message, get_user_guess, start_time) bot.register_next_step_handler(message, get_user_guess, start_time)
return return
else:
if message.text.count(",") > 1 and found is False:
bot.send_message(chat_id=user_id, text="Please type a number or float") bot.send_message(chat_id=user_id, text="Please type a number or float")
bot.register_next_step_handler(message, get_user_guess, start_time) bot.register_next_step_handler(message, get_user_guess, start_time)
return return