From cb1a9c8ede110276b9604974aca064e624745e64 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sun, 30 Jul 2017 20:13:57 +0100 Subject: [PATCH] Ignore UTF-8 decoding errors --- dave/dave.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dave/dave.py b/dave/dave.py index 0e20577..c0e5fe2 100644 --- a/dave/dave.py +++ a/dave/dave.py @@ -22,6 +22,15 @@ def __init__(self): Dave.instance = self + def lineReceived(self, line): + """Override lineReceived to ignore invalid characters so non-utf8 messages + don't crash the bot""" + if isinstance(line, bytes): + # decode bytes from transport to unicode + line = line.decode("utf-8", errors="ignore") + + super(Dave, self).lineReceived(line) + def connectionMade(self): irc.IRCClient.connectionMade(self) log.msg("Connected to server at {} with name {}".format( -- rgit 0.1.3