Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F133014
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/main.py b/main.py
index 67d46dd..99ec8f3 100644
--- a/main.py
+++ b/main.py
@@ -1,25 +1,21 @@
-#This code is very sloppy, I am aware
-#I will clean it up when I've got some more time
import sys
import time
import telepot
-TOKEN = sys.argv[1]
+#fetching our BOT_TOKEN
+BOT_TOKEN = sys.argv[1]
-def chat_handle(msg):
+def chat_handler(msg):
content_type, chat_type, chat_id = telepot.glance(msg)
if content_type == 'text':
if "hendrik" in (msg['text'].lower()):
bot.sendMessage(chat_id, 'Who the fuck is Hendrik?', reply_to_message_id=msg['message_id'])
+ print "Trigger Phrase Detected: \n Message Text: {}".format(msg['text'])
-
-bot = telepot.Bot(TOKEN)
-bot.message_loop(chat_handle)
-
-print ('Bot Running ...')
-
-# Keep the program running.
-while 1:
- time.sleep(10)
+#make our bot and feed it the token
+bot = telepot.Bot(BOT_TOKEN)
+#fetch messages and keep script looped
+bot.message_loop({'chat' :chat_handler},
+ run_forever="Bot Running...")
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jun 16, 1:10 AM (2 w, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70194
Default Alt Text
(1 KB)
Attached To
Mode
R41 JanBot
Attached
Detach File
Event Timeline