初回の処理を修正
This commit is contained in:
parent
5c15c0b092
commit
260779fca3
1 changed files with 12 additions and 14 deletions
26
dislocker.py
26
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):
|
||||
|
|
Loading…
Reference in a new issue