add save line message to log

This commit is contained in:
Jay
2018-08-28 23:34:08 +08:00
parent ac446758b6
commit ad45231d8d
4 changed files with 93 additions and 2 deletions
+31 -1
View File
@@ -95,7 +95,37 @@ const replyMessage = async (replyToken, message) => {
}
}
/**
* query user info
* @param {string} group group id
* @param {string} id user id
*/
const getUserInfo = async (group = '', id = '') => {
if (typeof group !== 'string' || group.trim().length === 0) return null
if (typeof id !== 'string' || id.trim().length === 0) return null
let url = `/group/${group.trim()}/member/${id.trim()}`
try {
let result = await client({
url,
method: 'get'
})
if ('data' in result && typeof result.data === 'object') {
let {displayName, userId} = result.data
if (typeof displayName !== 'string' || displayName.length === 0) return null
if (typeof userId !== 'string' || userId.length === 0) return null
return {
displayName,
userId
}
}
} catch (err) {
console.log('get user info error :::: ', err)
}
return null
}
module.exports = {
pushMessage,
replyMessage
replyMessage,
getUserInfo
}