🏡 index : ~doyle/dave.git

author Jordan Doyle <jordan@doyle.wf> 2017-07-30 20:13:57.0 +01:00:00
committer Jordan Doyle <jordan@doyle.wf> 2017-07-30 20:13:57.0 +01:00:00
commit
cb1a9c8ede110276b9604974aca064e624745e64 [patch]
tree
882f9f04febdbe4bed8ce6f0bead1c46bc46ca36
parent
6aada2e83b13315416d7f40d4fefd7fd74799a93
download
cb1a9c8ede110276b9604974aca064e624745e64.tar.gz

Ignore UTF-8 decoding errors



Diff

 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(