<commit_before>import Plugin from "./../Plugin";
import Util from "./../Util";

export default class MediaSet extends Plugin {

    static get plugin() {
        return {
            name: "MediaSet",
            description: "Media-capable set command",
            help: '/mset `trigger`',

            needs: {
                database: true
            }
        };
    }

    start() {
        if (!this.db.triggers)
            this.db.triggers = {};

        if (!this.db.pendingRequests)
            this.db.pendingRequests = {};
    }

    onText(message, reply) {
        const text = message.text;

        const triggers = this.db.triggers[message.chat.id] || {};
        for (const trigger in triggers) {
            if (text.indexOf(trigger) === -1) continue;
            const re = new RegExp("(?:\\b|^)(" + Util.escapeRegExp(trigger) + ")(?:\\b|$)", "g");
            const match = re.exec(text);
            if (!match) continue;
            const media = triggers[trigger];
<commit_msg>Use early return in MediaSet<commit_after>import Plugin from "./../Plugin";
import Util from "./../Util";

export default class MediaSet extends Plugin {

    static get plugin() {
        return {
            name: "MediaSet",
            description: "Media-capable set command",
            help: '/mset `trigger`',

            needs: {
                database: true
            }
        };
    }

    start() {
        if (!this.db.triggers)
            this.db.triggers = {};

        if (!this.db.pendingRequests)
            this.db.pendingRequests = {};
    }

    onText(message, reply) {
        const text = message.text;

        if (!this.db.triggers[message.chat.id]) return;
        const triggers = this.db.triggers[message.chat.id];

        for (const trigger in triggers) {
            if (text.indexOf(trigger) === -1) continue;
            const re = new RegExp("(?:\\b|^)(" + Util.escapeRegExp(trigger) + ")(?:\\b|$)", "g");
            const match = re.exec(text);
            if (!match) continue;
            const media = triggers[trigger];

{'fraction_non_alphanumeric': 0.14946962391513982, 'fraction_numerical': 0.0009643201542912247, 'mean_word_length': 1.7266754270696452, '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': '3793068', 'n_tokens_mistral': 596, 'n_tokens_neox': 574, 'n_words': 147}