diff options
| author | Jan Tuomi <jan-sebastian.tuomi@aalto.fi> | 2016-07-20 23:08:54 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan-sebastian.tuomi@aalto.fi> | 2016-07-20 23:08:54 +0300 |
| commit | e13ae89fcbd1543bf583e7a56f82ccaef4dfa8d4 (patch) | |
| tree | 3a715c3c523d35c0b6e7001a2f41705f9d1d51d7 /project/botmanager.py | |
| parent | 2cb5a755d3d384d47e7c8c9690397f7f886a5915 (diff) | |
Fix API post functionality
Diffstat (limited to 'project/botmanager.py')
| -rw-r--r-- | project/botmanager.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/project/botmanager.py b/project/botmanager.py index 448dbb8..151e94d 100644 --- a/project/botmanager.py +++ b/project/botmanager.py @@ -27,6 +27,7 @@ class BotManager(object): If not possible, crash gracefully """ TelegramCommunicator.token = token + self.running_message_id = 1 try: logging.info("Creating bot listener with token {}...".format(token)) TelegramCommunicator.spawn_bot(token) @@ -103,13 +104,22 @@ class BotManager(object): logging.warning("Skipped sending message to shoutbox.") return - data = JSONFactory.make_object(text, user_name, date, "null") - logging.info("Created JSON packet:\n{}".format(data)) - ShoutboxCommunicator.send(data) + message = { + "user": user_name, + "text": text, + "id": self.running_message_id, + "ip": "null", + "timestamp": date + } + self.running_message_id += 1 + ShoutboxCommunicator.send(message) def handle(self, msg): """Start parsing the incoming message if it is a text message""" content_type, chat_type, chat_id = telepot.glance(msg) if content_type == 'text': + logging.info("Got text message.") self.parse_message(msg) + else: + logging.info("Got non-text message.") |
