Skip to content

Commit

Permalink
filters.py: Filter required users
Browse files Browse the repository at this point in the history
If respond to required users only configuration
is true, then stop responding to users other
than those in the required users list in config.

Fixes coala#515
  • Loading branch information
Vamshi99 committed Mar 28, 2018
1 parent ec45229 commit 28fb3dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
10 changes: 7 additions & 3 deletions utils/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def filters(self, msg, cmd, args, dry_run):
return msg, cmd, args

@cmdfilter
def filter_ignored_users(self, msg, cmd, args, dry_run):
if msg.frm.nick in self.bot_config.IGNORE_USERNAMES:
def filter_users(self, msg, cmd, args, dry_run):
name=msg.frm.fullname if BACKEND == 'Zulip' else msg.frm.nick
if name in self.bot_config.IGNORE_USERNAMES:
return None, None, None
return msg, cmd, args
if (name not in self.bot_config.REQUIRED_USERS
and self.bot_config.RESP_ONLY_REQ_USERS):
return None, None, None
return msg, cmd, args

0 comments on commit 28fb3dc

Please sign in to comment.