Handle badly encoded incoming messages better

This commit is contained in:
Ondrej Mikle 2023-10-03 19:45:36 +02:00
parent 30ca988239
commit b496da75c5

View file

@ -355,6 +355,7 @@ class IrcThread(threading.Thread):
# see https://github.com/jaraco/irc/issues/132 # see https://github.com/jaraco/irc/issues/132
while self.getConnected(): while self.getConnected():
try:
self.reactor.process_once(timeout=5) self.reactor.process_once(timeout=5)
try: try:
with self.threadLock: with self.threadLock:
@ -362,6 +363,10 @@ class IrcThread(threading.Thread):
self.connection.privmsg_many(self.channels, msg) self.connection.privmsg_many(self.channels, msg)
except Queue.Empty: except Queue.Empty:
pass pass
except UnicodeDecodeError:
logging.warn("Skipped incorrectly encoded message, cannot decode to UTF-8")
except UnicodeEncodeError:
logging.warn("We were sending badly encoded message? maybe via topic?")
except Exception: except Exception:
logging.exception("Exception in IRC thread") logging.exception("Exception in IRC thread")
time.sleep(self.reconnectDelay) time.sleep(self.reconnectDelay)