Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from slackclient import SlackClient
- ### This is whatever name you gave your bot
- BOT_NAME = 'toggle_bot'
- ### You get this by command export export SLACK_BOT_TOKEN='your slack token pasted here'
- slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN'))
- 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement