Skip to content

Instantly share code, notes, and snippets.

@somma
Created November 3, 2016 05:15
Show Gist options
  • Save somma/a76f1ad74e37941bae98125ddced0878 to your computer and use it in GitHub Desktop.
Save somma/a76f1ad74e37941bae98125ddced0878 to your computer and use it in GitHub Desktop.
import json
from slacker import Slacker
from websocket import create_connection
slack = Slacker('xxxxxx')
# start RTM
rtm = slack.rtm.start()
url = rtm.body['url']
ws = create_connection(url)
res = ws.recv()
rep = json.loads(res)
if rep['type'] == 'hello':
print('ok. connected\n')
while True:
slack.chat.post_message('#general', 'ping...')
res = ws.recv()
print(res)
ws.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment