<commit_before>var request = require('request');
var oauth = require('oauth');
var sentiment = require('sentiment');

var oauth = new oauth.OAuth(
  'https://api.twitter.com/oauth/request_token',
  'https://api.twitter.com/oauth/access_token',
  process.env.CONSUMER_KEY,
  process.env.CONSUMER_SECRET,
  '1.0A',
  null,
  'HMAC-SHA1'
);

exports.getMentions = function(req, res, callback){
  callback = callback || analyzeTweets;
  oauth.get(
    'https://api.twitter.com/1.1/statuses/mentions_timeline.json?count=800',
    process.env.ACCESS_TOKEN_KEY, //test user token
    process.env.ACCESS_TOKEN_SECRET, //test user secret            
    function (e, data, res){
      if (e) return console.error(e);
      callback(data);
      // res.send(200,'tweets obtained!')
    });    
}

exports.sendMessage = function(message, number){
  console.log('sending message!')
  number = number || process.env.TEST_PHONE;
  var text = {
    api_key: process.env.NEXMO_KEY,
    api_secret: process.env.NEXMO_SECRET,
    from: process.env.NEXMO_PHONE,
    to: number,
    text: message
  };
  
  request.post('https://rest.nexmo.com/sms/json',{
    form: text
  },function(err,data){
    if(err) return console.error(err);
    console.log('DATA!',data.body);
  });<commit_msg>Added setInterval for continuous checking of twitter messages<commit_after>var request = require('request');
var oauth = require('oauth');
var sentiment = require('sentiment');

var oauth = new oauth.OAuth(
  'https://api.twitter.com/oauth/request_token',
  'https://api.twitter.com/oauth/access_token',
  process.env.CONSUMER_KEY,
  process.env.CONSUMER_SECRET,
  '1.0A',
  null,
  'HMAC-SHA1'
);

setInterval(function() {
  exports.getMentions();
}, 15000);

exports.getMentions = function(req, res, callback){
  callback = callback || analyzeTweets;
  oauth.get(
    'https://api.twitter.com/1.1/statuses/mentions_timeline.json?count=800',
    process.env.ACCESS_TOKEN_KEY, //test user token
    process.env.ACCESS_TOKEN_SECRET, //test user secret            
    function (e, data, res){
      if (e) return console.error(e);
      callback(data);
      // res.send(200,'tweets obtained!')
    });    
}

exports.sendMessage = function(message, number){
  console.log('sending message!')
  number = number || process.env.TEST_PHONE;
  var text = {
    api_key: process.env.NEXMO_KEY,
    api_secret: process.env.NEXMO_SECRET,
    from: process.env.NEXMO_PHONE,
    to: number,
    text: message
  };
  
  request.post('https://rest.nexmo.com/sms/json',{
    form: text
  },function(err,data){
    if(err) return console.error(err);
    console.log('DATA!',data.body);
  });
{'fraction_non_alphanumeric': 0.15582450832072617, 'fraction_numerical': 0.01021180030257186, 'mean_word_length': 3.6, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, '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': '6228142', 'n_tokens_mistral': 960, 'n_tokens_neox': 946, 'n_words': 162}