Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def start_bot(redis_object):
- print('In start bot')
- slack_client = SlackClient('xoxb-xxxx')
- bot_id = None
- PING_DELAY = 1 #1 sec
- response = ''
- if slack_client.rtm_connect(with_team_state=False):
- print("Starter Bot connected and running!")
- bot_id = slack_client.api_call("auth.test")["user_id"]
- while True:
- rtm_response = slack_client.rtm_read()
- #print(rtm_response)
- command, channel = parse_bot_commands(rtm_response,bot_id)
- if command:
- print("Channel",channel)
- response = handle_command(command, channel,redis_object)
- print(str(1),'########',response)
- requests.get('https://slack.com/api/chat.postMessage',
- headers={'Authorization': 'Basic xxxx'},
- params = {'text': response, 'channel': channel})
- time.sleep(PING_DELAY)
- else:
- print("Connection failed.")
Add Comment
Please, Sign In to add comment