<commit_before>'use strict'

const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const fs = require('fs');
const path = require('path');
const chat = require('./chatCommands.js');
const dbController = require( './dbController' );
const mongoose = require('mongoose');

mongoose.connect( 'mongodb://homee:<EMAIL>:25802/homee-bot' );
const db = mongoose.connection;


//Need to parse body with bodyparser to JSON
var jsonParser = bodyParser.json();

app.use(express.static(path.join(__dirname, './client')));

/******************************************
 **************DB CONNECTION****************
 *******************************************/
db.on( 'error', console.error.bind( console, 'connection error:' ) );
db.once( 'open', function () {
	console.log( "your db is open" );
} );



/******************************************
 **************WEBHOOK STUFF****************
 *******************************************/
app.get('/webhook/', function(req, res) {
  if (req.query['hub.verify_token'] === 'this_is_my_token') {
    res.send(req.query['hub.challenge']);
  }
  res.send('Error, wrong validation token');
});

// app.post('/webhook/', jsonParser, dbController.getInfo, chat.askQuestions, function(req, res) {
app.post('/webhook/', jsonParser, function(req, res) {
  // let messaging_events = req.body.entry[0].messaging;
  // for (let i = 0; i < messaging_events.length; i++) {
  //   let event = req.body.entry[0].messaging[i];
  //   let sender = event.sender.id;
  //   // req.sender = event.sender.id;
  //   if (event.message && event.message.text) {
  //     let text = event.message.text;
  //     // if (text === 'Generic') {
  //     //   chat.sendGenericMessage(sender);
  //     //   continue;
  //     // }
  //     // chat.sendTextMessage(sender, "Text received, echo: "+ text.substring(0, 200));
      chat.sendTextMessage(sender, "Text received, echo: "+ req.info.questsAnsd);
  //   }
  // }
  req.info = {};
  res.sendStatus(200);
  console.log("DONE ");
  // res.end();
});

// app.post('/webhook/', jsonParser, function(req, res) {
//   let messaging_events = req.body.entry[0].messaging;
//   for (let i = 0; i < messaging_events.length; i++) {
//     let event = req.body.entry[0].messaging[i];
//     let sender = event.sender.id;
//     // req.sender = event.sender.id;
//     if (event.message && event.message.text) {
//       let text = event.message.text;
//       // if (text === 'Generic') {
//       //   chat.sendGenericMessage(sender);
//       //   continue;
//       // }
//       // chat.sendTextMessage(sender, "Text received, echo: "+ text.substring(0, 200));
//       chat.sendTextMessage(sender, "Text received, echo: "+ text);
//     }
//   }
//   res.sendStatus(200);
//   console.log("DONE ");
// });

app.listen(process.env.PORT || 3000, function() {
  console.log('Server is lisening on port 3000');
});
<commit_msg>adding questions and functionality<commit_after>'use strict'

const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const fs = require('fs');
const path = require('path');
const chat = require('./chatCommands.js');
const dbController = require( './dbController' );
const mongoose = require('mongoose');

mongoose.connect( 'mongodb://homee:<EMAIL>:25802/homee-bot' );
const db = mongoose.connection;


//Need to parse body with bodyparser to JSON
var jsonParser = bodyParser.json();

app.use(express.static(path.join(__dirname, './client')));

/******************************************
 **************DB CONNECTION****************
 *******************************************/
db.on( 'error', console.error.bind( console, 'connection error:' ) );
db.once( 'open', function () {
	console.log( "your db is open" );
} );



/******************************************
 **************WEBHOOK STUFF****************
 *******************************************/
app.get('/webhook/', function(req, res) {
  if (req.query['hub.verify_token'] === '<PASSWORD>') {
    res.send(req.query['hub.challenge']);
  }
  res.send('Error, wrong validation token');
});

// app.post('/webhook/', jsonParser, dbController.getInfo, chat.askQuestions, function(req, res) {
app.post('/webhook/', jsonParser, dbController.getInfo, function(req, res) {
  // let messaging_events = req.body.entry[0].messaging;
  // for (let i = 0; i < messaging_events.length; i++) {
  //   let event = req.body.entry[0].messaging[i];
  //   let sender = event.sender.id;
  //   // req.sender = event.sender.id;
  //   if (event.message && event.message.text) {
  //     let text = event.message.text;
  //     // if (text === 'Generic') {
  //     //   chat.sendGenericMessage(sender);
  //     //   continue;
  //     // }
  //     // chat.sendTextMessage(sender, "Text received, echo: "+ text.substring(0, 200));
      chat.sendTextMessage(req.info.sender, "Text received, echo: "+ req.info.questsAnsd);
  //   }
  // }
  req.info = {};
  res.sendStatus(200);
  console.log("DONE ");
  // res.end();
});

// app.post('/webhook/', jsonParser, function(req, res) {
//   let messaging_events = req.body.entry[0].messaging;
//   for (let i = 0; i < messaging_events.length; i++) {
//     let event = req.body.entry[0].messaging[i];
//     let sender = event.sender.id;
//     // req.sender = event.sender.id;
//     if (event.message && event.message.text) {
//       let text = event.message.text;
//       // if (text === 'Generic') {
//       //   chat.sendGenericMessage(sender);
//       //   continue;
//       // }
//       // chat.sendTextMessage(sender, "Text received, echo: "+ text.substring(0, 200));
//       chat.sendTextMessage(sender, "Text received, echo: "+ text);
//     }
//   }
//   res.sendStatus(200);
//   console.log("DONE ");
// });

app.listen(process.env.PORT || 3000, function() {
  console.log('Server is lisening on port 3000');
});

{'fraction_non_alphanumeric': 0.2634974533106961, 'fraction_numerical': 0.011205432937181663, 'mean_word_length': 3.2688405797101447, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2285993', 'n_tokens_mistral': 1932, 'n_tokens_neox': 1855, 'n_words': 370}