slack-ruby / slack-ruby-bot

The easiest way to write a Slack bot in Ruby.
MIT License
1.12k stars 187 forks source link

Replace no-break spaces with regular spaces during command match process #255

Closed ghost closed 4 years ago

ghost commented 4 years ago

I originally filled out an issue for this on the client library here https://github.com/slack-ruby/slack-ruby-client/issues/319 but how to fix it was more apparent to me in the bot gem. I also mainly use the slack-ruby-bot gem for my bot, so I'm not as familiar with what cases the issue might come up with on the main library.

dblock commented 4 years ago

This works, but I worry that we are actually replacing characters and someone will one day want to distinguish those and we would have made a 1-way-door decision. I already had anxiety over the .strip ;)

Can you try changing the regex(es) to use [[:space:]], I believe that includes the non-breaking space?

ghost commented 4 years ago

This works, but I worry that we are actually replacing characters and someone will one day want to distinguish those and we would have made a 1-way-door decision. I already had anxiety over the .strip ;)

Can you try changing the regex(es) to use [[:space:]], I believe that includes the non-breaking space?

Using that version also replaces linefeed and carriage returns so it breaks the SlackRubyBot::Commands allows multiline expression test

ghost commented 4 years ago

Do you think it would be overkill to add an option to the config to turn this replacement on/off? That would at least give the user a choice

dblock commented 4 years ago

I am not seeing what you're seeing in https://github.com/slack-ruby/slack-ruby-bot/pull/256. Did I miss something?

ghost commented 4 years ago

I am not seeing what you're seeing in #256. Did I miss something?

Hmm maybe I did something wrong the first time, your version works though, I just tested your PR with my bot and it also works!

ghost commented 4 years ago

Closing in favour of https://github.com/slack-ruby/slack-ruby-bot/pull/256