たのむ

This commit is contained in:
suti7yk5032 2024-06-10 14:52:27 +09:00
parent 18076cdf31
commit a6082c1f0a

View file

@ -30,7 +30,7 @@ class Bot(discord.Client):
#パスワード生成、ハッシュ化 #パスワード生成、ハッシュ化
password = self.password_generate(4) password = self.password_generate(4)
password_hash = self.hash_genarate(password) password_hash = self.hash_genarate(password)
print("パスワード生成完了") print("password generated")
#メンバーリストと送信者を照合 #メンバーリストと送信者を照合
cursor = self.db.cursor() cursor = self.db.cursor()
cursor.execute("SELECT * FROM club_member WHERE discord_userid = %s", (discord_user_id,)) cursor.execute("SELECT * FROM club_member WHERE discord_userid = %s", (discord_user_id,))
@ -40,11 +40,11 @@ class Bot(discord.Client):
result = {"result": "user_data_not_found"} result = {"result": "user_data_not_found"}
#ユーザーデータが見つかった場合(登録済みの場合) #ユーザーデータが見つかった場合(登録済みの場合)
else: else:
print("ユーザーデータが見つかった") print("found user data")
cursor.execute("SELECT * FROM pc_usage_history WHERE member_id=%s ORDER BY id DESC LIMIT 1", (user_record[0][0],)) 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() pc_usage_history_record = cursor.fetchall()
if pc_usage_history_record: if pc_usage_history_record:
print("使用したことがあります") print("used")
if pc_usage_history_record[0][5] == None: 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])} 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: else:
@ -63,12 +63,6 @@ class Bot(discord.Client):
cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password_hash, pc_number)) cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password_hash, pc_number))
self.db.commit() self.db.commit()
result = {"result": "ok", "password": str(password), "name": str(user_record[0][1])} 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: else:
cursor.execute("SELECT * FROM pc_list WHERE pc_number=%s", (pc_number,)) cursor.execute("SELECT * FROM pc_list WHERE pc_number=%s", (pc_number,))
pc_list_record = cursor.fetchall() pc_list_record = cursor.fetchall()