-
Notifications
You must be signed in to change notification settings - Fork 104
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
Bot won't match in middle of text, re.match() vs re.search() #289
Comments
Thanks for reporting this. I don't see any issue switching to |
I meant to include this in my original post, but |
...in _handle_post() and _handle_webhook()
Since this was how it worked before the 2.x re-write I am fine with reverting it to the old behavior, despite the small reduction in performance. |
I've recently updated my bot to 2.0.2 and noticed a change in behavior that broke several functions.
Given the following plugin:
If a mattermost user enters the text:
I would expect the bot to invoke both
foo()
andbar()
, but will only respond with "bar found". So I dug around. I see that mmpy_bot uses re.match(), which only matches from the beginning of a string, rather than re.search(). mmpy_bot 1.x used re.search().I'm not completely expert at regex, but preceding all my patterns with a
.*
seems hacky. Is it possible to have a mode where re.search() is used instead? Or refactor so the matching can be more easily addressed in a subclass? Or I'd be happy to make a PR to change to search() if the devs aren't opposed to that change.The text was updated successfully, but these errors were encountered: