Tag Archives: MySQLdb

My Textbot and the Weather

About a month ago, I stumbled upon pygooglevoice, a python library to interface with google voice.  Of course, the wheels started spinning, and I decided to write a script that will send and receive text messages.  The project provided several examples to use with command line interfaces, which were very helpful in interfacing with google voice, but I took those examples and modified them to interface with a MySQL database.

The script will log onto Google voice, grab all messages, and place them in the incoming table.  The script will then grab all incoming messages, process them and place responses in an outgoing table.  Finally, the script will send all messages in the outgoing table.

….and now for the weather

The first service I have developed for my textbot is the weather.  Using python-weather-api, I am able to provide weather results via text message.  All text messages starting with the word weather followed by a space will be sent to the weather api.  The weather api will then interpret everything after the space as a location code.  Since, I am sending the request through Google weather, a number of different formats may be used.  Typically a city/state or zip code can be used.  Large cities such as Chicago or New York do not require the state, but small ones do.

Here are some examples:

Me to <textbot number>
8/9/10 12:50 AM 21 minutes ago
Me: weather kansas city, mo 12:31 AM
<textbot number>: It is 89 and Clear. Wind: S at 9 mph, Humidity: 63% in Kansas City, MO 12:36 AM
Me: weather 64086 12:37 AM
<textbot number>: It is 85 and Clear. Wind: S at 8 mph, Humidity: 74% in Lee’s Summit, MO 12:41 AM
Me: weather bangkok 12:41 AM
<textbot number>: It is 90 and Cloudy. Wind: SW at 13 mph, Humidity: 49% in bangkok 12:46 AM
Me: weather Moscow, Russia 12:49 AM
<textbot number>: It is 69 and Overcast. Wind: N at 0 mph, Humidity: 90% in moscow, russia 12:50 AM

As you can see, the number for the service is <textbot number>.  That number will not ring any phones or deliver text messages to a human being.  Unless you

I’ve created a basic tutorial page at textbot.ryanveach.com to provide a listing of features and instructions.  At the moment, it is nothing fancy by any means, but it gets the job done.

I’ve got more ideas planned, but they are a surprise 😉

Edit: This service has been taken offline so I can pursue other options with this google voice account.  Because of this, I’ve decided to edit out the number in case somebody else winds up with the same phone number.  I don’t want to spam them!