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):