From 04fcbbe0c7c50bdf8585280b86427661bbf26035 Mon Sep 17 00:00:00 2001 From: Nanyi Jiang Date: Mon, 18 Apr 2016 22:43:45 -0700 Subject: [PATCH] React :triggergif: when message contains 'PTSD' or 'trigger(ed)' --- plugins/lmao.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/lmao.py b/plugins/lmao.py index 44a9842..88badfb 100644 --- a/plugins/lmao.py +++ b/plugins/lmao.py @@ -8,14 +8,23 @@ class AyyLmao(GladosPluginBase): consumes_message = True + REGEX_TO_REACTION = { + r'\bay+(\b|lmao)': 'ayylmao', + r'\btrigger(\b|ed)|\bPTSD': 'triggergif', + } + def can_handle_message(self, msg): if msg['type'] != 'message' or 'message' in msg: return None - return re.search(r'\bay+(\b|lmao)', - msg['text'], flags=re.I) is not None + for regex in self.REGEX_TO_REACTION: + if re.search(regex, msg['text'], flags=re.I) is not None: + return True + return False def handle_message(self, msg): - self.react_to_message(msg, 'ayylmao') + for regex, reaction in self.REGEX_TO_REACTION.items(): + if re.search(regex, msg['text'], flags=re.I) is not None: + self.react_to_message(msg, reaction) @property def help_text(self):