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
while self.getConnected():
try:
self.reactor.process_once(timeout=5)
try:
with self.threadLock:
@ -362,6 +363,10 @@ class IrcThread(threading.Thread):
self.connection.privmsg_many(self.channels, msg)
except Queue.Empty:
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:
logging.exception("Exception in IRC thread")
time.sleep(self.reconnectDelay)