custom_commands.rb: Syntax fixes

This commit is contained in:
Bill Niblock 2021-03-26 20:46:48 -04:00
parent 4a2490b872
commit 6416c76891

View file

@ -10,10 +10,13 @@ require 'json'
module Chronicle module Chronicle
module Addon module Addon
# Custom Commander handles all custom command management
#
# @param bot [Chronicle] The instance of Chronicle for this addon
class CustomCommander class CustomCommander
def self.register(bot) def self.register(bot)
addon_instance = new(bot) addon_instance = new(bot)
addon_command = ['addcommand','modcommand','remcommand'] addon_command = %w[addcommand modcommand remcommand]
[addon_instance, addon_command] [addon_instance, addon_command]
end end
@ -32,11 +35,11 @@ module Chronicle
cmd = message.content[:body].split(/\s+/)[1].gsub(/#{pfx}/, '') cmd = message.content[:body].split(/\s+/)[1].gsub(/#{pfx}/, '')
case cmd case cmd
when "addcommand" when 'addcommand'
cmd_add_usage cmd_add_usage
when "modcommand" when 'modcommand'
cmd_mod_usage cmd_mod_usage
when "remcommand" when 'remcommand'
cmd_rem_usage cmd_rem_usage
else else
cmd_custom_usage(cmd) cmd_custom_usage(cmd)
@ -54,17 +57,15 @@ module Chronicle
.gsub(/#{pfx}\w+\s*/, '') .gsub(/#{pfx}\w+\s*/, '')
.strip .strip
res = 'Invalid command' res = case cmd
when 'addcommand'
case cmd handle_addcommand(roomid, msgstr)
when "addcommand" when 'modcommand'
res = handle_addcommand(roomid, msgstr) handle_modcommand(roomid, msgstr)
when "modcommand" when 'remcommand'
res = handle_modcommand(roomid, msgstr) handle_remcommand(roomid, msgstr)
when "remcommand"
res = handle_remcommand(roomid, msgstr)
else else
res = handle_runcommand(roomid, cmd) handle_runcommand(roomid, cmd)
end end
room = @bot.client.ensure_room(roomid) room = @bot.client.ensure_room(roomid)