From 260779fca37bdc26b7d3e89765d62a51400f9b3e Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Sun, 9 Jun 2024 20:11:20 +0900 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=9B=9E=E3=81=AE=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dislocker.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/dislocker.py b/dislocker.py index eaacacb..f133c37 100644 --- a/dislocker.py +++ b/dislocker.py @@ -41,8 +41,9 @@ class Bot(discord.Client): else: cursor.execute("SELECT * FROM pc_usage_history WHERE member_id=%s ORDER BY id DESC LIMIT 1", (user_record[0][0],)) pc_usage_history_record = cursor.fetchall() - if pc_usage_history_record[0][5] == None: - result = {"result": "pc_already_in_use_by_you", "pc_number": str(pc_usage_history_record[0][2]), "device_number": str(pc_usage_history_record[0][3]), "start_time": str(pc_usage_history_record[0][4]), "detail": str(pc_usage_history_record[0][6])} + if pc_usage_history_record: + if pc_usage_history_record[0][5] == None: + result = {"result": "pc_already_in_use_by_you", "pc_number": str(pc_usage_history_record[0][2]), "device_number": str(pc_usage_history_record[0][3]), "start_time": str(pc_usage_history_record[0][4]), "detail": str(pc_usage_history_record[0][6])} else: cursor.execute("SELECT * FROM pc_list WHERE pc_number=%s", (pc_number,)) pc_list_record = cursor.fetchall() @@ -69,15 +70,15 @@ class Bot(discord.Client): user_record = cursor.fetchall() cursor.execute("SELECT * FROM pc_usage_history WHERE member_id= %s ORDER BY id DESC LIMIT 1", (user_record[0][0],)) pc_usage_history_record = cursor.fetchall() - if not pc_usage_history_record[0][5] == None: - result = {"result": "unused"} - - else: - cursor.execute("UPDATE pc_usage_history SET end_use_time = current_timestamp WHERE id = %s", (pc_usage_history_record[0][0],)) - cursor.execute("UPDATE pc_list SET using_user_id = NULL WHERE pc_number = %s", (pc_usage_history_record[0][2],)) - cursor.execute("UPDATE pc_list SET password_hash = NULL WHERE pc_number = %s", (pc_usage_history_record[0][2],)) - self.db.commit() - result = {"result": "ok", "pc_number": str(pc_usage_history_record[0][2]), "name": str(user_record[0][1])} + if pc_usage_history_record: + if not pc_usage_history_record[0][5] == None: + result = {"result": "unused"} + else: + cursor.execute("UPDATE pc_usage_history SET end_use_time = current_timestamp WHERE id = %s", (pc_usage_history_record[0][0],)) + cursor.execute("UPDATE pc_list SET using_user_id = NULL WHERE pc_number = %s", (pc_usage_history_record[0][2],)) + cursor.execute("UPDATE pc_list SET password_hash = NULL WHERE pc_number = %s", (pc_usage_history_record[0][2],)) + self.db.commit() + result = {"result": "ok", "pc_number": str(pc_usage_history_record[0][2]), "name": str(user_record[0][1])} return result @@ -164,9 +165,6 @@ class Bot(discord.Client): await message.channel.send("なんでかわからんけど不正です。") - - - config_dir_path = "./config/" db_config_path = config_dir_path + "db.json" if not os.path.isfile(db_config_path):