Skip to content

Commit

Permalink
🔧 Add function
Browse files Browse the repository at this point in the history
Add function to update user info on db and marked 'to delete' all three functions about wait_trivial #75 #53
  • Loading branch information
MasterCruelty committed Dec 28, 2022
1 parent a3bc576 commit 183fe54
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion utils/dbfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
db.connect()


####################################################################
#### FUNZIONI LEGATE ALLE STATISTICHE SUI COMANDI USATI DAGLI UTENTI
####################################################################
"""
@params utente, comando
Expand Down Expand Up @@ -74,6 +77,10 @@ def show_stats(utente,client,message):
return sendMessage(client,message,result)


######################################
#### FUNZIONI LEGATE AL GIOCO /TRIVIAL
######################################

"""
@params utente,punteggio,categoria
Expand Down Expand Up @@ -130,6 +137,7 @@ def global_trivial_leaderboard(client,message):
"""
setto il wait time a true per via di un quiz in corso
"""
#to delete
def set_wait_trivial():
query = (waitTrivial
.update({waitTrivial.value: True})).execute()
Expand All @@ -141,6 +149,7 @@ def set_wait_trivial():
"""
setto il wait time a false, è possibile lanciare un nuovo quiz
"""
#to delete
def unset_wait_trivial():
query = (waitTrivial
.update({waitTrivial.value: False})).execute()
Expand All @@ -152,11 +161,18 @@ def unset_wait_trivial():
"""
prelevo il valore del wait time
"""
#to delete
def get_wait_trivial_value():
query = waitTrivial.select()
for item in query:
return item.value



#############################################################################
#### FUNZIONI LEGATE ALLA GESTIONE DEI GRUPPI SALVATI CON COMANDI AUTORIZZATI
#############################################################################

"""
Restituisce la lista dei gruppi autorizzati a certi comandi
"""
Expand Down Expand Up @@ -216,7 +232,11 @@ def check_group_command(match,message):
return True
else:
return False



##############################################################
#### FUNZIONI LEGATE ALLA GESTIONE DEGLI UTENTI SALVATI SUL DB
##############################################################
"""
questa funzione fa una select dalla tabella User e restituisce gli id di tutti gli utenti registratii dentro una lista di int
"""
Expand Down Expand Up @@ -282,6 +302,21 @@ def set_user(client,message,query):
result = "Utente " + str(user.id_user) + " salvato!"
return sendMessage(client,message,result)

"""
update dei dati sul db di un utente specifico
"""
@Client.on_message()
def update_user(client,message,query):
json_user = client.get_users(query)
userid = json_user.id
nome_utente = json_user.first_name
username_utente = "@" + str(json_user.username)
query = (User
.update((name = nome_utente,username = username_utente))
.where(User.id_user == userid)).execute()
result = "Dati aggiornati per utente " + str(userid)
return sendMessage(client,message,result)

"""
Questa funzione elimina un utente dalla tabella User
"""
Expand Down

0 comments on commit 183fe54

Please sign in to comment.