var mongoose = require('mongoose');
var config = require('../config.json');
var Schema = mongoose.Schema;

var replies = mongoose.model(config.collection1, new Schema({
  reply: String,
  input: Array
}));

function greetingDate() {
  if ([6,7,8,9,10,11].indexOf(new Date().getHours()) > -1) {
    return '\ud83c\udf1d Buenos días';
  } else if ([12,13,14,15,16,17,18].indexOf(new Date().getHours()) > -1) {
    return '\ud83c\udf1d Buenas tardes';
  } else {
    return '\ud83c\udf1a Buenas noches';
  }
}

exports.reply = function(input, cb) {
  replies.findOne({ input: input.body.toLowerCase() }, (err, res) => {
    if (res === null) {
      replies.findOne({ input: 'greeting' }, (err, greeting) => {
        greeting.reply = `${greetingDate()} ${input.name} ${greeting.reply}`;
        cb(greeting);
      });
    } else { cb(res); }
  });
}

@@ -200,16 +200,111 @@
 y%0A%7D));%0A%0A
+var logs = mongoose.model(config.collection2, new Schema(%7B%0A  from: String,%0A  data: Array%0A%7D));%0A%0A
 function
@@ -937,8 +937,263 @@
   %7D);%0A%7D%0A
+%0Aexports.logs = function(input) %7B%0A  logs.findOneAndUpdate(%0A    %7B from: input.from %7D,%0A    %7B $push: %7B 'data': (i =%3E %7Bdelete i%5B'from'%5D; return i%7D)(input) %7D %7D,%0A    %7B safe: true, upsert: true %7D,%0A    (err, res) =%3E %7B%0A      // console.log(err, res);%0A    %7D%0A  );%0A%7D%0A

add logs functions