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

module.exports = {listeners: [
{
    type: "equals",
    query: ".minion",
    callback: function(reply, message){
        var url = Math.random()<.5 ? "https://www.reddit.com/r/MinionHate/top/.json?sort=top&t=week" : "https://www.reddit.com/r/WackyTicTacs/top/.json?sort=top&t=week";
        request(url, function(err, res, body){
            try{
                var posts = JSON.parse(body).data.children;
                var index = Math.floor(Math.random() * posts.length);
                while(!posts[index].data.url){
                     index = Math.floor(Math.random() * posts.length);
                }
                var minion = posts[index].data.url;
                var image = request(minion);
                if(image){
                    reply({attachment: image});
                }
                else{
                    reply({attachment: request("http://i.imgur.com/L07nbhn.jpg")});
                }
            }catch(e){
                reply({attachment: request("http://i.imgur.com/L07nbhn.jpg")});
            }<commit_msg>Limited infinite loop potential<commit_after>var request = require('request');

module.exports = {listeners: [
{
    type: "equals",
    query: ".minion",
    callback: function(reply, message){
        var url = Math.random()<.5 ? "https://www.reddit.com/r/MinionHate/top/.json?sort=top&t=week" : "https://www.reddit.com/r/WackyTicTacs/top/.json?sort=top&t=week";
        request(url, function(err, res, body){
            try{
                var posts = JSON.parse(body).data.children;
                var index = Math.floor(Math.random() * posts.length);
                var attempts = 0;
                while(!posts[index].data.url){
                     index = Math.floor(Math.random() * posts.length);
                     attempts++;
                     if(attempts > 5){
                         break;
                     }
                }
                var minion = posts[index].data.url;
                var image = request(minion);
                if(image){
                    reply({attachment: image});
                }
                else{
                    reply({attachment: request("http://i.imgur.com/L07nbhn.jpg")});
                }
            }catch(e){
                reply({attachment: request("http://i.imgur.com/L07nbhn.jpg")});
            }
{'fraction_non_alphanumeric': 0.150856665273715, 'fraction_numerical': 0.005014625992478061, 'mean_word_length': 1.5306553911205074, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '3261260', 'n_tokens_mistral': 702, 'n_tokens_neox': 665, 'n_words': 106}