const commands = require('./commands') const DB = require('@libs/database') const api = require('@libs/api-action') /** * parse text message object * @param {object} evt line message event object */ const textMessage = async (evt) => { let {replyToken, source, message, type} = evt if (type === 'leave' && 'groupId' in source && 'type' in source && source.type === 'group') { await leaveGroup(source.groupId) return } if (!source || !('type' in source) || source.type !== 'group') return if (!message || message.type !== 'text') return let {text} = message if (typeof text !== 'string') return text = text.trim() if (text.length === 0) return let result = await commands(text, source) if (result === null) return if (typeof result === 'object' && 'reply' in result) { console.log('reply message :::: ', result.reply) await api.line.replyMessage(replyToken, result.reply) } } const leaveGroup = async (group = '') => { } module.exports = { textMessage }