Last active
May 6, 2017 05:37
-
-
Save Restioson/01366264af678c00ce88b00bd6af251b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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