Somewhere between whitepapers and a blog.
10 years of experience from the perspective of a designer tumbling into the world of programming lets me think some musings might be of use to people somewhere along the line.
Published: Thursday, 3 Sept, 2009
app.yaml
application: samplerobot
version: 1
runtime: python
api_version: 1
handlers:
- url: /_wave/.*
script: robotmain.py
- url: /assets
static_dir: assets
robotmain.py
from waveapi import events
from waveapi import model
from waveapi import robot
from google.appengine.api import urlfetch
import httplib, urllib
import APISMS
def OnBlipSubmitted(properties, context):
blip = context.GetBlipById(properties['blipId'])
contents = blip.GetDocument().GetText()
orig = blip.GetDocument().GetText()
if contents.find("sms:") > -1:
num_start = contents.find("sms:") + 4
cut = contents[num_start:(num_start+200)]
if cut.find(" ") > -1:
num_end = cut.find(" ")
"""
not a great way to split off the number means that
sms:666 344 797 and sms: 666334797 wont work
"""
num = cut[0:num_end]
msg = cut[(num_end+1):(num_end+161)]
login = '6XXXXXXXX'
pwd = 'XXXXXX'
sender = APISMS.MensajeriaWeb()
sender.EnviaMensaje(login, pwd, num, msg)
contents = blip.GetDocument().SetText(orig + "(message sent)")
if __name__ == '__main__':
myRobot = robot.Robot(
'appName',
image_url='http://samplerobot.appspot.com/icon.png',
version='1',
profile_url='http://samplerobot.appspot.com/'
)
myRobot.RegisterHandler(events.BLIP_SUBMITTED, OnBlipSubmitted)
myRobot.Run()
APISMS
import httplib, urllib
class MensajeriaWeb:
def EnviaMensaje(self, login, pwd, dest, msg) :
params1 = urllib.urlencode ({'TM_ACTION': 'AUTHENTICATE', 'TM_LOGIN': login})
params2 = urllib.urlencode ({'TM_PASSWORD': pwd})
params3 = urllib.urlencode ({'to': dest, 'message': msg})
params = params1 + "&" + params2 + "&" + params3
headers = {"Content-type":"application/x-www-form-urlencoded","Accept": "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*", "User-Agent" : "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727)", "Connection" : "Keep-Alive"}
conn=httplib.HTTPSConnection("opensms.movistar.es")
conn.request ("POST", "/aplicacionpost/loginEnvio.jsp",params, headers)
resp=conn.getresponse()
respuesta=resp.read()
conn.close()