Created
November 3, 2016 05:15
-
-
Save somma/a76f1ad74e37941bae98125ddced0878 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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