From 69cb9537ff90a963a34570426bfa170dd99b6b50 Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Thu, 26 Sep 2024 21:42:33 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9E=E3=82=B9=E3=82=BF=E3=83=BC=E3=83=91?= =?UTF-8?q?=E3=82=B9=E3=83=AF=E3=83=BC=E3=83=89=E3=82=92=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=B9=E3=83=A9=E3=83=83=E3=82=B7=E3=83=A5?= =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=81=A8=E5=87=A6=E7=90=86?= =?UTF-8?q?=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_slash.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/dislocker_slash.py b/dislocker_slash.py index c19a2bd..057a849 100644 --- a/dislocker_slash.py +++ b/dislocker_slash.py @@ -751,6 +751,23 @@ class DL(): self.log(title=f"[ERROR] デバイス登録用のワンタイムパスワード発行中にエラーが発生しました。 {str(error.__class__.__name__)}", message=str(error.args), flag=1) return {"result": 1, "about": "error"} + def show_pc_master_password(self, **kwargs): + if isinstance(kwargs.get("pc_number"), int): + try: + pc_number = int(kwargs.get("pc_number")) + + cursor = self.db.cursor() + cursor.execute("SELECT master_password FROM pc_list WHERE pc_number = %s", (pc_number,)) + pc_master_password_list = cursor.fetchall() + pc_master_password = pc_master_password_list[0][0] + + return {"result": 0, "about": "ok", "output_dict": {"pc_master_password": pc_master_password}} + except Exception as error: + self.log(title=f"[ERROR] PCのマスターパスワードを取得中にエラーが発生しました。 {str(error.__class__.__name__)}", message=str(error.args), flag=1) + return {"result": 1, "about": "error"} + else: + return {"result": 1, "about": "syntax_error"} + class ReasonModal(discord.ui.Modal): def __init__(self, title: str, pc_number: str, keyboard_number: str, mouse_number: str, timeout=15) -> None: @@ -1296,6 +1313,17 @@ async def button_init(interaction: discord.Interaction, text_channel: discord.Te await interaction.response.send_message(f":white_check_mark: ボタンを送信しました!", ephemeral=True) +@tree.command(name="masterpass", description="PCのマスターパスワードを表示します。") +@discord.app_commands.default_permissions(administrator=True) +async def masterpass(interaction: discord.Interaction, pc_number: int): + pc_master_password_get = dislocker.pc_master_password(pc_number=pc_number) + + if pc_master_password_get["result"] == 0: + pc_master_password = pc_master_password_get["output_dict"]["master_password"] + await interaction.response.send_message(f"# :key: PC番号 {pc_number} 番のマスターパスワードは以下の通りです。\n>>> # マスターパスワード | {pc_master_password}", ephemeral=True) + else: + await interaction.response.send_message("# :skull_crossbones: マスターパスワードの取得に失敗しました。", ephemeral=True) + if dislocker.init_result == "ok": print("Botを起動します...")