From c02fa75d4f9b2a5b6fd69ef6f25502891be317b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 13 Mar 2019 15:25:22 +0100 Subject: [PATCH] buffer: Handle bad events better. --- matrix/buffer.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/matrix/buffer.py b/matrix/buffer.py index 988e301..7e50836 100644 --- a/matrix/buffer.py +++ b/matrix/buffer.py @@ -19,6 +19,7 @@ from __future__ import unicode_literals import time import attr +import pprint from builtins import super from functools import partial from collections import deque @@ -47,6 +48,8 @@ from nio import ( OlmTrustError, UnknownEvent, FullyReadEvent, + BadEvent, + UnknownBadEvent, ) from . import globals as G @@ -1443,6 +1446,21 @@ class RoomBuffer(object): elif isinstance(event, UnknownEvent): pass + elif isinstance(event, BadEvent): + nick = self.find_nick(event.sender) + date = server_ts_to_weechat(event.server_timestamp) + data = ("Bad event received, event type: {t}").format(t=event.type) + extra_prefix = self.warning_prefix + + self.weechat_buffer.message( + nick, data, date, self.get_event_tags(event), extra_prefix + ) + + elif isinstance(event, UnknownBadEvent): + self.error("Unkwnown bad event: {}".format( + pprint.pformat(event.event_dict) + )) + else: W.prnt( "", "Unhandled event of type {}.".format(type(event).__name__)