We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6a67aa8 commit 6197c3dCopy full SHA for 6197c3d
1 file changed
doc/examples/example.py
@@ -0,0 +1,25 @@
1
+#!/usr/bin/env python
2
+# -*- coding: utf-8 -*-
3
+import random
4
+from slackclient import SlackClient
5
+import time
6
+
7
+#get your personal token from https://api.slack.com/web, bottom of the page.
8
+api_key = ''
9
+client = SlackClient(api_key)
10
11
+if client.rtm_connect():
12
+ while True:
13
+ last_read = client.rtm_read()
14
+ if last_read:
15
+ try:
16
+ parsed = last_read[0]['text']
17
+ #reply to channel message was found in.
18
+ message_channel = last_read[0]['channel']
19
+ if parsed and 'food:' in parsed:
20
+ choice = random.choice(['hamburger', 'pizza'])
21
+ client.rtm_send_message(message_channel,
22
+ 'Today you\'ll eat %s.' % choice)
23
+ except:
24
+ pass
25
+ time.sleep(1)
0 commit comments