Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import os
  2. from slackclient import SlackClient
  3.  
  4.  
  5. ### This is whatever name you gave your bot
  6. BOT_NAME = 'toggle_bot'
  7.  
  8. ### You get this by command export export SLACK_BOT_TOKEN='your slack token pasted here'
  9.  
  10. slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN'))
  11.  
  12.  
  13. if __name__ == "__main__":
  14. api_call = slack_client.api_call("users.list")
  15. if api_call.get('ok'):
  16. # retrieve all users so we can find our bot
  17. users = api_call.get('members')
  18. for user in users:
  19. if 'name' in user and user.get('name') == BOT_NAME:
  20. print("Bot ID for '" + user['name'] + "' is " + user.get('id'))
  21. else:
  22. print("could not find bot user with the name " + BOT_NAME)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement