Skip to content

Commit

Permalink
+ [Robot] update hear method to support flags with regex
Browse files Browse the repository at this point in the history
  • Loading branch information
lanfon72 committed Oct 2, 2019
1 parent 9f8d39c commit f11e04c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions aiohubot/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,18 @@ def listen(self, matcher, handler, **options):
"""
self.listeners.append(Listener(self, matcher, handler, **options))

def hear(self, regex, handler, **options):
def hear(self, regex, handler, *, flags=0, **options):
""" Adds a Listener that attempts to match incoming messages based on a
regular expression.
:param regex: A Regex that determines if the handler should be called.
:param handler: A (async) function is called with a Response object.
:param options: additional parameters keyed on extension name.
"""
listener = TextListener(self, re.compile(regex), handler, **options)
regex = re.compile(regex)
pattern, oflags = regex.pattern, regex.flags
regexp = re.compile(pattern, oflags | flags)
listener = TextListener(self, regexp, handler, **options)
self.listeners.append(listener)

def respond(self, regex, handler, *, flags=0, **options):
Expand Down

0 comments on commit f11e04c

Please sign in to comment.