Created
June 21, 2017 13:11
-
-
Save chrisbay/bcf30bd08dd9cdda1720305b5ca92099 to your computer and use it in GitHub Desktop.
Find a Slackbot's ID after connecting with its token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from slackclient import SlackClient | |
| BOT_NAME = 'bot_name_without_at_sign' | |
| slack_client = SlackClient('BOT_TOKEN_GOES_HERE') | |
| if __name__ == "__main__": | |
| api_call = slack_client.api_call("users.list") | |
| if api_call.get('ok'): | |
| # retrieve all users so we can find our bot | |
| users = api_call.get('members') | |
| for user in users: | |
| if 'name' in user and user.get('name') == BOT_NAME: | |
| print("Bot ID for '" + user['name'] + "' is " + user.get('id')) | |
| else: | |
| print("could not find bot user with the name " + BOT_NAME) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment