-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strip formatting from messages? #1053
Comments
👍 |
That is a good question. It's going to depend on the adapter I think, because not every one has rich formatting. Which adapter are you using? I'd guess Slack. |
Receive middleware can solve this elegantly. It can edit the message before listeners attempt to match it. Here's an example that would let module.exports = (robot) ->
robot.receiveMiddleware (context, next, done) ->
context.response.message.text = context.response.message.text.replace("pnig", "ping")
next() Hubot> /pnig
Hubot> PONG If you can write a function to strip the formatting, you could replace the message text with the stripped message in a similar way. |
Yeah, we're using Slack. A middleware would work. Not sure I can think of any cases where I would want |
Slack already has a place it strips formatting for links. That'd be a good place to do it for other things: https://github.com/slackhq/hubot-slack/blob/master/src/slack.coffee#L153-L192 I think it is going to be up to the adapters to strip formatting like this. They probably should preserve the raw message in case an adapter-specific script wants to do something about, like hubot-slack does here: https://github.com/slackhq/hubot-slack/blob/master/src/slack.coffee#L112-L120 |
This is adapter specific, so I filed slackapi/hubot-slack#241 to track Slack doing something special with formatting. |
Closing since this is being tracked in slackapi/hubot-slack#241 |
We have a script which starts like this:
However, it doesn't hear it if the words are formatted at all, e.g. "some sentence here".
Would it be possible / desired to remove formatting from messages before parsing them?
The text was updated successfully, but these errors were encountered: