From 0363f63029f164811f6ea72d214c8495973d8dd5 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 657e7140..fc686c9e 100644 --- a/config.py +++ b/config.py @@ -87,6 +87,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..0eac8582 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