Advertisement
Gguidini

Emoji Message Creator

Jan 16th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.89 KB | None | 0 0
  1. # Python first try
  2.  
  3. """
  4. Emoji Message Creator
  5. by Gguidini - January 2018
  6.  
  7. Code takes a string as input and prints it using big letters made with emojis.
  8. Emojis available are displayed at first.
  9. There is an option to create a file with the message ready to be sent via WhatsApp or any app of the like.
  10. """
  11.  
  12. # map of emoji codes
  13. emojis = {     "grin":'\U0001F600',         # grining face
  14.            "smile":'\U0001F601',        # grin with smiling eyes
  15.            "lol":'\U0001F602',          # laughing to tears
  16.            "smile":'\U0001F603',        # smiling face
  17.            "trueSmile":'\U0001F604',    # similing face and eyes
  18.            "sweat":'\U0001F605',        # similing face with drop
  19.            "wink":'\U0001F609',         # winking
  20.            "cuteSmile":'\U0001F60A',    # cute blushing smile
  21.            "tongue":'\U0001F60B',       # tongue out
  22.            "cool":'\U0001F60E',         # sunglasses
  23.            "heartEyes":'\U0001F60D',    # hearts in the eyes
  24.            "heartKiss":'\U0001F618',    # blowing kiss with heart
  25.            "notAmused":'\U0001F612',    # not amused face
  26.            "sadFace":'\U0001F614',      # sad face
  27.            "shit":'\U0001F4A9',         # smiling poop
  28.            "smirk":'\U0001F60F',        # smirking face
  29.            "cry":'\U0001F62D',          # full out tears
  30.            "mindBlown":'\U0001F92F',    # mind blown
  31.            "redHeart":'\U00002764',     # red heart
  32.            "doubleHeart":'\U0001F495',  # two pink hearts
  33.            "greenHeart":'\U0001F49A'    # green heart
  34.            }
  35.  
  36.  
  37. # map of letter designs
  38. letters = { # LETTERS
  39.             'A':[0x18, 0x3C, 0x66, 0x66, 0x7E, 0x7E, 0x66, 0x66],
  40.             'B':[0x0F, 0x13, 0x13, 0x0F, 0x13, 0x33, 0x13, 0x0F],
  41.             'C':[0x3C, 0x7E, 0x43, 0x03, 0x03, 0x43, 0x7E, 0x3C],
  42.             'D':[0x0F, 0x13, 0x23, 0x63, 0x63, 0x23, 0x13, 0x0F],
  43.             'E':[0x7F, 0x03, 0x03, 0x0F, 0x0F, 0x03, 0x7F, 0x7F],
  44.             'F':[0x7F, 0x03, 0x03, 0x0F, 0x0F, 0x03, 0x03, 0x07],
  45.             'G':[0x3C, 0x7E, 0x43, 0x03, 0x73, 0x43, 0x7E, 0x3C],
  46.             'H':[0xE7, 0x66, 0x66, 0x7E, 0x7E, 0x66, 0x66, 0xE7],
  47.             'I':[0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C],
  48.             'J':[0xF0, 0x60, 0x60, 0x60, 0x60, 0x66, 0x66, 0x3C],
  49.             'K':[0x63, 0x33, 0x1B, 0x0F, 0x1B, 0x33, 0x63, 0xC3],
  50.             'L':[0x0F, 0x06, 0x06, 0x06, 0x06, 0x06, 0x46, 0x7F],
  51.             'M':[0xE7, 0xDB, 0xDB, 0xDB, 0xC3, 0xC3, 0xC3, 0xC3],
  52.             'N':[0xC3, 0xE3, 0xF3, 0xDB, 0xCF, 0xC7, 0xC3, 0xC3],
  53.             'O':[0x3C, 0x66, 0xC3, 0xC3, 0xC3, 0xC3, 0x66, 0x3C],
  54.             'P':[0x3F, 0x63, 0x63, 0x3F, 0x03, 0x03, 0x03, 0x07],
  55.             'Q':[0x3C, 0x66, 0xC3, 0xC3, 0xDB, 0xF3, 0x66, 0xBC],
  56.             'R':[0x3F, 0x63, 0x63, 0x3F, 0x1B, 0x33, 0x63, 0xC7],
  57.             'S':[0x3C, 0x66, 0xC3, 0x1C, 0x38, 0xC3, 0x66, 0x3C],
  58.             'T':[0xFF, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C],
  59.             'U':[0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0x66, 0x3C],
  60.             'V':[0xC3, 0xC3, 0xC3, 0x66, 0x66, 0x66, 0x3C, 0x18],
  61.             'W':[0xC3, 0xC3, 0xC3, 0xC3, 0xDB, 0xDB, 0xDB, 0xE7],
  62.             'X':[0xC3, 0x66, 0x24, 0x18, 0x18, 0x24, 0x66, 0xC3],
  63.             'Y':[0xC3, 0x66, 0x24, 0x18, 0x18, 0x18, 0x18, 0x3C],
  64.             'Z':[0xFF, 0xE1, 0x60, 0x30, 0x18, 0x0C, 0x86, 0xFF],
  65.  
  66.             '0':[0x3C, 0x66, 0xC3, 0xDB, 0xDB, 0xC3, 0x66, 0x3C],
  67.             '1':[0x3C, 0x36, 0x33, 0x30, 0x30, 0x30, 0x30, 0xFC],
  68.             '2':[0x7C, 0xC6, 0x63, 0x30, 0x18, 0x0C, 0x06, 0xFF],
  69.             '3':[0x3F, 0x60, 0xC0, 0x78, 0x78, 0xC0, 0x60, 0x3F],
  70.             '4':[0x60, 0x78, 0x6C, 0x66, 0xFF, 0x60, 0x60, 0x60],
  71.             '5':[0xFF, 0x03, 0x03, 0x3C, 0xC0, 0xC3, 0x66, 0x3C],
  72.             '6':[0x78, 0x06, 0x03, 0x3F, 0x63, 0xC3, 0x66, 0x3C],
  73.             '7':[0xFF, 0xFF, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03],
  74.             '8':[0x3C, 0x66, 0xC3, 0x3C, 0x66, 0xC3, 0x66, 0x3C],
  75.             '9':[0x3C, 0x66, 0xC3, 0xC6, 0xFC, 0xC0, 0x60, 0x1E],
  76.  
  77.             # SPACE AND PONCTUATION
  78.             ' ':[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
  79.             '-':[0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00],
  80.             "'":[0xF0, 0xE0, 0xE0, 0x30, 0x00, 0x00, 0x00, 0x00],
  81.             '!':[0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18]
  82.              }
  83.            
  84. # gets input
  85. print("Available Emojis")
  86. options = list(emojis.items())
  87. for moji in options:
  88.     print("{0} = {1}".format(moji[0], moji[1]))
  89.  
  90. # Emoji to be used
  91. emoji = input("What emoji will you use?\n")
  92.  
  93. # File option
  94. opt = input("would you like to create file to copy the message? [Y/N]")
  95. opt = opt.upper()
  96.  
  97. # String to output
  98. msg = input("what do you want to send?\n")
  99. msg = msg.upper().strip()
  100.  
  101. if (opt.startswith("YES") or opt.startswith("Y")):
  102.     opt = True
  103. else:
  104.     opt = False
  105.  
  106. # file for WhatsApp version
  107. if(opt):
  108.     print("creating file...")
  109.     file = open("out.txt", "w")
  110.     file.write("```")
  111.  
  112. def checkPrint(d, char) :
  113.     if(bool(d&1)) :
  114.         return char
  115.     else:           # double spaces because emojis are wider
  116.         return "  "
  117.  
  118. # log for erros
  119. log = ""
  120. # iterates trough message to print it
  121. for s in msg:
  122.     try:
  123.         for i in letters[s] :
  124.             line = ""
  125.             for d in range(8) :
  126.                 line += checkPrint((i >> d), emojis.get(emoji , emojis["cuteSmile"]))
  127.             print(line)
  128.             line+='\n'
  129.             if(opt):
  130.                 file.write(line)
  131.         if(opt):
  132.             file.write("\n")
  133.         print("")
  134.     except:
  135.         log += "Character " + s + " unavailable\n"
  136.  
  137. print(log)
  138. # finishes and closes file
  139. if(opt):
  140.     file.write("```")
  141.     file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement