Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions ircbot/plugin/wide.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""ο½—ο½…ο½Œο½ƒο½ο½ο½…γ€€ο½”ο½γ€€ο½”ο½ˆο½…γ€€ο½ο½ƒο½†

Expand All @@ -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)