stopのKeyErrorを修正
This commit is contained in:
parent
26f5269ce5
commit
d433f38d94
1 changed files with 6 additions and 5 deletions
11
dislocker.py
11
dislocker.py
|
@ -382,12 +382,13 @@ class Bot(discord.Client):
|
|||
|
||||
def stop(self, **kwargs):
|
||||
try:
|
||||
discord_user_id = str(kwargs["user_id"])
|
||||
cursor = dislocker.db.cursor()
|
||||
discord_user_id = str(kwargs["discord_user_id"])
|
||||
if "bot_about" in kwargs:
|
||||
bot_about = kwargs["bot_about"]
|
||||
else:
|
||||
bot_about = None
|
||||
cursor = dislocker.db.cursor()
|
||||
|
||||
# ユーザーが登録してるかというよりはデータの取得のため
|
||||
user_register = self.user_register_check(discord_user_id=discord_user_id)
|
||||
member_id = user_register["user_info"]["member_id"]
|
||||
|
@ -398,7 +399,7 @@ class Bot(discord.Client):
|
|||
pc_usage_history_record = cursor.fetchall()
|
||||
|
||||
if pc_usage_history_record:
|
||||
usage_id = pc_usage_history_record[0][0]
|
||||
pc_usage_history_id = pc_usage_history_record[0][0]
|
||||
pc_number = pc_usage_history_record[0][2]
|
||||
keyboard_number = pc_usage_history_record[0][3]
|
||||
mouse_number = pc_usage_history_record[0][4]
|
||||
|
@ -408,9 +409,9 @@ class Bot(discord.Client):
|
|||
if end_use_time == None:
|
||||
# 利用停止の理由の有無を判断
|
||||
if bot_about == None:
|
||||
cursor.execute("UPDATE pc_usage_history SET end_use_time = clock_timestamp() WHERE id = %s", (usage_id,))
|
||||
cursor.execute("UPDATE pc_usage_history SET end_use_time = clock_timestamp() WHERE id = %s", (pc_usage_history_id,))
|
||||
else:
|
||||
cursor.execute("UPDATE pc_usage_history SET end_use_time = clock_timestamp(), bot_about = %s WHERE id = %s", (bot_about, usage_id))
|
||||
cursor.execute("UPDATE pc_usage_history SET end_use_time = clock_timestamp(), bot_about = %s WHERE id = %s", (bot_about, pc_usage_history_id))
|
||||
# pc_listの使用中ユーザーを消す
|
||||
cursor.execute("UPDATE pc_list SET using_member_id = NULL, password_hash = NULL WHERE pc_number = %s", (pc_number,))
|
||||
if keyboard_number == None:
|
||||
|
|
Loading…
Reference in a new issue