<commit_before>/*
  Text-mangling module for this bot

  Based on the perl module Text::Bastardize v0.06 by <NAME> (1999)
  The module was licensed under the GPL.
*/

var _ = require('underscore');

exports.type = 'command';

// all manglers under here
var manglers = {};

exports.listAll = function() {
  return [
    '*', 'rot13', 'k3wlt0k', 'reduct', 'reverse', 'n20e', 'gnu', 'aol',
    'uppercase', 'titlecase', 'lowercase', 'leetspeak', 'sort', 'shuffle'
  ];
};

exports.getHelp = function() {
  return {
    '*': ' `mangler.<type> <text...>` - mangle text using a specific algorithm'
  };
};

exports.listener = function(line, words, respond) {
  var ev = this.event.split('.');

  if (ev.length < 2) {
    respond('you didn\'t specify a mangling type! see `help mangler` and `list mangler`');
    return;
  }

  if (manglers.hasOwnProperty(ev[1])) {
    respond(manglers[ev[1]](words.slice(1).join(' ')));
  }
};

exports.init = function(config, myconfig, alias) {};

// https://stackoverflow.com/a/617685/2278637
manglers.rot13 = function(s) {
  return s.replace(/[a-zA-Z]/g, function(c){
    return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);
  });
};

// Text::Bastardize
manglers.k3wlt0k = function(text) {
  // okay left-to-right replacements then
  text = text.toLowerCase()
             .replace(/\bth/g, 'd')
             .replace(/ck\b/g, 'x0r')
             .replace(/cking\b/g, 'x0ring')
             .replace(/cked\b/g, 'x0red')
             .replace(/cker/g, 'x0r')
             .replace(/ing/g, 'in')
             .replace(/cause/g, 'cus')
             .replace(/fu/g, 'f00')
             .replace(/word/g, 'werd')
             .replace(/oo/g, 'ew')
             .replace(/for/g, '4')
             .replace(/ate/g, '8')
             .replace(/uaes itz clo/g, 'v34z 17z s10')
             .replace(/\'/g, '')
             .replace(/\./g, '...')
             .replace(/!/g, '!!!')
             .replace(/\?/g, '???')
             .replace(/\bc/g, 'k')
             .replace(/\b00/g, 'o0')
             .replace(/0rk/g, 'r0k')
             .replace(/y0v/g, 'j00')
             .replace(/[ck]001/g, 'k3wl')
             .replace(/741k/g, 't0k')
             .replace(/j00\B/g, 'j3r')
             .replace(/3z/g, 'z3')
             .replace(/3r/g, 'ur')
             .toUpperCase();
  return text;
};

// Text::Bastardize
manglers.reduct = function(text) {
  return text.toLowerCase()
             .replace(/!#\.,\?'";/g,'')
             .replace(/of/g,'uv')
             .replace(/one/g,'1')
             .replace(/\b(?:a|e)/g,'')
             .replace(/a?n?ks/g,'x')
             .replace(/you/g,'u')
             .replace(/are/g,'r')
             .replace(/you'?re?/g,'ur')
             .replace(/\B(?:a|e|i|o|u)\B/g,'');
};

// ... I don't think there is an origin
manglers.reverse = function(text) {
  return text.split('').reverse().join('');
};

// Text::Bastardize
manglers.n20e = function(text) {
  var start = text[0];
  var end = text[text.length -1];
  var n = text.length - 2;
  return start + n + end;
};

manglers.gnu = function(text) {
  return 'GNU/' + text;
};

manglers.aol = function(text) {
  var addition = _.sample([
    '<3', ':D', '~', '!', '.', ':)', ';)'
  ]);

  return text + addition + addition + addition;
};

manglers.uppercase = function(text) {
  return text.toUpperCase();
};
<commit_msg>extra additions to manglers.aol<commit_after>/*
  Text-mangling module for this bot

  Based on the perl module Text::Bastardize v0.06 by <NAME> (1999)
  The module was licensed under the GPL.
*/

var _ = require('underscore');

exports.type = 'command';

// all manglers under here
var manglers = {};

exports.listAll = function() {
  return [
    '*', 'rot13', 'k3wlt0k', 'reduct', 'reverse', 'n20e', 'gnu', 'aol',
    'uppercase', 'titlecase', 'lowercase', 'leetspeak', 'sort', 'shuffle'
  ];
};

exports.getHelp = function() {
  return {
    '*': ' `mangler.<type> <text...>` - mangle text using a specific algorithm'
  };
};

exports.listener = function(line, words, respond) {
  var ev = this.event.split('.');

  if (ev.length < 2) {
    respond('you didn\'t specify a mangling type! see `help mangler` and `list mangler`');
    return;
  }

  if (manglers.hasOwnProperty(ev[1])) {
    respond(manglers[ev[1]](words.slice(1).join(' ')));
  }
};

exports.init = function(config, myconfig, alias) {};

// https://stackoverflow.com/a/617685/2278637
manglers.rot13 = function(s) {
  return s.replace(/[a-zA-Z]/g, function(c){
    return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);
  });
};

// Text::Bastardize
manglers.k3wlt0k = function(text) {
  // okay left-to-right replacements then
  text = text.toLowerCase()
             .replace(/\bth/g, 'd')
             .replace(/ck\b/g, 'x0r')
             .replace(/cking\b/g, 'x0ring')
             .replace(/cked\b/g, 'x0red')
             .replace(/cker/g, 'x0r')
             .replace(/ing/g, 'in')
             .replace(/cause/g, 'cus')
             .replace(/fu/g, 'f00')
             .replace(/word/g, 'werd')
             .replace(/oo/g, 'ew')
             .replace(/for/g, '4')
             .replace(/ate/g, '8')
             .replace(/uaes itz clo/g, 'v34z 17z s10')
             .replace(/\'/g, '')
             .replace(/\./g, '...')
             .replace(/!/g, '!!!')
             .replace(/\?/g, '???')
             .replace(/\bc/g, 'k')
             .replace(/\b00/g, 'o0')
             .replace(/0rk/g, 'r0k')
             .replace(/y0v/g, 'j00')
             .replace(/[ck]001/g, 'k3wl')
             .replace(/741k/g, 't0k')
             .replace(/j00\B/g, 'j3r')
             .replace(/3z/g, 'z3')
             .replace(/3r/g, 'ur')
             .toUpperCase();
  return text;
};

// Text::Bastardize
manglers.reduct = function(text) {
  return text.toLowerCase()
             .replace(/!#\.,\?'";/g,'')
             .replace(/of/g,'uv')
             .replace(/one/g,'1')
             .replace(/\b(?:a|e)/g,'')
             .replace(/a?n?ks/g,'x')
             .replace(/you/g,'u')
             .replace(/are/g,'r')
             .replace(/you'?re?/g,'ur')
             .replace(/\B(?:a|e|i|o|u)\B/g,'');
};

// ... I don't think there is an origin
manglers.reverse = function(text) {
  return text.split('').reverse().join('');
};

// Text::Bastardize
manglers.n20e = function(text) {
  var start = text[0];
  var end = text[text.length -1];
  var n = text.length - 2;
  return start + n + end;
};

manglers.gnu = function(text) {
  return 'GNU/' + text;
};

manglers.aol = function(text) {
  var addition = _.sample([
    '<3', ':D', '~', '!', '.', ':)', ';)', ':-)', ':^)', ':^y'
  ]);

  return text + addition + addition + addition;
};

manglers.uppercase = function(text) {
  return text.toUpperCase();
};

{'fraction_non_alphanumeric': 0.22087701166395984, 'fraction_numerical': 0.025690240661449874, 'mean_word_length': 2.091738931994523, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '2851755', 'n_tokens_mistral': 2624, 'n_tokens_neox': 2513, 'n_words': 456}