SHARE
TWEET

Untitled

a guest Jan 21st, 2019 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def start_bot(redis_object):
  2.     print('In start bot')
  3.     slack_client = SlackClient('xoxb-xxxx')
  4.     bot_id = None
  5.     PING_DELAY = 1 #1 sec
  6.     response = ''
  7.     if slack_client.rtm_connect(with_team_state=False):
  8.         print("Starter Bot connected and running!")
  9.         bot_id = slack_client.api_call("auth.test")["user_id"]
  10.         while True:
  11.             rtm_response = slack_client.rtm_read()
  12.             #print(rtm_response)
  13.             command, channel = parse_bot_commands(rtm_response,bot_id)
  14.             if command:
  15.                 print("Channel",channel)
  16.                 response = handle_command(command, channel,redis_object)
  17.                 print(str(1),'########',response)
  18.                 requests.get('https://slack.com/api/chat.postMessage',
  19.                     headers={'Authorization': 'Basic xxxx'},
  20.                     params = {'text': response, 'channel': channel})
  21.             time.sleep(PING_DELAY)
  22.     else:
  23.         print("Connection failed.")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top