    # File lib/rbot/core/auth.rb, line 105
      def auth_edit_perm(m, params)

        setting = m.message.split[1] == "set"
        splits = params[:args]

        has_for = splits[-2] == "for"
        return usage(m) unless has_for

        begin
          user = @bot.auth.get_botuser(splits[-1].sub(/^all$/,"everyone"))
        rescue
          return m.reply(_("couldn't find botuser %{name}") % {:name => splits[-1]})
        end
        return m.reply(_("you can't change permissions for %{username}") % {:username => user.username}) if user.owner?
        splits.slice!(-2,2) if has_for

        cmds, locs, warns = parse_args(splits, setting)
        errs = warns.select { |w| w.kind_of?(Exception) }

        unless errs.empty?
          m.reply _("couldn't satisfy your request: %{errors}") % {:errors => errs.join(',')}
          return
        end

        if locs.empty?
          locs << "*"
        end
        begin
          locs.each { |loc|
            ch = loc
            if m.private?
              ch = "?" if loc == "_"
            else
              ch = m.target.to_s if loc == "_"
            end
            cmds.each { |setval|
              if setting
                val = setval[0].chr == '+'
                cmd = setval[1..-1]
                user.set_permission(cmd, val, ch)
              else
                cmd = setval
                user.reset_permission(cmd, ch)
              end
            }
          }
        rescue => e
          m.reply "something went wrong while trying to set the permissions"
          raise
        end
        @bot.auth.set_changed
        debug "user #{user} permissions changed"
        m.okay
      end