Fancify Your Festive Messages with this Python and SMS Script

Fancify Your Festive Messages with this Python and SMS Script

Published December 21, 2018 by Aaron Bassett

???? ???? ??????? ??? ?????-??? ???? ???? ???? ? ?????? ??? ?? ??????? ????????!

Telecoms providers see some of the highest volume of SMS on Christmas Day and New Year’s Eve. So it’s likely your friends, and family members are going to be receiving many messages, not just yours. However, with a little Python, the Nexmo SMS API, and some Unicode trickery we can make your message stand out from the crowd.

??????? ???????

You can view the entire script as a gist. To run locally, you’ll need Python 3 and the Nexmo Python client as well as Click.

Don’t forget to set environmental variables for NEXMO_KEY and NEXMO_SECRET, these values can be found on the Nexmo dashboard. Once you have the dependencies installed and the API values set you can run the script with the command:

????????? ?????

I’ve added 6 different fonts to the script as examples, but a search for “Unicode fancy text” turns up plenty of others you can add.

Screeenshot of SMS messages with custom fonts

???????? ??????? ??? ℂ???

The stack of decorators is how we define our Click command. We’re using a type of click.Choice for the font to limit the values to the keys of our font dictionaries that we’ll look at next.

Here we define our fonts in both lower and uppercase. We’re going to reference them later using fonts_lowercase[font] so the key must match exactly the string passed into the command.

We iterate over each letter from A-Z and do a string.replace on the message using the index of the letter (“a” equals 0, “b” equals 1, and so on) to find the correct letter in our fonts_lowercase[font] string. We make this loop twice, once for lowercase letters and once for uppercase.

Finally, we send our SMS. You can supply any alphanumeric string for the sender, but if you would like the message to appear as though you’ve sent it from your phone, and to ensure that the recipient can reply, you should set the sender to be your mobile number in the E.164 international format.

ℱ???????ℊ ??

This Unicode text also works on Facebook and WhatsApp using our Messages API, so you could make your Facebook Messenger bot seem a bit more ƈʏɮɛʀքʊռӄ, or add a ????? ?? ????? to your WhatsApp messages.

Leave a Reply

Your email address will not be published.