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

fix channel post command parse #4

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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