Skip to content

Instantly share code, notes, and snippets.

@aoberoi
Created November 27, 2017 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aoberoi/ca6d7322174b061877793bed2d182434 to your computer and use it in GitHub Desktop.
Save aoberoi/ca6d7322174b061877793bed2d182434 to your computer and use it in GitHub Desktop.
python slackclient debugging
import os
from slackclient import SlackClient
import requests
import logging
try:
import http.client as http_client
except ImportError:
# Python 2
import httplib as http_client
http_client.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
# from https://www.fullstackpython.com/blog/build-first-slack-bot-python.html
BOT_NAME = 'starterbot'
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment