const commands = require('./commands') const api = require('../api-action') /** * parse text message object * @param {object} evt line message event object */ const textMessage = async (evt) => { let {replyToken, source, message} = evt 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) { await api.line.replyMessage(replyToken, result.reply) } } module.exports = { textMessage }