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

Commit

Permalink
Merge pull request #4 from Exzender/master
Browse files Browse the repository at this point in the history
fix channel post command parse
  • Loading branch information
Samuel Kaiser authored Feb 10, 2021
2 parents da799b3 + e75b528 commit e367e66
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 e367e66

Please sign in to comment.