-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated main.py to add an exclude array for users #1
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
from requests import post | ||
from slackclient import SlackClient | ||
|
||
EXCLUDE_USERS = [ | ||
'UC2PXG134' | ||
] | ||
|
||
HITS = [ | ||
'guyz', | ||
|
@@ -45,6 +48,8 @@ def process_message_event(client, event): | |
return | ||
user = event['user'] | ||
if any(hit in text.lower() for hit in HITS): | ||
if any(excludeUser.lower() in user.lower() for excludeUser in EXCLUDE_USERS): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could exit out even earlier in the function, since we don't need to check if they said something that triggers the bot's response, since it'll be faster and avoid the other work. I'd also suggest keeping the excluded users in a Python set instead of array, then we can just check |
||
return | ||
client.api_call( | ||
'chat.postEphemeral', | ||
channel=channel, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should maybe put these in some sort of configuration file, since other folks are starting to use this bot on their own workspaces and potentially Slack user IDs could collide maybe? I also think including their username in a comment is useful, in case folks ask to get added/removed.