Skip to content

Commit

Permalink
🔧 avoid db bool
Browse files Browse the repository at this point in the history
Trying using a global variable to avoid using a db table just for a boolean value #75 #53
  • Loading branch information
MasterCruelty committed Dec 28, 2022
1 parent 57a607f commit f896d5b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions modules/trivial.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ def html2text(strings):
global difficolta_domanda
global versione_domanda
global categoria
global wait_trivial
wait_trivial = False
@Client.on_message()
def send_question(query,client,message):
#check wait_quiz
wait_trivial = get_wait_trivial_value()
#wait_trivial = get_wait_trivial_value()
if wait_trivial:
return sendMessage(client,message,"__Un altro quiz è attualmente in corso.\nRiprova tra poco.__")
#variabili globali per tenere traccia di alcune informazioni per la fine del poll
Expand Down Expand Up @@ -197,10 +199,12 @@ def send_question(query,client,message):
try:
msg = client.send_poll(get_chat(message),question="Category: " + category.title() + "\nDifficulty: " + difficulty.title() + "\n" + question,options=incorrect,type=PollType.QUIZ,correct_option_id=incorrect.index(correct),open_period=20,is_anonymous=False,reply_to_message_id=get_id_msg(message))
#Setto il wait così che non ci siano due quiz in contemporanea
set_wait_trivial()
#set_wait_trivial()
wait_trivial = True
time.sleep(20)
#setto a false dopo la fine del quiz
unset_wait_trivial()
wait_trivial = False
#unset_wait_trivial()

except errors.exceptions.bad_request_400.PollAnswersInvalid:
return sendMessage(client,message,"__Errore durante invio trivial__")
Expand Down

0 comments on commit f896d5b

Please sign in to comment.