Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
fix channel post command parse
Browse files Browse the repository at this point in the history
  • Loading branch information
Exzender authored Apr 2, 2020
1 parent da799b3 commit e75b528
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit e75b528

Please sign in to comment.