Skip to content
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

Match on raw text instead of formatted text on incoming messages #241

Open
technicalpickles opened this issue Oct 9, 2015 · 3 comments
Open
Labels
enhancement M-T: A feature request for new functionality good first issue

Comments

@technicalpickles
Copy link
Contributor

This was originally filed at hubotio/hubot#1053 but I believe this to be an adapter specific problem. From @callumacrae:

We have a script which starts like this:

robot.hear /some sentence here/i, (msg) ->

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?

I suggested this:

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

@DEGoodmanWilson
Copy link

This is a tough call. We could probably add this functionality enabled by an optional flag, to maintain the current behavior.

@aoberoi aoberoi added enhancement M-T: A feature request for new functionality and removed feature labels Oct 17, 2017
@aoberoi
Copy link
Contributor

aoberoi commented Oct 17, 2017

if someone would like to propose an API for optionally matching on an "unformatted" version of the message text, we are open to that. at the moment, we don't have any plans to implement this.

@aoberoi
Copy link
Contributor

aoberoi commented Mar 30, 2018

since 4.4.0, rawMessage is available on each message. so if your script listens for all messages, you can inspect that property and do your own matching against it. here's the idea in some code (i haven't actually run this):

robot.listen((message) => {
  if (message.rawText) {
    return \some sentence here\.exec(message.rawText);
  }
  return false;
}, (response) => {
  response.reply('matched raw text!');
});

@aoberoi aoberoi changed the title Strip formatting of incoming messages Match on raw text instead of formatted text on incoming messages Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality good first issue
Projects
None yet
Development

No branches or pull requests

3 participants