Skip to content

Instantly share code, notes, and snippets.

@majestrate
Created September 26, 2021 01:38
Show Gist options
  • Save majestrate/4f9a335e8ba6e987bae3fa0d31a6952b to your computer and use it in GitHub Desktop.
Save majestrate/4f9a335e8ba6e987bae3fa0d31a6952b to your computer and use it in GitHub Desktop.
emojifier script
#!/usr/bin/python3
#
# emojifier.py
#
# !!!! DANGER !!!!
#
# keep out of reach from children
# may cause permanent mental retardation
#
# !!!! DANGER !!!!
import sys
import random
import collections
_emos = collections.defaultdict(list)
_letters = [
'Ⓐ Ⓑ Ⓒ Ⓓ Ⓔ Ⓕ Ⓖ Ⓗ Ⓘ Ⓙ Ⓚ Ⓛ Ⓜ Ⓝ Ⓞ Ⓟ Ⓠ Ⓡ Ⓢ Ⓣ Ⓤ Ⓥ Ⓦ Ⓧ Ⓨ Ⓩ',
'🄰 🄱 🄲 🄳 🄴 🄵 🄶 🄷 🄸 🄹 🄺 🄻 🄼 🄽 🄾 🄿 🅀 🅁 🅂 🅃 🅄 🅅 🅆 🅇 🅈 🅉',
'🅐 🅑 🅒 🅓 🅔 🅕 🅖 🅗 🅘 🅙 🅚 🅛 🅜 🅝 🅞 🅟 🅠 🅡 🅢 🅣 🅤 🅥 🅦 🅧 🅨 🅩',
'🅰 🅱 🅲 🅳 🅴 🅵 🅶 🅷 🅸 🅹 🅺 🅻 🅼 🅽 🅾 🅿 🆀 🆁 🆂 🆃 🆄 🆅 🆆 🆇 🆈 🆉',
'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z',
'a b c d e f g h i j k l m n o p q r s t u v w x y z'
]
def _make_emo(letter_set):
idx = 0
for _ch in letter_set:
if _ch == ' ':
continue
_idx = chr(idx+ord('a'))
_emos[_idx] += _ch
idx += 1
for _set in _letters:
_make_emo(_set)
def emo(word):
ret = str()
for ch in word:
lch = ch.lower()
if lch in _emos:
ret += random.choice(_emos[lch])
else:
ret += ch
return ret
print(emo(' '.join(sys.argv[1:])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment