]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/auth.rb
remove whitespace
[user/henk/code/ruby/rbot.git] / lib / rbot / core / auth.rb
index 75c59f27cd55c93e5713c1a8495b44ded3aa1b67..275f5d7e18711a1fa293ddb679edfcdbe9420b4d 100644 (file)
@@ -160,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"))
@@ -242,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
@@ -407,9 +411,21 @@ class AuthModule < CoreBotModule
     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
@@ -801,13 +817,13 @@ class AuthModule < CoreBotModule
 
   def auth_export(m, params)
 
-    exportfile = "#{@bot.botclass}/new-auth.users"
+    exportfile = @bot.path "new-auth.users"
 
     what = params[:things]
 
     has_to = what[-2] == "to"
     if has_to
-      exportfile = "#{@bot.botclass}/#{what[-1]}"
+      exportfile = @bot.path what[-1]
       what.slice!(-2,2)
     end
 
@@ -873,13 +889,13 @@ class AuthModule < CoreBotModule
 
   def auth_import(m, params)
 
-    importfile = "#{@bot.botclass}/new-auth.users"
+    importfile = @bot.path "new-auth.users"
 
     what = params[:things]
 
     has_from = what[-2] == "from"
     if has_from
-      importfile = "#{@bot.botclass}/#{what[-1]}"
+      importfile = @bot.path what[-1]
       what.slice!(-2,2)
     end