forked from capitalone/slackbot-destroyer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathid.py
25 lines (21 loc) · 792 Bytes
/
id.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from constants import SLACK_BOT_TOKEN
from slackclient import SlackClient
# This should be replaced with the name of the bot user.
BOT_NAME = str(os.environ.get('BOT_NAME'))
slack_client = SlackClient(SLACK_BOT_TOKEN)
if __name__ == "__main__":
api_call = slack_client.api_call("users.list")
if api_call.get('ok'):
users = api_call.get('members')
for user in users:
if 'name' in user and user.get('name') == BOT_NAME:
print(
"The BOT_ID token for " +
user['name'] +
"' is " +
user.get('id'))
else:
print("Unable to find a user with the name " + BOT_NAME + ' or you are mising a Slack token.')