Skip to content

Commit

Permalink
Trivia rework
Browse files Browse the repository at this point in the history
  • Loading branch information
tisboyo committed Sep 7, 2021
1 parent 42f87d2 commit 600f522
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bot/mods/trivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,15 @@ def check_send_time(seconds_into_trivia: int):
self.answered_active_question = dict()
self.question_points = dict()

if self.trivia_active:
delay_at_end_of_question_displaying_answer = 10
else:
delay_at_end_of_question_displaying_answer = 1
now = datetime.datetime.now()
while datetime.datetime.now() < (datetime.timedelta(seconds=5) + now):
seconds = (datetime.timedelta(seconds=5) + now) - datetime.datetime.now()
while datetime.datetime.now() < (datetime.timedelta(seconds=delay_at_end_of_question_displaying_answer) + now):
seconds = (
datetime.timedelta(seconds=delay_at_end_of_question_displaying_answer) + now
) - datetime.datetime.now()
seconds_left = int(seconds.total_seconds())
await bot.MQTT.send(
bot.MQTT.Topics.trivia_current_question_data, {"seconds_left": seconds_left, "done": False}
Expand Down Expand Up @@ -324,13 +330,13 @@ async def trivia_start(self, msg: Message, debug=False):
"answers": {},
"id": "default",
"active": True,
"image": 0,
"image": "thumb-for-twitch",
"sound": 0,
"explain": "Send your trivia suggestions in discord!",
},
retain=True,
)
await sleep(2)
await sleep(10)
await bot.MQTT.send(bot.MQTT.Topics.trivia_current_question_setup, {"active": False}, retain=True)
await sleep(1.25) # 1 second was good, but to prevent any potential issues, bumped to 1.25

Expand Down
5 changes: 5 additions & 0 deletions web/routes/trivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ def iterfile():
return StreamingResponse(iterfile(), media_type="audio/wav")


@router.get("/trivia/images/thumb-for-twitch")
async def trivia_thumb_for_twitch(request: Request, key: str = Depends(check_valid_api_key(level=AuthLevel.admin))):
return RedirectResponse("https://www.baldengineer.com/thumbs/thumb-for-twitch.jpg", status_code=302)


@router.get("/trivia/images/{image_id}")
async def trivia_play_jpg(
request: Request, key: str = Depends(check_valid_api_key(level=AuthLevel.admin)), image_id="default"
Expand Down

0 comments on commit 600f522

Please sign in to comment.