Skip to content

Commit

Permalink
Added !comment and !resetcomment commands
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckBoss committed Jun 12, 2020
1 parent 0a1c2aa commit 8597770
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
47 changes: 46 additions & 1 deletion JJMumbleBot/plugins/core/core_commands/core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]}<br><br>[{META_NAME}({META_VERSION})] - {rutils.get_bot_name()}<br>{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()}<br>{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'<font color="{GS.cfg[C_PGUI_SETTINGS][P_TXT_SUBHEAD_COL]}">!help {msg.strip()}</font> - Displays help information for the <font color="{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}">{msg.strip()}</font> plugin.' for msg in all_plugin_names]
Expand Down
2 changes: 2 additions & 0 deletions JJMumbleBot/plugins/core/core_commands/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<b>!exit/!quit</b>: Initializes the bot exit procedure.<br>
<b>!help</b>: Displays a list of the help commands for all the available plugins.<br>
<b>!help 'plugin_name'</b>: Displays all the commands available for the given plugin.<br>
<b>!comment 'comment_text'</b>: Sets the bot's user comment with the given text.<br>
<b>!resetcomment</b>: Resets the bot's user comment to the default text.<br>
<b>!version</b>: Displays the bot version.<br>
<b>!refresh</b>: Refreshes all plugins.<br>
<b>!reboot/!restart</b>: Completely stops the bot and restarts it.<br>
Expand Down
3 changes: 2 additions & 1 deletion JJMumbleBot/plugins/core/core_commands/privileges.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8597770

Please sign in to comment.