log = logging.getLogger("bot")
def register_all_commands(bot):
- bot.register_command(constants.commands('joinme'), cmd_joinme)
+ bot.register_command(constants.commands('joinme'), cmd_joinme, no_partial_match=False, access_outside_channel=True)
bot.register_command(constants.commands('user_ban'), cmd_user_ban)
bot.register_command(constants.commands('user_unban'), cmd_user_unban)
bot.register_command(constants.commands('url_ban'), cmd_url_ban)
bot.register_command(constants.commands('rb_play'), cmd_rb_play)
bot.register_command(constants.commands('yt_search'), cmd_yt_search)
bot.register_command(constants.commands('yt_play'), cmd_yt_play)
- bot.register_command(constants.commands('help'), cmd_help)
+ bot.register_command(constants.commands('help'), cmd_help, no_partial_match=False, access_outside_channel=True)
bot.register_command(constants.commands('stop'), cmd_stop)
bot.register_command(constants.commands('clear'), cmd_clear)
bot.register_command(constants.commands('kill'), cmd_kill)
bot.register_command(constants.commands('search'), cmd_search_library)
bot.register_command(constants.commands('add_from_shortlist'), cmd_shortlist)
bot.register_command(constants.commands('delete_from_library'), cmd_delete_from_library)
- bot.register_command(constants.commands('drop_database'), cmd_drop_database, True)
- bot.register_command(constants.commands('rescan'), cmd_refresh_cache, True)
+ bot.register_command(constants.commands('drop_database'), cmd_drop_database, no_partial_match=True)
+ bot.register_command(constants.commands('rescan'), cmd_refresh_cache, no_partial_match=True)
# Just for debug use
bot.register_command('rtrms', cmd_real_time_rms, True)
else:
self.log.debug("update: no new version found.")
- def register_command(self, cmd, handle, no_partial_match=False):
+ def register_command(self, cmd, handle, no_partial_match=False, access_outside_channel=False):
cmds = cmd.split(",")
for command in cmds:
command = command.strip()
if command:
- self.cmd_handle[command] = { 'handle': handle, 'partial_match': not no_partial_match}
+ self.cmd_handle[command] = { 'handle': handle,
+ 'partial_match': not no_partial_match,
+ 'access_outside_channel': access_outside_channel}
self.log.debug("bot: command added: " + command)
def set_comment(self):
self.log.info('bot: received command ' + command + ' - ' + parameter + ' by ' + user)
# Anti stupid guy function
- if not self.is_admin(user) and not var.config.getboolean('bot', 'allow_other_channel_message') \
- and self.mumble.users[text.actor]['channel_id'] != self.mumble.users.myself['channel_id']:
- self.mumble.users[text.actor].send_text_message(
- constants.strings('not_in_my_channel'))
- return
-
if not self.is_admin(user) and not var.config.getboolean('bot', 'allow_private_message') and text.session:
self.mumble.users[text.actor].send_text_message(
constants.strings('pm_not_allowed'))
try:
if command in self.cmd_handle:
command_exc = command
+
+ if not self.cmd_handle[command]['access_outside_channel'] \
+ and not self.is_admin(user) \
+ and not var.config.getboolean('bot', 'allow_other_channel_message') \
+ and self.mumble.users[text.actor]['channel_id'] != self.mumble.users.myself['channel_id']:
+ self.mumble.users[text.actor].send_text_message(
+ constants.strings('not_in_my_channel'))
+ return
+
self.cmd_handle[command]['handle'](self, user, text, command, parameter)
else:
# try partial match
if len(matches) == 1:
self.log.info("bot: {:s} matches {:s}".format(command, matches[0]))
command_exc = matches[0]
+
+ if not self.cmd_handle[command]['access_outside_channel'] \
+ and not self.is_admin(user) \
+ and not var.config.getboolean('bot', 'allow_other_channel_message') \
+ and self.mumble.users[text.actor]['channel_id'] != self.mumble.users.myself[
+ 'channel_id']:
+ self.mumble.users[text.actor].send_text_message(
+ constants.strings('not_in_my_channel'))
+ return
+
self.cmd_handle[command_exc]['handle'](self, user, text, command_exc, parameter)
elif len(matches) > 1:
self.mumble.users[text.actor].send_text_message(