<commit_before>'use strict';

/**
 * Discord Bot
 * Connects Github with Discord Server and relays messages.
 */
const Config = require('./config.json');
const RestifyServer = require('restify');
const IPAddr = require('ipaddr.js');
const Async = require('async');
const DiscordClient = require('discord.io');
const GithubModule = require('./github.js');
const Log = require('./logger.js');

const Restify = RestifyServer.createServer({
    name: 'Discord Bot',
});

let Bot;
let Github;
let LastConnect = new Date();

Bot = new DiscordClient({
    email: Config.email,
    password: Config.password,
    autorun: true,
});

Bot.on('ready', function botReady() {
    Log.info('Bot is now ready for action (id: ' + Bot.id + ')!');
    Github = new GithubModule(Bot, Config.channel);
});

Bot.on('disconnected', function botDisconnected() {
    Log.fatal('It seems the bot has disconnected from Discord...');

    if (Math.floor(new Date().getTime() / 1000) - LastConnect < 60) {
        Log.fatal('Unable to reconnect bot due to throttling. Bot has disconnected twice in 60 seconds.');
        return;
    }

    Bot.connect();
    LastConnect = new Date();
});

Restify.use(RestifyServer.bodyParser());<commit_msg>try reconnecting every 2 minutes if disconnected<commit_after>'use strict';

/**
 * Discord Bot
 * Connects Github with Discord Server and relays messages.
 */
const Config = require('./config.json');
const RestifyServer = require('restify');
const IPAddr = require('ipaddr.js');
const Async = require('async');
const DiscordClient = require('discord.io');
const GithubModule = require('./github.js');
const Log = require('./logger.js');

const Restify = RestifyServer.createServer({
    name: 'Discord Bot',
});

let Bot;
let Github;
let LastConnect = new Date();

Bot = new DiscordClient({
    email: Config.email,
    password: Config.password,
    autorun: true,
});

Bot.on('ready', function botReady() {
    Log.info('Bot is now ready for action (id: ' + Bot.id + ')!');
    Github = new GithubModule(Bot, Config.channel);
});

Bot.on('disconnected', function botDisconnected() {
    Log.fatal('It seems the bot has disconnected from Discord...');

    if (Math.floor(new Date().getTime() / 1000) - LastConnect < 60) {
        Log.fatal('Unable to reconnect bot due to throttling. Bot has disconnected twice in 60 seconds. Retrying again in 2 minutes.');
        setTimeout(function () {
            Bot.connect();
            LastConnect = new Date();
        }, 120000);
    } else {
        Bot.connect();
        LastConnect = new Date();
    }
});

Restify.use(RestifyServer.bodyParser());
{'fraction_non_alphanumeric': 0.1514919663351186, 'fraction_numerical': 0.009181331293037491, 'mean_word_length': 3.661319073083779, 'pattern_counts': {'":': 0, '<': 5, '<?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': '150356', 'n_tokens_mistral': 801, 'n_tokens_neox': 769, 'n_words': 232}