     # robot.send({room: "bot"}, 'hello')
     process.exit()
 
-  # test()
+#  test()
+
 
 
 
 
   ### Event class ###
   robot.on 'healthcheck:url', (data) ->
-      options = {
-        url: data.url
-        status: data.status
-        headers: "User-Agent":"iPhone"
-      }
-      request.get options, (err, res, body) ->
+    options = {
+      url: data.url
+      status: data.status
+      headers: "User-Agent":"iPhone"
+    }
+    request.get options, (err, res, body) ->
 #        robot.logger.info data.status
 #        robot.logger.info options.url
 #        robot.logger.info res.statusCode
-        if err
+      if err
 #          robot.logger.error err
 #          robot.send {room: "notifications"}, "error: #{res.statusCode}"
-          robot.send {room: "bot"}, err
-        else if res.statusCode is options.status
-          msg = "#{options.url} : #{res.statusCode}"
-          robot.send {room: "bot"}, msg + " All right :)"
-        else if res.statusCode isnt options.status #doesn't matched
+        robot.send {room: "bot"}, err
+      else if res.statusCode is options.status
+        msg = "#{options.url} : #{res.statusCode}"
+        robot.send {room: "bot"}, msg + " All right :)"
+      else if res.statusCode isnt options.status #doesn't matched
 #          robot.logger.error err
-          msg = "#{options.url} : #{res.statusCode}"
-          robot.send {room: "bot"}, msg + " Something wrong :("
+        msg = "#{options.url} : #{res.statusCode}"
+        robot.send {room: "bot"}, msg + " Something wrong :("
 #        else if res.statusCode isnt 200 #!200
 ##          robot.logger.error res.headers
 ##          robot.send {room: "bot"}, "success: #{res.statusCode}"

module.exports = (robot) ->
  ### tmp check ###
  robot.hear /sc sites/i, (msg) ->
    msg.send 'checking...'
    key = 'sites'
    urls = robot.brain.get(key) ? []
    url = urls.map (i) ->
        "#{i.url} #{i.status}"
      .join '\n'
    msg.send url
    msg.send urls.length
    msg.send urls[0]

    for u, s in urls #u: url, s:status
      robot.logger.info u, s #@@
      robot.emit 'healthcheck:url', {url: u, status: s}

#    robot.emit 'healthcheck:url', {url: 'https://www.google.com', status: 200}
#    robot.emit 'healthcheck:url', {url: 'http://takamachi.com/hogehoge', status: 200}
#    robot.emit 'healthcheck:url', {url: 'http://sasukene.info', status: 500}
#


  test = ->
    messages = []
    key = 'sites'
    i = { url: 'www.google.com', status: 200}

    i = { url: 'www.yahoo.co.jp', status: 200}
    messages.push i
    robot.logger.info messages
#    messages = [
#      hoge: {url: 'hoge.com'},
#      fuga: {url: 'fuga.com'}
#    ]

    for valueObject, key in messages #u: url, s:status
      robot.send({room: "bot"}, 'key: '+key, 'url: '+ valueObject.url, 'staus: '+ valueObject.status)
    # robot.logger.info key, value, key #@@

    process.exit()
