]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Fix help. For real
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 17 Aug 2006 13:36:53 +0000 (13:36 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 17 Aug 2006 13:36:53 +0000 (13:36 +0000)
ChangeLog
lib/rbot/core/auth.rb
lib/rbot/plugins.rb

index e3a4e6cd5479c304578cb35065cca736942ebeec..269c051d790416bdc01c2c1ca414dc3c57229f9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
 
        * Fix help: It got broken while rearranging the plugin stuff, now it's
        properly fixed.
+       * New Auth Framework: forgot to create the InvalidPassword exception.
+       It's a RuntimeError now.
+       * Fix help: this time for real (or so I hope).
 
 2006-08-12  Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
 
index b38dd49aad99c27e5854069b6cba51b2890bee73..1fec6e4b4530e0862ce476a472367fccb7efaf65 100644 (file)
@@ -221,36 +221,42 @@ class AuthModule < CoreBotModule
     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
index 933ea14f24927dfbb3f3211b1cc31fb497d28015..b0626b9687181c8416e5d3e68e19ce0efaa439b4 100644 (file)
@@ -504,8 +504,12 @@ module Plugins
       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
@@ -513,12 +517,12 @@ module Plugins
             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)