From 985ff48e2b83837e5e722f0695c1f577e8b3a0aa Mon Sep 17 00:00:00 2001 From: Vamshi99 Date: Wed, 28 Mar 2018 12:56:36 +0530 Subject: [PATCH] filters.py: Filter required users If RESP_ONLY_REQ_USERS configuration is true, then stop responding to users other than those in the REQUIRED_USERS list in config. Closes https://github.com/coala/corobo/issues/515 --- config.py | 4 ++++ utils/filters.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 7369a0fd..0449846b 100644 --- a/config.py +++ b/config.py @@ -69,6 +69,10 @@ IGNORE_USERNAMES = os.environ.get("IGNORE_USERNAMES", 'co-robo coala-bot').split() +RESP_ONLY_REQ_USERS = False + +REQUIRED_USERS = [] + DIVERT_TO_PRIVATE = ('help', ) ROOMS_TO_JOIN = ( diff --git a/utils/filters.py b/utils/filters.py index 9b3c14a7..ca5e1202 100644 --- a/utils/filters.py +++ b/utils/filters.py @@ -23,7 +23,10 @@ def filters(self, msg, cmd, args, dry_run): return msg, cmd, args @cmdfilter - def filter_ignored_users(self, msg, cmd, args, dry_run): + def filter_users(self, msg, cmd, args, dry_run): if msg.frm.nick in self.bot_config.IGNORE_USERNAMES: return None, None, None + if msg.frm.nick not in self.bot_config.REQUIRED_USERS \ + and self.bot_config.RESP_ONLY_REQ_USER: + return None, None, None return msg, cmd, args