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

Fix mention extraction when parsing message for non-breaking space characters sent by Slack #32

Merged
merged 2 commits into from
Apr 13, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion omnibot/services/slack/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from omnibot.services import slack
from omnibot.services import stats

SPACE_REGEX = re.compile(r'[\s\u00A0]')


def extract_users(text, bot):
statsd = stats.get_statsd_client()
Expand Down Expand Up @@ -178,7 +180,7 @@ def extract_mentions(text, bot, channel):
with statsd.timer('parser.extract_mentions'):
to_me = False
at_me = '@{}'.format(bot.name)
if text.split(' ')[0] == at_me:
if SPACE_REGEX.split(text)[0] == at_me:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any unit tests can be added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

to_me = True
directed = channel.get('is_im') or to_me
return directed
Expand Down