buffer: Handle bad events better.

This commit is contained in:
Damir Jelić 2019-03-13 15:25:22 +01:00
parent 1b54b67154
commit c02fa75d4f

View file

@ -19,6 +19,7 @@ from __future__ import unicode_literals
import time import time
import attr import attr
import pprint
from builtins import super from builtins import super
from functools import partial from functools import partial
from collections import deque from collections import deque
@ -47,6 +48,8 @@ from nio import (
OlmTrustError, OlmTrustError,
UnknownEvent, UnknownEvent,
FullyReadEvent, FullyReadEvent,
BadEvent,
UnknownBadEvent,
) )
from . import globals as G from . import globals as G
@ -1443,6 +1446,21 @@ class RoomBuffer(object):
elif isinstance(event, UnknownEvent): elif isinstance(event, UnknownEvent):
pass 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: else:
W.prnt( W.prnt(
"", "Unhandled event of type {}.".format(type(event).__name__) "", "Unhandled event of type {}.".format(type(event).__name__)