<commit_before>'use strict';

module.exports = function listenForQueries() {

  var self = this;

  console.log( 'listening...' );

  var stream = self.T.stream( 'user' );

  stream.on( 'tweet', respondToTweet );

  function respondToTweet( tweet ) {
    if ( tweet.user.screen_name !== 'FrontPageBot' ) {

      // TODO: filter out other screen names and add to replyTo
      var inquiry = tweet.text.replace( /@FrontPageBot /i, '', 'i');
      var replyTo = '@' + tweet.user.screen_name;

      var page = self.pages.filter( function findPageMatch( page ) {
        var titleMatchRegex = new RegExp( inquiry, 'gi' );

        return ( page.title.search( titleMatchRegex ) >= 0 );
      });

      console.log( tweet.text, page );

      if ( page.length > 0 ) {
        self.prepareTweet({
          title: page[0].title,
          src: page[0].src,
          loc: page[0].loc,
          mentions: replyTo,
          replyTo: tweet.id
        }, function(){});
      } else {
        console.log( inquiry );
      }

    }
  }

};
<commit_msg>replies require tweet.id_str for some reason<commit_after>'use strict';

module.exports = function listenForQueries() {

  var self = this;

  console.log( 'listening...' );

  var stream = self.T.stream( 'user' );

  stream.on( 'tweet', respondToTweet );

  function respondToTweet( tweet ) {
    if ( tweet.user.screen_name !== 'FrontPageBot' ) {

      // TODO: filter out other screen names and add to replyTo
      var inquiry = tweet.text.replace( /@FrontPageBot /i, '', 'i');
      var replyTo = '@' + tweet.user.screen_name;

      var page = self.pages.filter( function findPageMatch( page ) {
        var titleMatchRegex = new RegExp( inquiry, 'gi' );

        return ( page.title.search( titleMatchRegex ) >= 0 );
      });

      console.log( tweet.text, page );

      if ( page.length > 0 ) {
        self.prepareTweet({
          title: page[0].title,
          src: page[0].src,
          loc: page[0].loc,
          mentions: replyTo,
          replyTo: tweet.id_str
        }, function(){});
      } else {
        console.log( inquiry );
      }

    }
  }

};

{'fraction_non_alphanumeric': 0.14541176470588235, 'fraction_numerical': 0.004705882352941176, 'mean_word_length': 2.1969924812030075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4408463', 'n_tokens_mistral': 702, 'n_tokens_neox': 657, 'n_words': 163}