From 3219bb0d67b5abdd0e3620d813da46ca86e59193 Mon Sep 17 00:00:00 2001 From: Joshix Date: Fri, 15 Oct 2021 21:00:47 +0200 Subject: [PATCH] don't put url in dict and improve code --- discover_overlay/text_overlay.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/discover_overlay/text_overlay.py b/discover_overlay/text_overlay.py index 3c7254f..fa0a9a8 100644 --- a/discover_overlay/text_overlay.py +++ b/discover_overlay/text_overlay.py @@ -127,10 +127,9 @@ class TextOverlayWindow(OverlayWindow): ret = message['surrogate'] else: ### Add Image ### - url = ("https://cdn.discordapp.com/emojis/%s.png?v=1" % - (message['emojiId'])) - img = {"url": url} - self.image_list.append(img) + self.image_list.append( + f"https://cdn.discordapp.com/emojis/{message['emojiId']}.png?v=1" + ) ret = "`" elif (message['type'] == 'inlineCode' or message['type'] == 'codeBlock' or @@ -296,13 +295,12 @@ class TextOverlayWindow(OverlayWindow): """ Draw an inline image as a custom emoticon """ + # print(shape.data, self.image_list, self.attachment) if shape.data >= len(self.image_list): logging.warning(f"{shape.data} >= {len(self.image_list)}") return - if 'url' not in self.image_list[shape.data]: - logging.warning(f"'url' not in {self.image_list[shape.data]}") - return - key = self.image_list[shape.data]['url'] + # key is the url to the image + key = self.image_list[shape.data] if key not in self.attachment: get_surface(self.recv_attach, key,