m.reply rep\r
end\r
\r
- def help(plugin, topic="")\r
- case topic\r
- when /^login/\r
+ def help(cmd, topic="")\r
+ case cmd\r
+ when "login"\r
return "login [<botuser>] [<pass>]: logs in to the bot as botuser <botuser> with password <pass>. When using the full form, you must contact the bot in private. <pass> can be omitted if <botuser> allows login-by-mask and your netmask is among the known ones. if <botuser> is omitted too autologin will be attempted"\r
- when /^whoami/\r
+ when "whoami"\r
return "whoami: names the botuser you're linked to"\r
- when /^permission syntax/\r
- return "a permission is specified as module::path::to::cmd; when you want to enable it, prefix it with +; when you want to disable it, prefix it with -; when using the +reset+ command, do not use any prefix"\r
when /^permission/\r
- return "permissions (re)set <permission> [in <channel>] for <user>: sets or resets the permissions for botuser <user> in channel <channel> (use ? to change the permissions for private addressing)"\r
- when /^user show/\r
- return "user show <what> : shows info about the user; <what> can be any of autologin, login-by-mask, netmasks"\r
- when /^user (en|dis)able/\r
- return "user enable|disable <what> : turns on or off <what> (autologin, login-by-mask)"\r
- when /^user set/\r
- return "user set password <blah> : sets the user password to <blah>; passwords can only contain upper and lowercase letters and numbers, and must be at least 4 characters long"\r
- when /^user (add|rm)/\r
- return "user add|rm netmask <mask> : adds/removes netmask <mask> from the list of netmasks known to the botuser you're linked to"\r
- when /^user reset/\r
- return "user reset <what> : resets <what> to the default values. <what> can be +netmasks+ (the list will be emptied), +autologin+ or +login-by-mask+ (will be reset to the default value) or +password+ (a new one will be generated and you'll be told in private)"\r
- when /^user tell/\r
- return "user tell <who> the password for <botuser> : contacts <who> in private to tell him/her the password for <botuser>"\r
- when /^user create/\r
- return "user create <name> <password> : create botuser named <name> with password <password>. The password can be omitted, in which case a random one will be generated. The <name> should only contain alphanumeric characters and the underscore (_)"\r
- when /^user list/\r
- return "user list : lists all the botusers"\r
- when /^user destroy/\r
- return "user destroy <botuser> <password> : destroys <botuser>; this function #{Bold}must#{Bold} be called in two steps. On the first call, no password must be specified: <botuser> is then queued for destruction. On the second call, you must specify the correct password for <botuser>, and it will be destroyed. If you want to cancel the destruction, issue the command +user cancel destroy <botuser>+"\r
- when /^user/\r
- return "user show, enable|disable, add|rm netmask, set, reset, tell, create, list, destroy"\r
+ case topic\r
+ when "syntax"\r
+ return "a permission is specified as module::path::to::cmd; when you want to enable it, prefix it with +; when you want to disable it, prefix it with -; when using the +reset+ command, do not use any prefix"\r
+ else\r
+ return "permissions (re)set <permission> [in <channel>] for <user>: sets or resets the permissions for botuser <user> in channel <channel> (use ? to change the permissions for private addressing)"\r
+ end\r
+ when "user"\r
+ case topic\r
+ when "show"\r
+ return "user show <what> : shows info about the user; <what> can be any of autologin, login-by-mask, netmasks"\r
+ when /^(en|dis)able/\r
+ return "user enable|disable <what> : turns on or off <what> (autologin, login-by-mask)"\r
+ when "set"\r
+ return "user set password <blah> : sets the user password to <blah>; passwords can only contain upper and lowercase letters and numbers, and must be at least 4 characters long"\r
+ when "add", "rm"\r
+ return "user add|rm netmask <mask> : adds/removes netmask <mask> from the list of netmasks known to the botuser you're linked to"\r
+ when "reset"\r
+ return "user reset <what> : resets <what> to the default values. <what> can be +netmasks+ (the list will be emptied), +autologin+ or +login-by-mask+ (will be reset to the default value) or +password+ (a new one will be generated and you'll be told in private)"\r
+ when "tell"\r
+ return "user tell <who> the password for <botuser> : contacts <who> in private to tell him/her the password for <botuser>"\r
+ when "create"\r
+ return "user create <name> <password> : create botuser named <name> with password <password>. The password can be omitted, in which case a random one will be generated. The <name> should only contain alphanumeric characters and the underscore (_)"\r
+ when "list"\r
+ return "user list : lists all the botusers"\r
+ when "destroy"\r
+ return "user destroy <botuser> <password> : destroys <botuser>; this function #{Bold}must#{Bold} be called in two steps. On the first call, no password must be specified: <botuser> is then queued for destruction. On the second call, you must specify the correct password for <botuser>, and it will be destroyed. If you want to cancel the destruction, issue the command +user cancel destroy <botuser>+"\r
+ else\r
+ return "user show, enable|disable, add|rm netmask, set, reset, tell, create, list, destroy"\r
+ end\r
else\r
return "#{name}: login, whoami, permission syntax, permissions, user"\r
end\r
when /^(\S+)\s*(.*)$/
key = $1
params = $2
- (core_modules + plugins).each { |p|
- next unless p.name == key
+
+ # We test for the mapped commands first
+ k = key.to_sym
+ [core_commands, plugin_commands].each { |pl|
+ next unless pl.has_key?(k)
+ p = pl[k][:botmodule]
begin
return p.help(key, params)
rescue Exception => err
error report_error("#{p.botmodule_class} #{p.name} help() failed:", err)
end
}
- k = key.to_sym
- [core_commands, plugin_commands].each { |pl|
- next unless pl.has_key?(k)
- p = pl[k][:botmodule]
+
+ # If no such commmand was found, we look for a botmodule with that name
+ (core_modules + plugins).each { |p|
+ next unless p.name == key
begin
- return p.help(p.name, params)
+ return p.help(key, params)
rescue Exception => err
#rescue TimeoutError, StandardError, NameError, SyntaxError => err
error report_error("#{p.botmodule_class} #{p.name} help() failed:", err)