如何检查拼写错误,语法和标点错误,问候语和简短关键字的使用以及总时间,以在socket.io Express猫鼬聊天应用程序中完成每个单独的聊天会话?
这是我的代码,我使用拼写检查器成功,但是无法检查我提到的其余内容,
//语法检查给用户的消息 gingerbread(data.message,{/ **选项以覆盖** /},功能(错误,文本,结果){ 如果(!err){ var grammar_result = { 文字:文字, 结果:结果 }
// Insert message in Databae
chats.find({
'uid': data.uid,
'aid': data.aid
}).exec(function (err, userChat) {
if (userChat.length <= 0) {
// first time user chat this condition call
var messages_body = {
message: data.message,
message_details: data.message_detail,
grammar: grammar_result,
type: data.type
};
var chatsData = new chats();
chatsData.uid = data.uid;
chatsData.aid = data.aid;
chatsData.cid = data.cid;
chatsData.messages = messages_body;
chatsData.save(function (err, saveData) {
// call function : chatBot
botMessage();
});
} else {
// already user is chat this condition call
if (userChat[0]) {
var messages_body = {
message: data.message,
message_details: data.message_detail,
grammar: grammar_result,
type: data.type
};
var fieldsToSet = {
$push: {
messages: messages_body
}
};
var options = {
new: true
};
chats.findByIdAndUpdate(userChat[0]._id, fieldsToSet, options, function (err, data) {
// call function : chatBot
botMessage();
});
}
}
});
}
});