From 1aac753ba2e95276af63bbaaedae9c2e89cb91c2 Mon Sep 17 00:00:00 2001 From: jantuomi Date: Mon, 18 Jul 2016 12:40:45 +0300 Subject: Create JSON Factory, http test server now dumps incoming telegram messages --- shoutboxapicommunicator.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'shoutboxapicommunicator.py') diff --git a/shoutboxapicommunicator.py b/shoutboxapicommunicator.py index 57f6bc7..28a5b74 100644 --- a/shoutboxapicommunicator.py +++ b/shoutboxapicommunicator.py @@ -6,7 +6,8 @@ import logging class Communicator(object): - def fetch(self, url): + @staticmethod + def fetch(url): try: r = requests.get(url) logging.info("Response from API OK.") @@ -22,10 +23,11 @@ class Communicator(object): return content - def send(self, url, text, user): - data = {"text": text, "user": user} + @staticmethod + def send(url, data): try: requests.post(url, data) + user = json.loads(data)["user"] logging.info("Sent message from {} to shoutbox.".format(user)) except: - logging.warning("Failed to send message from {} to shoutbox API!".format(user)) \ No newline at end of file + logging.warning("Failed to send message to shoutbox API!") \ No newline at end of file -- cgit v1.3