Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DuckBoss/JJMumbleBot
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckBoss committed Jun 22, 2020
2 parents babc7f9 + ed43145 commit bcc2b31
Show file tree
Hide file tree
Showing 17 changed files with 271 additions and 26 deletions.
2 changes: 2 additions & 0 deletions JJMumbleBot/cfg/templates/config_template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ WebServerIP = 127.0.0.1
WebPagePort = 7000
; This sets the port of the web socket on the web interface providing live data.
WebSocketPort = 7001
; This sets the tick rate of the loop that sends data to the web interface.
WebTickRate = 1

[Media Directories]
; Temporary images directory to store youtube thumbnails and other images content. This directory is cleared when the bot exits
Expand Down
31 changes: 31 additions & 0 deletions JJMumbleBot/lib/monitor_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import psutil
import platform
from JJMumbleBot.settings import global_settings
from JJMumbleBot.lib.utils.runtime_utils import get_all_channels


def get_all_users():
Expand All @@ -10,13 +11,43 @@ def get_all_users():
}


def get_all_online():
online_user_info = {
"channels": {},
"users": {}
}
all_channels_dict = get_all_channels()

users_in_channels = {}
for channel_id in all_channels_dict:
all_users_in_channel = all_channels_dict[channel_id].get_users()
users_in_channels[channel_id] = {}
for user in all_users_in_channel:
users_in_channels[channel_id][user["name"]] = {
f'name': f'{user["name"]}',
f'user_id': f'{user["user_id"]}',
f'channel_id': f'{user["channel_id"]}'
}

online_user_info["channels"] = all_channels_dict
online_user_info["users"] = users_in_channels
return online_user_info


def get_hardware_info():
return {
"cpu_usage": f'{psutil.cpu_percent()}%',
"mem_usage": f'{psutil.virtual_memory().percent}%'
}


def get_last_command_output():
return {
"last_cmd_type": f'{global_settings.last_command_type}',
"last_cmd_output": f'{global_settings.last_command_output}'
}


def get_system_info():
uname = platform.uname()
return {
Expand Down
4 changes: 4 additions & 0 deletions JJMumbleBot/lib/pgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ def display_box(self, channel, user=None, ignore_whisper=False):
if self.content is None or self.box_open:
return
if user is not None:
GS.last_command_type = f'[PRIVATE]'
GS.last_command_output = f'{self.content}'
runtime_utils.msg(user, self.content)
self.clear_display()
return
GS.last_command_type = f'[PUBLIC]'
GS.last_command_output = f'{self.content}'
runtime_utils.echo(channel, self.content, ignore_whisper=ignore_whisper)
self.clear_display()

Expand Down
3 changes: 2 additions & 1 deletion JJMumbleBot/lib/resources/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
P_WEB_IP = 'WebServerIP'
P_WEB_PAGE_PORT = 'WebPagePort'
P_WEB_SOCK_PORT = 'WebSocketPort'
P_WEB_TICK_RATE = 'WebTickRate'
# Permanent Directories
P_PERM_MEDIA_DIR = 'PermanentMediaDirectory'
# Temporary Directories
Expand Down Expand Up @@ -94,5 +95,5 @@
###########################################################################
# BOT META INFORMATION STRINGS
META_NAME = "JJMumbleBot"
META_VERSION = "3.1.1"
META_VERSION = "3.1.2"
###########################################################################
10 changes: 9 additions & 1 deletion JJMumbleBot/lib/utils/runtime_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ def get_all_users():
return global_settings.mumble_inst.users


def get_all_channels():
return global_settings.mumble_inst.channels


def get_users_in_channel(channel_name):
return global_settings.mumble_inst.channels.find_by_name(channel_name).get_users()


def get_version():
return META_VERSION

Expand Down Expand Up @@ -200,7 +208,7 @@ def remove_channel():

def check_up_time():
cur_time = datetime.datetime.now() - runtime_helper.start_time
return f"Up-time: {str(cur_time)[:-7]}"
return f"{str(cur_time)[:-7]}"


def refresh_plugins():
Expand Down
2 changes: 1 addition & 1 deletion JJMumbleBot/plugins/core/core_commands/core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def process(self, text):
if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
return
GS.gui_service.quick_gui(
rutils.check_up_time(),
f"Up-time: {rutils.check_up_time()}",
text_type='header',
box_align='left',
ignore_whisper=True,
Expand Down
2 changes: 1 addition & 1 deletion JJMumbleBot/plugins/core/core_commands/metadata.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Plugin Information]
PluginVersion = 3.1.0
PluginVersion = 3.1.2
PluginName = Core Commands
PluginDescription = The Core Commands plugin handles core functionality commands.
PluginLanguage = EN
Expand Down
2 changes: 2 additions & 0 deletions JJMumbleBot/plugins/extensions/sound_board/help.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
All commands can be run by typing it in the channel or privately messaging JJMumbleBot.<br>
<b>!sb 'file_name'</b>: Plays a locally saved wav file.<br>
<b>!sbquiet 'file_name'</b>: Plays a locally saved wav file without displaying what is being played.<br>
<b>!sbloop 'file_name'</b>: Plays a locally saved wav file, but endlessly loops until it is stopped.<br>
<b>!sbloopquiet 'file_name'</b>: Plays a locally saved wav file without displaying what is being played, but endlessly loops until it is stopped.<br>
<b>!sbseek 'seconds'</b>: Skips the current track by the given amount of seconds.<br>
<b>!sbrandom</b>: Plays a random sound clip from the list of available clips.<br>
<b>!sbvolume '0..1'</b>: Sets the sound board audio volume.<br>
Expand Down
4 changes: 3 additions & 1 deletion JJMumbleBot/plugins/extensions/sound_board/metadata.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[Plugin Information]
PluginVersion = 3.0.8
PluginVersion = 3.1.2
PluginName = Sound Board
PluginDescription = The Sound Board plugin allows users to play saved sound clips in the channel.
PluginLanguage = EN
PluginCommands: [
"sb",
"sbquiet",
"sbloop",
"sbloopquiet",
"sbseek",
"sbvolume",
"sblist",
Expand Down
2 changes: 2 additions & 0 deletions JJMumbleBot/plugins/extensions/sound_board/privileges.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
command,level
sb,2
sbquiet,3
sbvolume,3
sbrandom,3
sbloop,3
sbloopquiet,3
sbskip,3
sblist,2
sblist_echo,3
Expand Down
64 changes: 64 additions & 0 deletions JJMumbleBot/plugins/extensions/sound_board/sound_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,38 @@ def process(self, text):
sbu.play_audio()

elif command == "sb":
if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
return
if len(message_parse) < 2:
return
if not GS.audio_dni[0]:
GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
else:
if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
rprint(
f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
GS.gui_service.quick_gui(
"An audio plugin is using the audio thread with no interruption mode enabled.",
text_type='header',
box_align='left')
return
# print(GS.audio_dni)
parameter = message_parse[1].strip()
if not os.path.isfile(f"{dir_utils.get_perm_med_dir()}/{self.plugin_name}/{parameter}.wav"):
GS.gui_service.quick_gui(
"The sound clip does not exist.",
text_type='header',
box_align='left')
return False
sbu_settings.current_track = parameter
sbu_settings.loop_clip = False
GS.gui_service.quick_gui(
f"Playing sound clip: {sbu_settings.current_track}",
text_type='header',
box_align='left')
sbu.play_audio()

elif command == "sbquiet":
if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
return
if len(message_parse) < 2:
Expand Down Expand Up @@ -229,6 +261,38 @@ def process(self, text):
sbu.play_audio()

elif command == "sbloop":
if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
return
if len(message_parse) < 2:
return
if not GS.audio_dni[0]:
GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
else:
if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
rprint(
f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
GS.gui_service.quick_gui(
"An audio plugin is using the audio thread with no interruption mode enabled.",
text_type='header',
box_align='left')
return
# print(GS.audio_dni)
parameter = message_parse[1].strip()
if not os.path.isfile(f"{dir_utils.get_perm_med_dir()}/{self.plugin_name}/{parameter}.wav"):
GS.gui_service.quick_gui(
"The sound clip does not exist.",
text_type='header',
box_align='left')
return False
sbu_settings.current_track = parameter
sbu_settings.loop_clip = True
GS.gui_service.quick_gui(
f"Playing looping sound clip: {sbu_settings.current_track}",
text_type='header',
box_align='left')
sbu.play_audio()

elif command == "sbloopquiet":
if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
return
if len(message_parse) < 2:
Expand Down
5 changes: 4 additions & 1 deletion JJMumbleBot/settings/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
cmd_queue = None
# Aliases
aliases = {}
# Initialized plugins.
# Initialized Plugins.
bot_plugins = None
# Last Command Output
last_command_type = ''
last_command_output = ''
49 changes: 49 additions & 0 deletions JJMumbleBot/web/static/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#commandOutputPanel {
text-align: center;
display: inline-block;
width:100%;
max-width:100%;
max-height:450px;
overflow: auto;
}
#commandOutputData {
text-align: center;
width:100%;
max-width:100%;
}
#commandInput {
background-color: #212529;
color: white;
}
.container {
padding: 15px;
width: 60%;
background-color: rgb(28, 30, 31);
}
figcaption {
text-decoration: underline;
}
.breadcrumb {
background-color: #212529;
}
.row {
padding: 10px;
}
.col-8.border.border-light {
padding: 10px;
}
.col-4.border.border-light {
padding: 10px;
}
.list-group ul{
font-size: small;
background-color: #212529;
}
.list-group li {
font-size: small;
background-color: #212529;
}
body {
color: rgb(218, 215, 210);
background-color: rgb(24, 26, 27);
}
Binary file added JJMumbleBot/web/static/favicon.ico
Binary file not shown.
Loading

0 comments on commit bcc2b31

Please sign in to comment.