def checkInbox(): for message in voice.sms().messages: if not message.isRead: n=message.phoneNumber msgtxt = str(message.messageText) txtarray = msgtxt.split(" ") print txtarray if len(txtarray) > 2: e = String(txtarray[0]) #print e key = txtarray[1] #print key code = ' '.join([str(x) for x in txtarray[2:len(txtarray)]]) #print code if e.equalsIgnoreCase("encode"): coded = encrypt(code, key) #print "Coded message" if len(coded) < 140: postToTwitter(coded) returnText(n, "Posted to Twitter: "+coded) else: returnText(n, "Coded message too long") elif e.equalsIgnoreCase("decode"): uncoded = decrypt(code, key) #print "Decoded message" returnText(n, "Uncoded text: "+uncoded) else: returnText(n, "Unable to parse input text message") message.delete() time.sleep(10)