From 85977709c670bcd394655e48366594f5eb66c64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jason=20=5B=EC=A0=9C=EC=9D=B4=EC=8A=A8=20=EC=A0=9C?= =?UTF-8?q?=EB=A1=AC=5D?= <20238115+DuckBoss@users.noreply.github.com> Date: Fri, 12 Jun 2020 14:05:23 -0400 Subject: [PATCH] Added !comment and !resetcomment commands --- .../core/core_commands/core_commands.py | 47 ++++++++++++++++++- .../plugins/core/core_commands/help.html | 2 + .../plugins/core/core_commands/privileges.csv | 3 +- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/JJMumbleBot/plugins/core/core_commands/core_commands.py b/JJMumbleBot/plugins/core/core_commands/core_commands.py index 223e3b4a..95a6d142 100644 --- a/JJMumbleBot/plugins/core/core_commands/core_commands.py +++ b/JJMumbleBot/plugins/core/core_commands/core_commands.py @@ -104,11 +104,56 @@ def process(self, text): return rutils.refresh_plugins() + elif command == "comment": + from JJMumbleBot.lib.utils.dir_utils import get_main_dir + if not privileges.plugin_privilege_checker(text, command, self.plugin_name): + return + message = text.message.strip() + message_parse = message[1:].split(' ', 1) + if len(message_parse) < 2: + return + GS.mumble_inst.users.myself.comment( + f'{message_parse[1]}

[{META_NAME}({META_VERSION})] - {rutils.get_bot_name()}
{rutils.get_about()}') + + GS.cfg.set(C_CONNECTION_SETTINGS, P_USER_COMMENT, message_parse[1]) + with open(f'{get_main_dir()}/cfg/config.ini', mode='w') as cfg_file: + GS.cfg.write(cfg_file) + + GS.gui_service.quick_gui( + f"Changed the bot's user comment.", + text_type='header', + box_align='left', + ignore_whisper=True, + user=GS.mumble_inst.users[text.actor]['name']) + dprint(f"Changed the bot\'s user comment to {message_parse[1]}.") + log(INFO, f"Changed the bot\'s user comment to {message_parse[1]}.", origin=L_COMMAND) + + elif command == "resetcomment": + from JJMumbleBot.lib.utils.dir_utils import get_main_dir + if not privileges.plugin_privilege_checker(text, command, self.plugin_name): + return + GS.mumble_inst.users.myself.comment( + f'[{META_NAME}({META_VERSION})] - {rutils.get_bot_name()}
{rutils.get_about()}') + + GS.cfg.set(C_CONNECTION_SETTINGS, P_USER_COMMENT, "") + with open(f'{get_main_dir()}/cfg/config.ini', mode='w') as cfg_file: + GS.cfg.write(cfg_file) + + GS.gui_service.quick_gui( + f"Reset the bot's user comment.", + text_type='header', + box_align='left', + ignore_whisper=True, + user=GS.mumble_inst.users[text.actor]['name']) + dprint(f"Reset the bot\'s user comment.") + log(INFO, f"Reset the bot\'s user comment.", origin=L_COMMAND) + + elif command == "help": if not privileges.plugin_privilege_checker(text, command, self.plugin_name): return message = text.message.strip() - message_parse = message[1:].split(' ', 2) + message_parse = message[1:].split(' ', 1) if len(message_parse) < 2: all_plugin_names = sorted(list(GS.bot_plugins.keys()), key=str.lower) all_help_lines = [f'!help {msg.strip()} - Displays help information for the {msg.strip()} plugin.' for msg in all_plugin_names] diff --git a/JJMumbleBot/plugins/core/core_commands/help.html b/JJMumbleBot/plugins/core/core_commands/help.html index 8e0a3037..f4a4f729 100644 --- a/JJMumbleBot/plugins/core/core_commands/help.html +++ b/JJMumbleBot/plugins/core/core_commands/help.html @@ -2,6 +2,8 @@ !exit/!quit: Initializes the bot exit procedure.
!help: Displays a list of the help commands for all the available plugins.
!help 'plugin_name': Displays all the commands available for the given plugin.
+!comment 'comment_text': Sets the bot's user comment with the given text.
+!resetcomment: Resets the bot's user comment to the default text.
!version: Displays the bot version.
!refresh: Refreshes all plugins.
!reboot/!restart: Completely stops the bot and restarts it.
diff --git a/JJMumbleBot/plugins/core/core_commands/privileges.csv b/JJMumbleBot/plugins/core/core_commands/privileges.csv index 5997c71c..5ae19c9c 100644 --- a/JJMumbleBot/plugins/core/core_commands/privileges.csv +++ b/JJMumbleBot/plugins/core/core_commands/privileges.csv @@ -2,7 +2,8 @@ command,level exit,4 help,1 version,1 -botstatus,1 +comment,4 +resetcomment,4 refresh,4 about,1 system_test,4