git made me suffer
This commit is contained in:
parent
d2d2f1e90e
commit
d249504f6c
@ -33,7 +33,7 @@ load_dotenv(dotenv_path='.env') # load environment variables
|
|||||||
BOT_VERSION = "0.6.6" # version of bot
|
BOT_VERSION = "0.6.6" # version of bot
|
||||||
|
|
||||||
START_DAY = dt.time(8, 0, 0)
|
START_DAY = dt.time(8, 0, 0)
|
||||||
END_DAY = dt.time(23, 0, 0)
|
END_DAY = dt.time(22, 0, 0)
|
||||||
|
|
||||||
bot = telebot.TeleBot(os.getenv('BOT_API_KEY'))
|
bot = telebot.TeleBot(os.getenv('BOT_API_KEY'))
|
||||||
|
|
||||||
@ -528,6 +528,10 @@ def daily_message(message):
|
|||||||
Raises:
|
Raises:
|
||||||
None: None
|
None: None
|
||||||
|
|
||||||
|
Test:
|
||||||
|
type /daily as command in telegram and check if bot sends daily challenge message
|
||||||
|
type /daily again for message that you already played today and your guess
|
||||||
|
|
||||||
"""
|
"""
|
||||||
user_id = int(message.from_user.id)
|
user_id = int(message.from_user.id)
|
||||||
|
|
||||||
@ -594,6 +598,11 @@ def get_user_guess(message, start_time):
|
|||||||
Args:
|
Args:
|
||||||
message (Message): Message element to react to. In this case next step after /daily
|
message (Message): Message element to react to. In this case next step after /daily
|
||||||
start_time (time.time): Time the user got the image
|
start_time (time.time): Time the user got the image
|
||||||
|
|
||||||
|
Test:
|
||||||
|
Send a price and see if the bot responds correctly (guess accepted)
|
||||||
|
Send text withwith wrong format (right format = number fitting for float) and see if bot notices and gives you another try
|
||||||
|
See if score changes after you guessed (only if you guessed somewhat correctly so your score is not 0)
|
||||||
"""
|
"""
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
user_id = int(message.from_user.id)
|
user_id = int(message.from_user.id)
|
||||||
|
@ -11,11 +11,12 @@ import time
|
|||||||
import sys
|
import sys
|
||||||
import pandas
|
import pandas
|
||||||
import random
|
import random
|
||||||
|
import datetime as dt
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
|
|
||||||
|
|
||||||
from bot import bot
|
from bot import bot
|
||||||
from db import User, session, Product
|
from db import User, session, Product, Score
|
||||||
|
|
||||||
CHALLENGE_READY = "0 8 * * *"
|
CHALLENGE_READY = "0 8 * * *"
|
||||||
CHALLENGE_OVER = "0 22 * * *"
|
CHALLENGE_OVER = "0 22 * * *"
|
||||||
@ -107,8 +108,16 @@ def send_current_event(str_event):
|
|||||||
elif str_event == "over":
|
elif str_event == "over":
|
||||||
product_today = find_todays_product_from_db()
|
product_today = find_todays_product_from_db()
|
||||||
for element in all_users["telegram_id"]:
|
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"\
|
bot.send_message(chat_id=int(element), text="Todays challenge is over!\n"\
|
||||||
"The correct price is: " + str(product_today.price) + "€\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!")
|
"Check the /scoreboard to see the leaderboard!")
|
||||||
else:
|
else:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
Loading…
Reference in New Issue
Block a user