From 558b368b1ae167572d6ca9b4cc172301cfbaab08 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 5 Aug 2018 11:42:25 +0100 Subject: [PATCH] Only get "fallback-encoding" setting when we need it --- IRCServer.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/IRCServer.py b/IRCServer.py index 414dbe6f..7deff771 100644 --- a/IRCServer.py +++ b/IRCServer.py @@ -170,10 +170,6 @@ class Server(object): self.remove_user(user) self.new_users.clear() def read(self): - encoding = self.bot.database.get_server_setting(self.id, - "encoding", "utf8") - fallback_encoding = self.bot.database.get_server_setting( - self.id, "fallback-encoding", "latin-1") data = b"" try: data = self.read_buffer + self.socket.recv(4096) @@ -188,10 +184,12 @@ class Server(object): decoded_lines = [] for line in data_lines: try: - line = line.decode(encoding) + line = line.decode(self.get_setting( + "encoding", "utf8")) except: try: - line = line.decode(fallback_encoding) + line = line.decode(self.get_setting( + "fallback-encoding", "latin-1")) except: continue decoded_lines.append(line)