]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/auth.rb
auth: better clarify the allow/deny syntax
[user/henk/code/ruby/rbot.git] / lib / rbot / core / auth.rb
index f5745d0e96aa63ca1a7b48bfbf48822dcc490520..5e80d880081585d874578aa2d41e1b1bbcf00fed 100644 (file)
@@ -37,6 +37,13 @@ class AuthModule < CoreBotModule
   def load_array(key=:default, forced=false)
     debug "loading botusers (#{key}): #{@registry[key].pretty_inspect}"
     @bot.auth.load_array(@registry[key], forced) if @registry.has_key?(key)
+    if @bot.auth.botowner.password != @bot.config['auth.password']
+      error "Master password is out of sync!"
+      debug "  db password: #{@bot.auth.botowner.password}"
+      debug "conf password: #{@bot.config['auth.password']}"
+      error "Using conf password"
+      @bot.auth.botowner.password = @bot.config['auth.password']
+    end
   end
 
   # The permission parameters accept arguments with the following syntax:
@@ -153,7 +160,7 @@ class AuthModule < CoreBotModule
   def auth_view_perm(m, params)
     begin
       if params[:user].nil?
-        user = get_botusername_for(m.source)
+        user = get_botuser_for(m.source)
         return m.reply(_("you are owner, you can do anything")) if user.owner?
       else
         user = @bot.auth.get_botuser(params[:user].sub(/^all$/,"everyone"))
@@ -235,23 +242,27 @@ class AuthModule < CoreBotModule
       where = m.parse_channel_list(p[:where].to_s).first # should only be one anyway
     end
 
-    # pseudo-message to find the template. The source is ignored, and the
-    # target is set according to where the template should be checked
-    # (public or private)
-    # This might still fail in the case of 'everywhere' for commands there are
-    # really only private
-    case where
-    when :"?"
-      pseudo_target = @bot.myself
-    when :*
-      pseudo_target = m.channel
+    if p.has_key? :auth_path
+      auth_path = p[:auth_path]
     else
-      pseudo_target = m.server.channel(where)
-    end
+      # pseudo-message to find the template. The source is ignored, and the
+      # target is set according to where the template should be checked
+      # (public or private)
+      # This might still fail in the case of 'everywhere' for commands there are
+      # really only private
+      case where
+      when :"?"
+        pseudo_target = @bot.myself
+      when :*
+        pseudo_target = m.channel
+      else
+        pseudo_target = m.server.channel(where)
+      end
 
-    pseudo = PrivMessage.new(bot, m.server, m.source, pseudo_target, p[:stuff].to_s)
+      pseudo = PrivMessage.new(bot, m.server, m.source, pseudo_target, p[:stuff].to_s)
 
-    auth_path = find_auth(pseudo)
+      auth_path = find_auth(pseudo)
+    end
     debug auth_path
 
     if auth_path
@@ -394,15 +405,27 @@ class AuthModule < CoreBotModule
         return _("user topics: show, enable|disable, add|rm netmask, set, reset, tell, create, list, destroy")
       end
     when "auth"
-      return _("auth <masterpassword>: log in as the bot owner; other commands: login, whoami, permission syntax, permissions [re]set, permissions view, user, meet, hello, allow, prevent")
+      return _("auth <masterpassword>: log in as the bot owner; other commands: login, whoami, permissions syntax, permissions [re]set, permissions view, user, meet, hello, allow, prevent")
     when "meet"
       return _("meet <nick> [as <user>]: creates a bot user for nick, calling it user (defaults to the nick itself)")
     when "hello"
       return _("hello: creates a bot user for the person issuing the command")
     when "allow"
-      return _("allow <user> to do <sample command> [<where>]: gives botuser <user> the permissions to execute a command such as the provided sample command (in private or in channel, according to the optional <where>)")
+      return [
+        _("allow <user> to do <sample command> [<where>]: gives botuser <user> the permissions to execute a command such as the provided sample command"),
+        _("(in private or in channel, according to the optional <where>)."),
+        _("<sample command> should be a full command, not just the command keyword --"),
+        _("correct: allow user to do addquote stuff --"),
+        _("wrong: allow user to do addquote.")
+      ].join(" ")
     when "deny"
-      return _("deny <user> from doing <sample command> [<where>]: removes from botuser <user> the permissions to execute a command such as the provided sample command (in private or in channel, according to the optional <where>)")
+      return [
+        _("deny <user> from doing <sample command> [<where>]: removes from botuser <user> the permissions to execute a command such as the provided sample command"),
+        _("(in private or in channel, according to the optional <where>)."),
+        _("<sample command> should be a full command, not just the command keyword --"),
+        _("correct: deny user from doing addquote stuff --"),
+        _("wrong: deny user from doing addquote.")
+      ].join(" ")
     else
       return _("auth commands: auth, login, whoami, who, permission[s], user, meet, hello, allow, deny")
     end