Automatic Tweets - Word of The Day

Using Python and Twitter API

Posted on June 24, 2015 in webdev

Nearly 5 years ago, being the "gotta have" teenager I was, and having recently discovered the joy of using the perfect word in the perfect occasion, I resolved never to gloss over one unfamiliar word again. I believed that I could become as succinct yet brilliantly voluble as the infamous Aldous Huxley.

Anyway, I started recording every word that I ran into, along with its meaning and appropriate contexts, in order to construct the perfect vocabulary. A few years after my glorious resolution I tried to write a script to feed me a word a day, but I ended up abandoning it because of this...

I wrote some code in python that spit out a word and its definition, but it just wasn't written well and wasn't as glamorous as I imagined it to be. Even though python was supposed to be one of the easiest languages to learn, I just couldn't find the drive to finish that project.

Today I have the motivation I lacked then with a little more knowledge (maybe just more patience) to follow through with my idea and link it up with a twitter account that I started roughly around the same time I resolved to be like Aldous Huxley, called "@wordofyourday"

A quick google search led me to this guide which I used to make a simple app that tweets a word each day. The only real work is getting my words, definitions, and example sentences all organized into one text file.

After the if statement, the program starts reading characters and adding them to the string called 'tweet' until it hits a newline character. Because of the way I've set up the text file, it will stop reading before it makes it to the second word. If the tweet is empty, then it won't tweet anything. If I don't see a confirmation of my tweet, then I know that my wordlist is empty.

The next step would be to schedule this to run daily, liberating me completely from the tweeting process. For now, I'm just going to run the program myself to make sure everything works properly.

This was a fun little project. It was very simple and it only took two hours or so to iron everything out. Python rescued me from my excuse once again by showing me that anything is possible with a little bit of code.


comments powered by Disqus