<commit_before>/**
 * Usage:
 * - 消息功能
 * Author:
 * - hopesfish at 163.com
 */
var ejs = require('ejs');
var conf = require('../../conf');
var UserServices = require("../../services/UserServices");

function add_parent_start(info, next) {
    if (info.session.parent) {
        //info.wait("parent message input");
        UserServices.queryParentsAsParent({schoolOpenId: info.sp, userId: info.session.parent.id})
        .then(function(parents) {
            var contacts = [], prompt;
            for (var i=0; i<parents.length; i++) {
                contacts.push(parents[i].name + ' ' + parents[i].mobile);
            }
            if (parents.length >= 2) {
                prompt = '抱歉！已达上限，无法再添加认证家长。';
            } else {
                prompt = '请点击右下角键盘后输入其他家长的手机号：';
                info.wait("add parent mobile input");
            }
            var text = [
                "现有认证家长 " + parents.length + " 名:\n",
                contacts.join("\n") + '\n',
                prompt
            ];
            return next(null, text.join("\n"));
        }, function(err) {
            return next(null, "抱歉，获取您孩子的家长列表异常！无法添加家长，请联系老师。");
        });
    } else if (info.session.teacher) {
        next(null, '抱歉！该功能尚未为教师开放。');
    } else {
        return next(null, "抱歉，您不是认证用户，不能添加家长。");
    }
};

module.exports = function(webot) {
    // 消息提示语
    webot.set('add parent start by text', {
        domain: "gateway",
        pattern: /^(添加家长|(add )?parent)/i,
        handler: add_parent_start
    });
    webot.set('add parent start by event', {<commit_msg>提示文字错误<commit_after>/**
 * Usage:
 * - 消息功能
 * Author:
 * - hopesfish at 163.com
 */
var ejs = require('ejs');
var conf = require('../../conf');
var UserServices = require("../../services/UserServices");

function add_parent_start(info, next) {
    if (info.session.parent) {
        //info.wait("parent message input");
        UserServices.queryParentsAsParent({schoolOpenId: info.sp, userId: info.session.parent.id})
        .then(function(parents) {
            var contacts = [], prompt;
            for (var i=0; i<parents.length; i++) {
                contacts.push(parents[i].name + ' ' + parents[i].mobile);
            }
            if (parents.length >= 2) {
                prompt = '抱歉！已达上限，无法再添加认证家长。';
            } else {
                prompt = '请点击左下角键盘后输入其他家长的手机号：';
                info.wait("add parent mobile input");
            }
            var text = [
                "现有认证家长 " + parents.length + " 名:\n",
                contacts.join("\n") + '\n',
                prompt
            ];
            return next(null, text.join("\n"));
        }, function(err) {
            return next(null, "抱歉，获取您孩子的家长列表异常！无法添加家长，请联系老师。");
        });
    } else if (info.session.teacher) {
        next(null, '抱歉！该功能尚未为教师开放。');
    } else {
        return next(null, "抱歉，您不是认证用户，不能添加家长。");
    }
};

module.exports = function(webot) {
    // 消息提示语
    webot.set('add parent start by text', {
        domain: "gateway",
        pattern: /^(添加家长|(add )?parent)/i,
        handler: add_parent_start
    });
    webot.set('add parent start by event', {
{'fraction_non_alphanumeric': 0.1644883646796302, 'fraction_numerical': 0.0031877590054191903, 'mean_word_length': 1.8657534246575342, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1858170', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1195, 'n_words': 190}