Advertisement
Guest User

Untitled

a guest
May 27th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #!/bin/python3
  2. import sys, random
  3.  
  4. ## HOW TO USE:
  5. ## python emojitext.py "your text here" zws
  6. ## zws: This option is used to enable a zero-width space character to prevent discord from
  7. ## converting your characters into flags.
  8.  
  9. DIGIT = [':zero:', ':one:', ':two:', ':three:', ':four:', ':five:', ':six:', ':seven:', ':eight:', ':nine:']
  10. ALTS = ['ben', 'crap', 'jx9', 'tuts', 'thinking', 'smirk', 'tada', 'snus', 'punk', 'face_palm', 'facepalm', 'clap', 'ok_hand', 'smile', '1234']
  11.  
  12. ZWS = '\u200b' if len(sys.argv) > 2 and sys.argv[2] == 'zws' else ''
  13.  
  14. def to_emoji(word):
  15. if word in ALTS:
  16. print(':%s:' % word, end=ZWS)
  17. else:
  18. for c in word:
  19. if random.randint(0, 100) >= 50 and c == 'b':
  20. print(':b:', end=ZWS)
  21. else:
  22. if c.isdigit():
  23. print(DIGIT[int(c)], end=ZWS)
  24. else:
  25. print(':regional_indicator_%s:' % c, end=ZWS)
  26.  
  27. if len(sys.argv) > 1:
  28. spl = sys.argv[1].lower().split(' ')
  29. for word in spl:
  30. to_emoji(word.strip())
  31. print('', end=' ')
  32. print('')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement