add key word command not fin
This commit is contained in:
+34
-12
@@ -36,6 +36,14 @@ const pushMessage = async (target, message = '') => {
|
||||
await client(opts)
|
||||
}
|
||||
|
||||
const textObject = (txt = '') => {
|
||||
if (typeof txt !== 'string' || txt.trim().length === 0) return null
|
||||
return {
|
||||
type: 'text',
|
||||
text: txt
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* send reply message
|
||||
* @param {string} replyToken line message reply token
|
||||
@@ -43,21 +51,35 @@ const pushMessage = async (target, message = '') => {
|
||||
*/
|
||||
const replyMessage = async (replyToken, message) => {
|
||||
let url = '/message/reply'
|
||||
let opts = {
|
||||
method: 'post',
|
||||
url,
|
||||
data: {
|
||||
replyToken,
|
||||
messages: [
|
||||
{
|
||||
type: 'text',
|
||||
text: message
|
||||
}
|
||||
]
|
||||
|
||||
let regex = /^\$(.+?)\$/
|
||||
let m = message.match(regex)
|
||||
let obj = null
|
||||
message = message.replace(/^\$.+?\$/, '')
|
||||
if (m !== null && m.length > 1) {
|
||||
switch (m[1]) {
|
||||
case 'image':
|
||||
break
|
||||
case 'text':
|
||||
obj = textObject(message)
|
||||
break
|
||||
default:
|
||||
obj = textObject(message)
|
||||
}
|
||||
}
|
||||
|
||||
await client(opts)
|
||||
if (obj !== null) {
|
||||
let opts = {
|
||||
method: 'post',
|
||||
url,
|
||||
data: {
|
||||
replyToken,
|
||||
messages: [obj]
|
||||
}
|
||||
}
|
||||
|
||||
await client(opts)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user