Commas working now and not setting a product as default

This commit is contained in:
Kellermann 2022-06-01 19:41:09 +02:00
parent 8ab51e7f8c
commit bcc14f0da9
2 changed files with 17 additions and 5 deletions

View File

@ -598,10 +598,23 @@ def get_user_guess(message, start_time):
user_id = int(message.from_user.id) user_id = int(message.from_user.id)
try: if message.text.count(",") == 0:
user_guess = float(message.text) try:
except ValueError: user_guess = float(message.text)
bot.send_message(chat_id=user_id, text="Please type a number (or float with '.' )") except ValueError:
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)
return
if message.text.count(",") == 1:
try:
user_guess = float(message.text.replace(",", "."))
except ValueError:
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)
return
else:
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

View File

@ -161,7 +161,6 @@ def find_todays_product_from_db():
return product return product
if __name__ == "__main__": if __name__ == "__main__":
set_todays_product()
try: try:
start_challenges() start_challenges()
sys.exit(-1) sys.exit(-1)