From e75b528428dd263c0fcf4712e5d67ba805c20f56 Mon Sep 17 00:00:00 2001 From: Exzender <42044185+Exzender@users.noreply.github.com> Date: Thu, 2 Apr 2020 12:08:42 +0300 Subject: [PATCH] fix channel post command parse --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4d03c0a..4405d60 100644 --- a/index.js +++ b/index.js @@ -4,10 +4,11 @@ const regex = /^\/([^@\s]+)@?(?:(\S+)|)\s?([\s\S]+)?$/i; /* eslint no-param-reassign: ["error", { "props": false }] */ module.exports = () => mount('text', (ctx, next) => { - const parts = regex.exec(ctx.message.text.trim()); + const messageText = ctx.updateType === 'channel_post' ? ctx.channelPost.text : ctx.message.text; + const parts = regex.exec(messageText); if (!parts) return next(); const command = { - text: ctx.message.text, + text: messageText, command: parts[1], bot: parts[2], args: parts[3],