-
Notifications
You must be signed in to change notification settings - Fork 395
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
Regex group support #130
base: develop
Are you sure you want to change the base?
Regex group support #130
Changes from 5 commits
9ce9b45
b86d92e
a39c891
0f5fe91
9303d07
72ff387
2581de8
9538730
aed6522
70692dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,8 +67,14 @@ def get_plugins(self, category, text): | |
for matcher in self.commands[category]: | ||
m = matcher.search(text) | ||
if m: | ||
kwargs = m.groupdict() | ||
args = tuple( | ||
m.group(i) | ||
for i in range(1, m.lastindex + 1) | ||
if i not in matcher.groupindex.values() | ||
) | ||
has_matching_plugin = True | ||
yield self.commands[category][matcher], to_utf8(m.groups()) | ||
yield self.commands[category][matcher], to_utf8(args), to_utf8(kwargs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
if not has_matching_plugin: | ||
yield None, None | ||
yield None, None, None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The FakeFakePluginManager also need to be updated to return a 3-tuple. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from slackbot.bot import respond_to | ||
|
||
|
||
@respond_to('Hello, (?P<name>.+)') | ||
def say_hello(message, name): | ||
message.reply('Hello! {}'.format(name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe sth. like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also worth moving this to helper function in utils.py, e.g.