             json_body = null
         cb json_body
 
-
-
-  getLogs = (room, start, stop, cb) ->
-    # would be good to replace this with a filter, we don't need relevance
-    query = {
-      query: {
-        bool: {
-          must: [
-            {
-              range:
-                "@timestamp": {
-                  from: start,
-                  to: stop
-                }
-            },
-            {
-              match_phrase: {
-                room: room
-              }
-            }
-          ]
-        }
-      },
-      sort: {
-        "@timestamp": {
-          order: "asc"
-        }
-      },
-      size: 1000
-    }
-    json = JSON.stringify(query)
-    index = logIndexName + '-' + start.format('YYYY.MM.DD')
-    index_end = logIndexName + '-' + stop.format('YYYY.MM.DD')
-    if index == index_end
-      searchES index, json, (body) ->
-        cb body.hits.hits
-    else
-      searchES index, json, (body) ->
-        searchES index_end, json, (body_end) ->
-          cb body.hits.hits.concat(body_end.hits.hits)
-
-  getLastTerm = (room, term, cb) ->
-    query = {
-      query: {
-        bool: {
-          must: [
-            {
-              match_phrase: {
-                message: term
-              }
-            },
-            {
-              match_phrase: {
-                room: room
-              }
-            }
-          ],
-          must_not: {
-            match_phrase: {
-              message: '.recall '
-            }
-          }
-        }
-      },
-      sort: {
-        "@timestamp": {
-          order: "desc"
-        }
-      },
-      size: 1
-    }
-    json = JSON.stringify(query)
-    # console.log json
-    searchAllES json, (body) ->
-      cb body.hits.hits
-
-
-  searchAllES = (json, cb) ->
-    robot.http(logESUrl)
-      .path('/logstash-*/_search')
-      .get(json) (err, res, body) ->
-        switch res.statusCode
-          when 200 then json_body = JSON.parse(body)
-          else
-            console.log res.statusCode
-            console.log body
-            json_body = null
-        cb json_body
-
-  searchES = (index, json, cb) ->
-    robot.http(logESUrl)
-      .path(index + '/_search')
-      .post(json) (err, res, body) ->
-        switch res.statusCode
-          when 200 then json_body = JSON.parse(body)
-          else
-            console.log res.statusCode
-            console.log body
-            json_body = null
-        cb json_body
-
-
-  logContent = (room, lines, start, stop) ->
+  logContent: (room, lines, start, stop) ->
     time = moment().utc().format("HH:mm")
     start_date = start.format("MMM, ddd Do HH:mm")
     stop_date = stop.format("MMM, ddd Do HH:mm")
-    content = html_head("<a href=\"/#{robot.name}/logs\">Irc Logs</a> for #{room}")
+    content = @html_head("<a href=\"/#{robot.name}/logs\">Irc Logs</a> for #{room}")
     content += """
           <div>from #{start_date} to #{stop_date} - Times are UTC (now is #{time} UTC)</div>
           <br>

    }
    json = JSON.stringify(query)
    # console.log json
    searchAllES json, (body) ->
      cb body.hits.hits


  searchAllES = (json, cb) ->
    robot.http(logESUrl)
      .path('/logstash-*/_search')
      .get(json) (err, res, body) ->
        switch res.statusCode


  missingEnvironmentForApi: (msg) ->
    missingAnything = false
    unless @logESUrl?
      msg.send "Ensure that GANDI_LOG_ES_URL is set."
      missingAnything |= true
    unless @logRooms?
      msg.send "Ensure that GANDI_LOG_ROOMS is set."
      missingAnything |= true
    unless @logIndexName?
      msg.send "Ensure that GANDI_LOG_INDEX_NAME is set."
      missingAnything |= true
    missingAnything


