decode special characters in jokes

This commit is contained in:
Justin 2023-07-17 20:00:46 +08:00 committed by GitHub
parent ecbc4b2673
commit 11e5970955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6127,11 +6127,17 @@ class StockTicker():
else: else:
safe = self.textImage('Unsafe', small_font, r=255, g=0, b=0) safe = self.textImage('Unsafe', small_font, r=255, g=0, b=0)
if joke['type'] == 'twopart': if joke['type'] == 'twopart':
decoded = joke['setup'].encode("ascii","ignore")
joke['setup'] = decoded.decode()
joke1 = self.textImage(joke['setup'].replace('\n', ' '), font, int(r),int(g),int(b)) joke1 = self.textImage(joke['setup'].replace('\n', ' '), font, int(r),int(g),int(b))
random_color = random.choice(list(colours.keys())) random_color = random.choice(list(colours.keys()))
r,g,b = colours[random_color] r,g,b = colours[random_color]
decoded = joke['delivery'].encode("ascii","ignore")
joke['delivery'] = decoded.decode()
joke2 = self.textImage(joke['delivery'].replace('\n', ' '), font, int(r), int(g), int(b)) joke2 = self.textImage(joke['delivery'].replace('\n', ' '), font, int(r), int(g), int(b))
else: else:
decoded = joke['joke'].encode("ascii","ignore")
joke['joke'] = decoded.decode()
joke1 = self.textImage(joke['joke'].replace('\n', ' '), font, int(r), int(g), int(b)) joke1 = self.textImage(joke['joke'].replace('\n', ' '), font, int(r), int(g), int(b))
joke2 = None joke2 = None
try: try: