Fix mention extraction when parsing message for non-breaking space characters sent by Slack #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a user copy-and-pastes a command into Slack and hits enter, for some reason Slack sends the event payload with non-breaking space characters (unicode
\u00A0
), which causes omnibot to not detect adirected
bot user in these cases and hence will not forward the even payload to the corresponding downstream bot.e.g. raw text payloads:
{"text": "@bot-name command"}
-> omnibot knows this text payload is targeting a bot with the namebot-name
{"text": "@bot-name\u00A0command"}
-> omnibot does not know this text payload is targeting a bot because the original logic for settingdirected = True
is whentext.split(' ')[0] == bot name
, which in this case there is no' '
char to split by because Slack sent us a non-breaking space character instead.This change allows for any whitespace character to be between the @bot-mention and the start of the command for forwarding the payload downstream.
NOTE that Slack has acknowledged this issue as a bug but is unsure when this will be fixed by them upstream.