diff --git a/pnut-bridge.py b/pnut-bridge.py index 59e49ea..0506060 100644 --- a/pnut-bridge.py +++ b/pnut-bridge.py @@ -90,10 +90,13 @@ class ChannelMonitor(threading.Thread): def send_message(self, roomid, msg): url = self.matrix_api_url + '/rooms/' + roomid +'/send/m.room.message' + '/' + str(self.txId) + #logging.debug('debug: ' + msg['ts']) + #logging.debug('debug: ') + #logging.debug(msg['ts']) + # 'ts': msg['ts'] params = { 'access_token': self.matrix_api_token, - 'user_id': msg['user']['user_id'], - 'ts': msg['ts'] + 'user_id': msg['user']['user_id'] } data = { 'msgtype': 'm.text', @@ -106,6 +109,9 @@ class ChannelMonitor(threading.Thread): el = MatrixMsgEvents(eventid, roomid, msg['msgid'], msg['puser'], msg['chan']) db.session.add(el) db.session.commit() + else: + logging.debug('error: ' + str(r.status_code)) + logging.debug(r.text) def poll_channel(self, room): @@ -134,7 +140,7 @@ class ChannelMonitor(threading.Thread): text = msg.content.text + "\n" # dt = datetime.datetime.strptime(msg.created_at, "%Y-%m-%dT%H:%M:%SZ") dt = msg.created_at - ts = time.mktime(dt.timetuple()) + ts = int(time.mktime(dt.timetuple())) for lnk in msg.content.entities.links: text += "\n" @@ -193,7 +199,7 @@ if __name__ == '__main__': with open("config.yaml", "rb") as config_file: config = yaml.load(config_file) - logging.basicConfig(level=logging.INFO) + logging.basicConfig(level=logging.DEBUG) app.config.update(config)