Skip to content

Commit 498f299

Browse files
committed
Fixed RegExpFilter
1 parent c907bb3 commit 498f299

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

whatsapp_chatbot_python/filters.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ def check_event(self, notification: "Notification") -> bool:
7676

7777
class RegExpFilter(AbstractFilter):
7878
def __init__(self, pattern: str, flags: Union[RegexFlag, int] = 0):
79-
self.pattern = pattern
80-
self.flags = flags
79+
if isinstance(pattern, str):
80+
self.pattern = pattern
81+
self.flags = flags
82+
elif isinstance(pattern, tuple):
83+
if len(pattern) == 2:
84+
self.pattern, self.flags = pattern
8185

8286
def check_event(self, notification: "Notification") -> bool:
8387
text_message = notification.message_text

0 commit comments

Comments
 (0)