From e49c3e0d6ccfcc1f14186b19acda18a3f7d7d93a Mon Sep 17 00:00:00 2001 From: victormylle Date: Sun, 15 Nov 2020 10:33:42 +0100 Subject: [PATCH] Fixed emoji issue --- cogs/playerlink.py | 16 +++++++++++++--- cogs/quiz.py | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cogs/playerlink.py b/cogs/playerlink.py index 9d29839..0a094d5 100755 --- a/cogs/playerlink.py +++ b/cogs/playerlink.py @@ -7,6 +7,7 @@ import asyncio import threading from functions.timer import Timer from data import constants +import re from data.DatabaseConnection import * # 25216 --> uuid server @@ -36,13 +37,22 @@ def get_player_uuid(minecraftname): raise PlayerError() return data_string +def deEmojify(text): + regrex_pattern = re.compile(pattern = "[" + u"\U0001F600-\U0001F64F" # emoticons + u"\U0001F300-\U0001F5FF" # symbols & pictographs + u"\U0001F680-\U0001F6FF" # transport & map symbols + u"\U0001F1E0-\U0001F1FF" # flags (iOS) + "]+", flags = re.UNICODE) + return regrex_pattern.sub(r'',text) + def send_chat(discordname, minecraftname, code): HOST = '192.168.1.214' # The server's hostname or IP address PORT = 25224 # The port used by the server with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) - s.send(bytes("{}\t{}\t{}\n".format(discordname, minecraftname, code), encoding="ascii")) + s.send(bytes("{}\t{}\t{}\n".format(deEmojify(discordname), minecraftname, code), encoding="ascii")) data = s.recv(1024) data_string = data.decode("utf-8").strip('\n') if data_string == "PlayerError": @@ -149,8 +159,8 @@ class PlayerLink(commands.Cog): except PlayerError: await ctx.send("Player '" + arg + "' not found") - except: - await ctx.send("Something went wrong") + # except: + # await ctx.send("Something went wrong") @commands.command(name="Unlink") async def unlink(self, ctx): diff --git a/cogs/quiz.py b/cogs/quiz.py index b880960..9e13f6a 100644 --- a/cogs/quiz.py +++ b/cogs/quiz.py @@ -245,7 +245,7 @@ class Quiz(commands.Cog): embed.add_field(name="Question:", value=f"{shaken_word}", inline=False) embed.add_field(name="Reward:", value=f"${word['reward']} in game", inline=False) - embed.add_field(name="Answer:", value=f"{word['word']}", inline=False) + embed.add_field(name="Answer:", value=f"{word['word']}", inline=Falvse) try: message = await self.client.wait_for("message", check=lambda message: message.content.lower() == word['word'].lower(), timeout=self.timeout)