git made me suffer

This commit is contained in:
Kellermann
2022-05-31 07:05:12 +02:00
parent d2d2f1e90e
commit d249504f6c
2 changed files with 20 additions and 2 deletions

View File

@@ -11,11 +11,12 @@ import time
import sys
import pandas
import random
import datetime as dt
from apscheduler.schedulers.background import BackgroundScheduler
from bot import bot
from db import User, session, Product
from db import User, session, Product, Score
CHALLENGE_READY = "0 8 * * *"
CHALLENGE_OVER = "0 22 * * *"
@@ -107,8 +108,16 @@ def send_current_event(str_event):
elif str_event == "over":
product_today = find_todays_product_from_db()
for element in all_users["telegram_id"]:
user_guesses = session.query(Score).filter(Score.telegram_id == element).all()
user_guess, user_score = 0, 0
for guesses in user_guesses: # find todays guess and score
if guesses.date.date() == dt.datetime.now().date():
user_guess = guesses.guess
user_score = guesses.score
bot.send_message(chat_id=int(element), text="Todays challenge is over!\n"\
"The correct price is: " + str(product_today.price) + "\n"\
"Your guess was: " + str(user_guess) + "\n"\
"Your score was: " + str(user_score) + "\n"\
"Check the /scoreboard to see the leaderboard!")
else:
sys.exit(-1)