<commit_before>
import { Server } from "../server";
import { RethinkDB } from "../rethinkdb";

// Sidenote: Interval is in MS
interface IRepeats {
    [token: string]: {
        [command: string]: {
            command: string;
            interval: number;
            intervalVar: number;
        }[];
    };
};

export class Repeat {
    private activeRepeats: IRepeats = {};

    constructor(public server: Server, public rethink: RethinkDB) { }

    addRepeat(packet: Object): boolean {
        let repeat: any = packet;
        
        if (!repeat.token || !repeat.commandName || !repeat.period) {
            return false;
        }

        if (this.activeRepeats[repeat.token] === (null || undefined)) {
            this.activeRepeats[repeat.token] = {};
        }

        if (this.activeRepeats[repeat.token][repeat.command] === (null || undefined)) {
            this.activeRepeats[repeat.token][repeat.command] = [{ command: repeat.command, interval: repeat.period * 1000, intervalVar: this.startRepeat(repeat) }];
        } else {
            this.activeRepeats[repeat.token][repeat.command].push({ command: repeat.command, interval: repeat.period * 1000, intervalVar: this.startRepeat(repeat) });
        }

        return true;
    }

    removeRepeat(packet: Object): boolean {
        let data: any = packet;

        console.log(data);<commit_msg>Fix timeout time<commit_after>
import { Server } from "../server";
import { RethinkDB } from "../rethinkdb";

// Sidenote: Interval is in MS
interface IRepeats {
    [token: string]: {
        [command: string]: {
            command: string;
            interval: number;
            intervalVar: number;
        }[];
    };
};

export class Repeat {
    private activeRepeats: IRepeats = {};

    constructor(public server: Server, public rethink: RethinkDB) { }

    addRepeat(packet: Object): boolean {
        let repeat: any = packet;
        
        if (!repeat.token || !repeat.commandName || !repeat.period) {
            return false;
        }

        if (this.activeRepeats[repeat.token] === (null || undefined)) {
            this.activeRepeats[repeat.token] = {};
        }

        repeat.period = repeat.period * 1000

        if (this.activeRepeats[repeat.token][repeat.command] === (null || undefined)) {
            this.activeRepeats[repeat.token][repeat.command] = [{ command: repeat.command, interval: repeat.period, intervalVar: this.startRepeat(repeat) }];
        } else {
            this.activeRepeats[repeat.token][repeat.command].push({ command: repeat.command, interval: repeat.period, intervalVar: this.startRepeat(repeat) });
        }

        return true;
    }

    removeRepeat(packet: Object): boolean {
        let data: any = packet;

        console.log(data);
{'fraction_non_alphanumeric': 0.13651137594799567, 'fraction_numerical': 0.004333694474539545, 'mean_word_length': 2.440993788819876, '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': '2715452', 'n_tokens_mistral': 813, 'n_tokens_neox': 781, 'n_words': 176}