Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

remove @direct_mention from middleware receive message text #175

Closed
simpixelated opened this issue Apr 10, 2016 · 3 comments
Closed

remove @direct_mention from middleware receive message text #175

simpixelated opened this issue Apr 10, 2016 · 3 comments

Comments

@simpixelated
Copy link

Is there a built-in way to strip the user (<@userid>) from the message.text that is passed to the middleware receive function? Currently it comes baked into the string, so I'd have to manually parse it out in the middleware with regex.

Crosspost from the botkit-middelware-witai: howdyai/botkit-middleware-witai#2

The message.text value passed to the middleware.receive function contains the username mentioned, which means it gets set to wit.ai. For example, a "direct_mention" shows up in wit.ai as:
@U0ZA78R19 testing pt 2. This may be an issue with how https://github.com/howdyai/botkit works, but is there any way to strip out the user prior to passing it to wit.captureTextIntent in the case of "direct_mention" and "direct_message"?

@airlikidh2
Copy link
Contributor

I have the same problem and just do a basic and not very elegant:

function cleanID(id) {
        var newString = id.substr(2); //remove two first char
        return newString.substring(0,9);
    }

@peterswimm
Copy link
Contributor

Closing as answered.

@simpixelated
Copy link
Author

@airlikidh2 can you give an example of how I would use your cleanID function? I'm still seeing this same problem with both the witai and apiai middlewares when used with Slack.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants