使用目的のプリセットを追加
This commit is contained in:
parent
5a709197e7
commit
c08afa08c3
1 changed files with 29 additions and 2 deletions
27
dislocker.py
27
dislocker.py
|
@ -77,6 +77,7 @@ class DL():
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
|
|
||||||
self.pc_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
self.pc_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||||
|
self.preset_games = self.server_config["bot"]["preset_games"]
|
||||||
|
|
||||||
cursor.execute("SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'club_member')")
|
cursor.execute("SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'club_member')")
|
||||||
find_club_member_table = cursor.fetchall()
|
find_club_member_table = cursor.fetchall()
|
||||||
|
@ -625,6 +626,9 @@ class Bot(discord.Client):
|
||||||
pc_number = custom_id_split[1]
|
pc_number = custom_id_split[1]
|
||||||
device_number = custom_id_split[2]
|
device_number = custom_id_split[2]
|
||||||
reason_register_view = View(timeout=15)
|
reason_register_view = View(timeout=15)
|
||||||
|
for i in dislocker.preset_games:
|
||||||
|
reason_quick_button = reason_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(i)}", custom_id=f"reasonregister_{str(pc_number)}_{str(device_number)}_quick_{str(i)}")
|
||||||
|
reason_register_view.add_item(reason_quick_button)
|
||||||
reason_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="使用目的を入力する", custom_id=f"reasonregister_{str(pc_number)}_{str(device_number)}")
|
reason_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="使用目的を入力する", custom_id=f"reasonregister_{str(pc_number)}_{str(device_number)}")
|
||||||
reason_register_view.add_item(reason_button)
|
reason_register_view.add_item(reason_button)
|
||||||
|
|
||||||
|
@ -633,6 +637,29 @@ class Bot(discord.Client):
|
||||||
elif custom_id_split[0] == "reasonregister":
|
elif custom_id_split[0] == "reasonregister":
|
||||||
pc_number = custom_id_split[1]
|
pc_number = custom_id_split[1]
|
||||||
device_number = custom_id_split[2]
|
device_number = custom_id_split[2]
|
||||||
|
|
||||||
|
if len(custom_id_split) >= 4:
|
||||||
|
if custom_id_split[3] == "quick":
|
||||||
|
reason = custom_id_split[4]
|
||||||
|
device_number = custom_id_split[2]
|
||||||
|
register = bot.register(user_id=interaction.user.id, name=interaction.user.name, display_name=interaction.user.display_name, pc_number=pc_number, device_number=device_number, detail=reason)
|
||||||
|
print(register["result"])
|
||||||
|
|
||||||
|
if register["result"] == "ok":
|
||||||
|
await interaction.response.send_message(f":white_check_mark: 使用が開始されました。\n>>> # パスワード | {register["password"]}\n## PC番号 | {pc_number}\n## デバイス番号 | {device_number}\n## 使用目的 | {reason}", ephemeral=True)
|
||||||
|
await bot.get_channel(dislocker.server_config["bot"]["log_channel_id"]).send(f':white_check_mark: {register["name"]} さんがPC {pc_number} の使用を開始しました。')
|
||||||
|
elif register["result"] == "pc_already_in_use_by_you":
|
||||||
|
await interaction.response.send_message(f"# :exploding_head: あなたはPCをもう使用されているようです。\n使用状態を解除するには 終了ボタン で使用終了をお知らせください。\n>>> # PC番号 | {register["pc_number"]}\n# デバイス番号 | {register["device_number"]}\n# 使用開始時刻 | {register["start_time"]}\n# 使用目的 | {register["detail"]}", ephemeral=True)
|
||||||
|
elif register["result"] == "pc_already_in_use_by_other":
|
||||||
|
await interaction.response.send_message(f"# :man_gesturing_no: そのPCは他のメンバーによって使用されています。\n別のPC番号を指定して、再度お試しください。", ephemeral=True)
|
||||||
|
elif register["result"] == "user_data_not_found":
|
||||||
|
await interaction.response.send_message("# :dizzy_face: ユーザーとして登録されていないようです。\n最初にサーバーで登録を行ってください。", ephemeral=True)
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message("# :skull_crossbones: 登録できませんでした。\n内部エラーが発生しています。", ephemeral=True)
|
||||||
|
else:
|
||||||
|
reason_input_form = Reason(title="Dislocker | 登録", pc_number=str(pc_number), device_number=str(device_number))
|
||||||
|
await interaction.response.send_modal(reason_input_form)
|
||||||
|
else:
|
||||||
reason_input_form = Reason(title="Dislocker | 登録", pc_number=str(pc_number), device_number=str(device_number))
|
reason_input_form = Reason(title="Dislocker | 登録", pc_number=str(pc_number), device_number=str(device_number))
|
||||||
await interaction.response.send_modal(reason_input_form)
|
await interaction.response.send_modal(reason_input_form)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue