<commit_before>'use strict';
let https = require( 'https' );
let BotPlug = require( './BotPlug.js' );
let githubConfig = require('../config.js').github;

class GithubBotPlug extends BotPlug {
    constructor( bot ){
        super( bot );

        this.characters = {
            'lastMessage': '┗',
            'message': '┣'
        };

        this.useridCache = {};

        this.loadInterval = false;

        if (githubConfig === false) {
            console.log('Failed to load github config, can\'t start');
        } else {
            this.start();
        }
    }

    start() {
        this.getAllUsers();

        this.loadInterval = setInterval(() => {
            this.getAllUsers();
        }, 60000);
    }

    rightPad( myString, size, character ) {
        myString = myString.toString();

        while (myString.length < size) {
            myString = myString + character;
        }

        return myString;
    }

    apiUrlToRealUrl( apiUrl ) {
        var realUrl = apiUrl.replace( 'api.github', 'github' );

        realUrl = realUrl.replace( '/repos/', '/' );

        return realUrl;
    }

    handleResponse( responseData, user ) {
        var message = false,
            commitText = 'commit',
            messageStart,
            commitMessage,
            i;

        if ( this.useridCache[ user ] && this.useridCache[ user ] !== responseData[ 0 ].id ) {
            responseData[0].repo.html_url = this.apiUrlToRealUrl(responseData[0].repo.url);

            switch (responseData[0].type) {
                case 'PushEvent':

                    if (responseData[0].payload.commits.length > 1) {
                        commitText = commitText + 's';
                    }

                    message = user + ' pushed ' + responseData[0].payload.commits.length + ' ' + commitText + ' to ' + responseData[0].repo.html_url;
                    for (i = 0; i < responseData[0].payload.commits.length; i = i + 1) {
                        messageStart = '    ';
                        if (i === responseData[0].payload.commits.length - 1) {
                            messageStart = messageStart + this.characters.lastMessage + '   ';
                        } else {
                            messageStart = messageStart + this.characters.message + '   ';
                        }

                        commitMessage = responseData[0].payload.commits[i].message.replace(/(\r\n|\n\r|\n\n|\r\r|\r|\n)/gm, this.rightPad('\n', messageStart.length + 1, ' '));

                        message = message + '\n' + messageStart + commitMessage;
                    }
                    break;
                case 'CreateEvent':
                    switch (responseData[0].payload.ref_type) {
                        case 'repository':
                            message = user + ' created repository ' + responseData[0].repo.html_url;
                            break;
                        case 'branch':
                            message = user + ' created a branch for ' + responseData[0].repo.name + ' called ' + responseData[0].payload.ref;
                            break;
                        case 'tag':
                            message = user + ' created a tag for ' + responseData[0].repo.name + ' called ' + responseData[0].payload.ref;
                            break;
                        default:
                            break;
                    }
                    break;
                case 'PullRequestEvent':
                    switch (responseData[0].payload.action) {
                        case 'opened':
                            message = user + ' created a pull request for ' + responseData[0].repo.name + ' titled "' + responseData[0].payload.pull_request.title + '" (' + responseData[0].payload.pull_request.html_url + ')';
                            break;
                        default:
                            break;
                    }
                    break;
                case 'IssuesEvent':
                    switch (responseData[0].payload.action) {
                        case 'opened':
                            message = user + ' created an issue for ' + responseData[0].repo.name + ' titled "' + responseData[0].payload.issue.title + '" (' + responseData[0].repo.html_url + ')';
                            break;
                        default:
                            break;
                    }
                    break;
                case 'ForkEvent':
                    message = user + ' forked repository ' + responseData[0].payload.forkee.name + ' from ' + responseData[0].repo.name;<commit_msg>Issues shouldn't link to repos.... duh<commit_after>'use strict';
let https = require( 'https' );
let BotPlug = require( './BotPlug.js' );
let githubConfig = require('../config.js').github;

class GithubBotPlug extends BotPlug {
    constructor( bot ){
        super( bot );

        this.characters = {
            'lastMessage': '┗',
            'message': '┣'
        };

        this.useridCache = {};

        this.loadInterval = false;

        if (githubConfig === false) {
            console.log('Failed to load github config, can\'t start');
        } else {
            this.start();
        }
    }

    start() {
        this.getAllUsers();

        this.loadInterval = setInterval(() => {
            this.getAllUsers();
        }, 60000);
    }

    rightPad( myString, size, character ) {
        myString = myString.toString();

        while (myString.length < size) {
            myString = myString + character;
        }

        return myString;
    }

    apiUrlToRealUrl( apiUrl ) {
        var realUrl = apiUrl.replace( 'api.github', 'github' );

        realUrl = realUrl.replace( '/repos/', '/' );

        return realUrl;
    }

    handleResponse( responseData, user ) {
        var message = false,
            commitText = 'commit',
            messageStart,
            commitMessage,
            i;

        if ( this.useridCache[ user ] && this.useridCache[ user ] !== responseData[ 0 ].id ) {
            responseData[0].repo.html_url = this.apiUrlToRealUrl(responseData[0].repo.url);

            switch (responseData[0].type) {
                case 'PushEvent':

                    if (responseData[0].payload.commits.length > 1) {
                        commitText = commitText + 's';
                    }

                    message = user + ' pushed ' + responseData[0].payload.commits.length + ' ' + commitText + ' to ' + responseData[0].repo.html_url;
                    for (i = 0; i < responseData[0].payload.commits.length; i = i + 1) {
                        messageStart = '    ';
                        if (i === responseData[0].payload.commits.length - 1) {
                            messageStart = messageStart + this.characters.lastMessage + '   ';
                        } else {
                            messageStart = messageStart + this.characters.message + '   ';
                        }

                        commitMessage = responseData[0].payload.commits[i].message.replace(/(\r\n|\n\r|\n\n|\r\r|\r|\n)/gm, this.rightPad('\n', messageStart.length + 1, ' '));

                        message = message + '\n' + messageStart + commitMessage;
                    }
                    break;
                case 'CreateEvent':
                    switch (responseData[0].payload.ref_type) {
                        case 'repository':
                            message = user + ' created repository ' + responseData[0].repo.html_url;
                            break;
                        case 'branch':
                            message = user + ' created a branch for ' + responseData[0].repo.name + ' called ' + responseData[0].payload.ref;
                            break;
                        case 'tag':
                            message = user + ' created a tag for ' + responseData[0].repo.name + ' called ' + responseData[0].payload.ref;
                            break;
                        default:
                            break;
                    }
                    break;
                case 'PullRequestEvent':
                    switch (responseData[0].payload.action) {
                        case 'opened':
                            message = user + ' created a pull request for ' + responseData[0].repo.name + ' titled "' + responseData[0].payload.pull_request.title + '" (' + responseData[0].payload.pull_request.html_url + ')';
                            break;
                        default:
                            break;
                    }
                    break;
                case 'IssuesEvent':
                    switch (responseData[0].payload.action) {
                        case 'opened':
                            message = user + ' created an issue for ' + responseData[0].repo.name + ' titled "' + responseData[0].payload.issue.title + '" (' + responseData[0].issue.html_url + ')';
                            break;
                        default:
                            break;
                    }
                    break;
                case 'ForkEvent':
                    message = user + ' forked repository ' + responseData[0].payload.forkee.name + ' from ' + responseData[0].repo.name;
{'fraction_non_alphanumeric': 0.11960025789813024, 'fraction_numerical': 0.007736943907156673, 'mean_word_length': 1.2524201355275895, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6913899', 'n_tokens_mistral': 2436, 'n_tokens_neox': 2272, 'n_words': 466}