diff --git a/ircbot/plugin/wide.py b/ircbot/plugin/wide.py index 0e5e71f..4f4d0ac 100644 --- a/ircbot/plugin/wide.py +++ b/ircbot/plugin/wide.py @@ -61,6 +61,13 @@ def get_text(bot, msg): return text.strip() +def is_emoji(c): + if ord(c) in range(0x1f300, 0x1fadf) or ord(c) in range(0x2700, 0x27bf): + return True + else: + return False + + def widetextify(bot, msg, width, translation=WIDETEXT_MAP): """welcome to the ocf @@ -69,7 +76,17 @@ def widetextify(bot, msg, width, translation=WIDETEXT_MAP): message in the channel. """ text = get_text(bot, msg) - + response = '' if text: - response = (c.translate(translation) + WIDE_SPACE_CHAR * width for c in text) + for i in range(len(text)): + if is_emoji(text[i]) and i < len(text) - 1: + if ord(text[i + 1]) == 0x200d or ord(text[i + 1]) == 0xfe0f: + response += text[i] + else: + response += text[i] + WIDE_SPACE_CHAR * width + elif ord(text[i]) == 0x200d and i < len(text) - 1: + response += text[i] + else: + response += text[i].translate(translation) + WIDE_SPACE_CHAR * width + msg.respond(''.join(response), ping=False)