SMS (+ contact name) -> Twitter!

Submitted by alajous@mit.edu on Wed, 04/15/2009 - 16:25.

This script automatically sends every SMS recieved on the phone to a Twitter account where the number of the phone from where it was originally sent and the content of the SMS appear on Twitter. (For it to work you need to setup the Twitter SMS service in you Twitter account)

From what I presented in class I made a small modification after Chris' "I am wearing a tutu" SMS (Twitter: andreslajous, I am wearing a tutu) so that it now would say "andreslajous, Chris dice (spanish for says) : I am wearing a tutu".

import inbox, e32, appuifw, messaging
global i
global id

#exit function


app_lock=e32.Ao_lock()
def quit():
app_lock.signal()
appuifw.app.exit_key_handler=quit

#this retrieves the content of the received sms


id=0
def cb(id_cb):
global id
id=id_cb
i=inbox.Inbox()
data1 = i.address(id)
data2 = i.content(id)
#this sends the retreived content to Twitter's SMS service


messaging.sms_send("40404", u" %s dice: %s " % (data1, data2))
i=inbox.Inbox()
i.bind(cb)
app_lock.wait()