From 1147b50fd1357b111ccd7f77b54be3ae70e7ca5f Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Mon, 10 Jun 2024 14:31:40 +0900 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E8=A6=8F=E3=83=A6=E3=83=BC=E3=82=B6?= =?UTF-8?q?=E3=83=BC(=E4=BD=BF=E7=94=A8=E5=B1=A5=E6=AD=B4=E3=81=8C?= =?UTF-8?q?=E3=81=AA=E3=81=84)=E3=81=A8=E3=81=8D=E3=81=AE=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dislocker.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dislocker.py b/dislocker.py index 991fbb0..7adde0d 100644 --- a/dislocker.py +++ b/dislocker.py @@ -60,6 +60,28 @@ class Bot(discord.Client): cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password_hash, pc_number)) self.db.commit() result = {"result": "ok", "password": str(password), "name": str(user_record[0][1])} + 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: + 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() + if not pc_list_record[0][1] == None: + result = {"result": "pc_already_in_use_by_other"} + else: + if detail == None: + cursor.execute("INSERT INTO pc_usage_history (member_id, pc_number, device_number, start_use_time) VALUES (%s, %s, %s, current_timestamp)", (user_record[0][0], pc_number, device_number)) + #使用用途があるとき + else: + cursor.execute("INSERT INTO pc_usage_history (member_id, pc_number, device_number, start_use_time, use_detail) VALUES (%s, %s, %s, current_timestamp, %s)", (user_record[0][0], pc_number, device_number, detail)) + + cursor.execute("UPDATE pc_list SET using_user_id = %s WHERE pc_number = %s", (user_record[0][0], pc_number)) + cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password_hash, pc_number)) + self.db.commit() + result = {"result": "ok", "password": str(password), "name": str(user_record[0][1])} return result