rivescript-js icon indicating copy to clipboard operation
rivescript-js copied to clipboard

Cannot capture emails with star

Open webfrank opened this issue 8 years ago • 3 comments

Is not possible to capture emails (containing @ and dots or dash) because messages are parsed by the function stripNasties which strips everything but a-zA-Z and space.

webfrank avatar Sep 12 '17 16:09 webfrank

@webfrank You'd have to enable utf8 when instantiating Rivescript i.e new Rivescript({ utf8: true })

josephrexme avatar Sep 12 '17 16:09 josephrexme

Even so, the periods will be stripped out because of the unicodePunctuation. There's a related bug and some discussion about it at https://github.com/aichaos/rivescript-go/issues/31.

If somebody wants to come up with the regexp described there and submit a pull request to either project, it can get fixed sooner and you'll help me with all the other RiveScript versions to get this change implemented everywhere.

As a hacky workaround, you could store the user's original message via rs.setUservar before calling rs.reply[Async], and then deal with getting their email address from inside an object macro. You could recall the variable like rs.getUservar(rs.currentUser(), "rawMessage") from inside an object macro, and then parse the email out yourself.

kirsle avatar Sep 12 '17 17:09 kirsle

No they wouldn't be if you do this.

const bot = new Rivescript({ utf8: true })
bot.unicodePunctuation = new RegExp(/[~]/)

That's how I get around it. Basically tells it to only strip out ~ character which I never find myself needing

josephrexme avatar Sep 12 '17 17:09 josephrexme