Skip to content

Instantly share code, notes, and snippets.

@Restioson
Last active May 6, 2017 05:37
Show Gist options
  • Save Restioson/01366264af678c00ce88b00bd6af251b to your computer and use it in GitHub Desktop.
Save Restioson/01366264af678c00ce88b00bd6af251b to your computer and use it in GitHub Desktop.
import string
import unidecode
NUMBERS = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"]
def emojify(text):
"""Converts text to regional indicators for use in discord"""
emojified = ""
for char in text:
normalized_char = unidecode.unidecode(char.lower())
if normalized_char in string.ascii_lowercase:
emojified += ":regional_indicator_{0}: ".format(normalized_char)
elif char.isnumeric():
emojified += ":{0}: ".format(NUMBERS[int(char)])
elif char == " ":
emojified += " "
else:
emojified += char.replace("!", ":exclamation: ").replace("?", ":question: ")
return emojified
if __name__ == "__main__":
while True:
print(emojify(input("> ")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment