diff options
| author | jantuomi <jans.tuomi@gmail.com> | 2016-07-18 12:40:45 +0300 |
|---|---|---|
| committer | jantuomi <jans.tuomi@gmail.com> | 2016-07-18 12:40:45 +0300 |
| commit | 1aac753ba2e95276af63bbaaedae9c2e89cb91c2 (patch) | |
| tree | f2b71ebffd789f157df9f429e08ba7474f2d14a0 /shoutboxapicommunicator.py | |
| parent | aa526d6d1b34113c2fdc6a97d6f46bc41b08713b (diff) | |
Create JSON Factory, http test server now dumps incoming telegram messages
Diffstat (limited to 'shoutboxapicommunicator.py')
| -rw-r--r-- | shoutboxapicommunicator.py | 10 |
1 files changed, 6 insertions, 4 deletions
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 |
