Skip to content

Commit 0c3b7c5

Browse files
committed
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 #515
1 parent 583785c commit 0c3b7c5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@
6969
IGNORE_USERNAMES = os.environ.get("IGNORE_USERNAMES",
7070
'co-robo coala-bot').split()
7171

72+
RESP_ONLY_REQ_USERS = False
73+
74+
REQUIRED_USERS = []
75+
7276
DIVERT_TO_PRIVATE = ('help', )
7377

7478
ROOMS_TO_JOIN = (

utils/filters.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ def filters(self, msg, cmd, args, dry_run):
2323
return msg, cmd, args
2424

2525
@cmdfilter
26-
def filter_ignored_users(self, msg, cmd, args, dry_run):
27-
if msg.frm.nick in self.bot_config.IGNORE_USERNAMES:
26+
def filter_users(self, msg, cmd, args, dry_run):
27+
name = msg.frm.fullname if BACKEND == 'Zulip' else msg.frm.nick
28+
if name in self.bot_config.IGNORE_USERNAMES:
29+
return None, None, None
30+
if (name not in self.bot_config.REQUIRED_USERS
31+
and self.bot_config.RESP_ONLY_REQ_USERS):
2832
return None, None, None
2933
return msg, cmd, args

0 commit comments

Comments
 (0)