diff --git a/slack/chat.py b/slack/chat.py index a9d5d2c..26cb528 100644 --- a/slack/chat.py +++ b/slack/chat.py @@ -25,7 +25,7 @@ class Message: self.__ts = json["ts"] self.__time = datetime.fromtimestamp(float(self.__ts)) self.__user = users.info(json.get("user", None)) - self.__text = [ json["text"].encode("utf-8").decode("latin-1") ] + self.__text = [ json["text"].encode("utf-8").decode(errors="replace")] def __lt__(self, other): return self.__time < other.__time diff --git a/slack/threads.py b/slack/threads.py index eb902ca..77aa1c4 100644 --- a/slack/threads.py +++ b/slack/threads.py @@ -16,8 +16,8 @@ class Thread: def __init__(self, json): self.__id = json.get("id", 0) self.__name = json.get("name", "").title() - self.__topic = json["topic"].get("value", "").encode("utf-8").decode("latin-1") - self.__purpose = json["purpose"].get("value", "").encode("utf-8").decode("latin-1") + self.__topic = json["topic"].get("value", "").encode("utf-8").decode(errors="replace") + self.__purpose = json["purpose"].get("value", "").encode("utf-8").decode(errors="replace") self.__unread = json.get("unread_count", None) self.__last_ts = json.get("last_read", None) @@ -49,7 +49,8 @@ class Thread: # Read original message list o_list = [] for message in self.do_fetch_messages(self.__last_ts): - o_list += [ chat.Message(message) ] + if message["text"] != None: + o_list += [ chat.Message(message) ] o_list.sort() # Merge together messages from the same user