<commit_before>const line = require('@line/bot-sdk');
const apiai = require("apiai");


class Maia extends line.Client {

    constructor(config) {
        super(config);
        this.handleEvent = this.handleEvent.bind(this);
    }

    middleware() {
        return (req, res, next) => {
            Promise
                .all(req.body.events.map(this.handleEvent))
                .then((result) => res.json(result));
        };
    }

    handleEvent(event) {
        var mention = /^(@|!)?bot(:|,)? /i;

        if (event.type !== 'message' || event.message.type !== 'text' || (event.source.type === "group" && !event.message.text.match(mention))) {
            // ignore non-text-message event
            return Promise.resolve(null);
        }

        var message = event.message.text.replace(mention, "");
        var userId = event.source.userId;
        var groupId = event.source.groupId;
        var session = {
            name: 'session',
            parameters: {
                'userid': userId,
                'groupid': groupId,
                'agent': "line"
            }
        };

        var agent = apiai(process.env.APIAI_KEY);
        var data = {
            sessionId: userId,
            contexts: [session]
        };
        if (!session.parameters.groupid)<commit_msg>change mention to mia<commit_after>const line = require('@line/bot-sdk');
const apiai = require("apiai");


class Maia extends line.Client {

    constructor(config) {
        super(config);
        this.handleEvent = this.handleEvent.bind(this);
    }

    middleware() {
        return (req, res, next) => {
            Promise
                .all(req.body.events.map(this.handleEvent))
                .then((result) => res.json(result));
        };
    }

    handleEvent(event) {
        var mention = /^(@|!)?mia(:|,)? /i;

        if (event.type !== 'message' || event.message.type !== 'text' || (event.source.type === "group" && !event.message.text.match(mention))) {
            // ignore non-text-message event
            return Promise.resolve(null);
        }

        var message = event.message.text.replace(mention, "");
        var userId = event.source.userId;
        var groupId = event.source.groupId;
        var session = {
            name: 'session',
            parameters: {
                'userid': userId,
                'groupid': groupId,
                'agent': "line"
            }
        };

        var agent = apiai(process.env.APIAI_KEY);
        var data = {
            sessionId: userId,
            contexts: [session]
        };
        if (!session.parameters.groupid)
{'fraction_non_alphanumeric': 0.1486280487804878, 'fraction_numerical': 0.0, 'mean_word_length': 1.734375, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3357451', 'n_tokens_mistral': 772, 'n_tokens_neox': 755, 'n_words': 146}