 
 # LOGIC -------------------------------------------------------------------------
 
+handleMessage = (bot, channel, isDirect, message) ->
+  team = bot.identifyTeam()
+
+  bot.reply {
+    channel: channel
+  }, {
+    text: ":star: channel=#{channel} isDirect=#{isDirect} message=#{message}"
+  }
+

        (cb) -> db.run "CREATE TABLE metadata (key TEXT PRIMARY KEY, value TEXT)", cb
        (cb) -> db.run "CREATE TABLE factoids (key TEXT PRIMARY KEY, value TEXT, last_edit TEXT)", cb
        (cb) -> db.run "INSERT INTO metadata VALUES($key, $value)", {$key: key, $value: value}, cb
      ], (err) ->
        if err then return cb "Couldn't initialize metadata for team #{team}: #{err}"
        log.info "Set metadata key #{key} for team #{team} with new table"

    if err
      log.error "Couldn't get token for #{team}: #{err}"
      return

    bot = bots[team] = controller.spawn(token: token)
    updateBotMetadata bot, team, (err) ->
      if err
        log.error "Couldn't update bot metadata: #{err}"
        return
      bot.startRTM()

for file in fs.readdirSync process.env.DATA_DIR
  log.info "Found db file for #{file}"
