From 9c31a0e4b9cdbb3d5e437e730a4ba9099b4c4c9f Mon Sep 17 00:00:00 2001 From: klafyvel Date: Fri, 2 Feb 2018 01:35:57 +0100 Subject: [PATCH] =?UTF-8?q?corrige=20le=20ban=20al=C3=A9atoire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roulette.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/roulette.py b/roulette.py index 629193d..fd59370 100755 --- a/roulette.py +++ b/roulette.py @@ -78,10 +78,14 @@ def get_player(player_id): con = connect_sql() cur = con.cursor() - cur.execute("""select id,firstname,name,ban_end from players - where id=%i"""% player_id) + s = """select id,firstname,name,ban_end from players + where id={}""".format(player_id) + if DEBUG: + print(s) + cur.execute(s) row = cur.fetchone() + print(row) con.close() return {'id': row[0], 'firstname': row[1], 'name': row[2], 'ban_end': row[3]} @@ -447,14 +451,14 @@ def ban_guimoz(): def ban_aleatoire(): players = get_players_not_banned() - playerid = random.choose(players).id - ban(23981,playerid,True) + player_1, player_2 = random.sample(players, 2) + ban(player_1['id'],player_2['id'],True) if __name__ == '__main__': if(sys.argv[1] == "ban_guimoz"): ban_guimoz() - elif(sys.argv[1] == "ban_alea"): + elif(sys.argv[1] == "ban_aleatoire"): ban_aleatoire() else: app.run()