aboutsummaryrefslogtreecommitdiffstats
path: root/botmanager.py
diff options
context:
space:
mode:
authorJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-07-18 00:10:13 +0300
committerJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-07-18 00:10:13 +0300
commit144542ddf58f114f0c8eaef5d2209705f493f04b (patch)
tree405082805769da34268338bda7365ddd702c633e /botmanager.py
parente1b2b62b20266cbebb266b6089215fb46d968a18 (diff)
Fix json message, general fixes
Diffstat (limited to 'botmanager.py')
-rw-r--r--botmanager.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/botmanager.py b/botmanager.py
index 32fa69f..dc91a3b 100644
--- a/botmanager.py
+++ b/botmanager.py
@@ -1,3 +1,4 @@
+import json
import random
import sys
import requests
@@ -8,7 +9,7 @@ import logging
class BotManager(object):
- shoutbox_api_url = "http://localhost:8080"
+ shoutbox_api_url = "http://localhost:8000"
telegram_chat_id = "default_id"
def __init__(self, token):
@@ -44,13 +45,17 @@ class BotManager(object):
try:
r = requests.get(self.shoutbox_api_url)
logging.info("Response from API OK.")
- logging.info("Messages:")
- logging.info(r.text)
+
except:
logging.warning("Failed to get response from API!")
traceback.print_exc(2)
return
+ content = json.loads(r.text)
+ logging.info("Messages:")
+ for msg in content:
+ logging.info("{}: {}".format(msg["user"], msg["text"]))
+
def default_action(self, chat_id):
self.bot.sendMessage(chat_id, "Radio palaa keväällä 2017!")