<commit_before>'use strict';

var ascii_art = require('../../ascii-art.js');

function messageListener(db, from, channel, message) {
  var img_regex = /^https?:\/\/[^ ]+\.(png|jpg|gif)$/i;

  if (img_regex.test(message)) {
    var img_url = message;

    return [{
      callback: function(say) {
        ascii_art(img_url, function(art) {
          say(channel, art);
        });
      }
    }];
  }
}

module.exports = messageListener;<commit_msg>Add time delay before each line of ascii art<commit_after>'use strict';

var ascii_art = require('../../ascii-art.js');

function messageListener(db, from, channel, message) {
  var img_regex = /^ascii +https?:\/\/[^ ]+\.(png|jpg|gif)$/i;

  if (img_regex.test(message)) {
    var img_url = message.replace(/^ascii +/, '');

    return [{
      callback: function(say) {
        ascii_art(img_url, function(ascii) {
          var lines = ascii.split("\n");

          slowly_say(say, channel, lines);
        });
      }
    }];
  }
}

function slowly_say(say, channel, lines) {
  var line = lines.shift();

  if (line) {
    say(channel, line);
    setTimeout(function() {slowly_say(say, channel, lines);}, 1000);
  }
}

module.exports = messageListener;
{'fraction_non_alphanumeric': 0.18106312292358803, 'fraction_numerical': 0.0033222591362126247, 'mean_word_length': 2.87459807073955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1667441', 'n_tokens_mistral': 430, 'n_tokens_neox': 404, 'n_words': 84}