Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
BingKui committed Sep 1, 2018
1 parent 85dc13b commit 62ce354
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions feature/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const groupMessage = async (message, info, self) => {
if (info.isSelf) {
return;
}
console.log(info.mentionInfo);
// 如果 @ 到自己,在进行回复
if (mentioned(info.mentionInfo, self.name)) {
// 处理消息进行回复
Expand Down
4 changes: 2 additions & 2 deletions tools/contactTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ const contactGender = (contact) => {
* @param {Array<Contact>} contactList 联系人对象数组
* @returns {Array<ContactInfo>} 返回处理过的用户信息数组
*/
const contactListInfo = (contactList = []) => {
return contactList.map(async item => await contactInfo(item));
const contactListInfo = async (contactList = []) => {
return await contactList.map(async item => await contactInfo(item));
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion tools/messageTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const messageInfo = async (message) => {
type: messageType(message), // 消息类型
content: messageText(message), // 消息内容
mention, // 提及用户 list
mentionInfo: contactListInfo(mention) || [], // 提及用户信息
mentionInfo: await contactListInfo(mention) || [], // 提及用户信息
date: formatDate(message.date()), // 消息发送时间
age: message.age(), // 消息的年龄,据当前时间的秒数
};
Expand Down
23 changes: 23 additions & 0 deletions tools/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ const mentioned = (list, name) => {
return result;
}

// 判断是否是 @ 机器人
const checkAtRobot = (username, content) => {
let flag = false;
const isAt = /\@/g.test(content);
if (isAt) {
const _space = returnSpace(content);
const _username = (content.split('@')[1]).split(_space)[0];
if (username === _username) {
flag = true;
}
}
return flag;
}

/**
*
* @param {*} con
*/
const returnSpace = (con) => {
const _str = con.split('@')[1];
return _str.indexOf(' ') > -1 ? ' ' : ' ';
}

module.exports = {
formatDate,
randomNum,
Expand Down

0 comments on commit 62ce354

Please sign in to comment.