I wanted to add 3 features to the robot from the tutorial here:
http://code.google.com/apis/wave/extensions/robots/python-tutorial.html
Before adding all these features, my robot is working as intended.
Now the odd features still shows up (with "v2" at the bck of the blip
content), but neither of the new features shows up!
I tried different ways alr, still doesn't work. So frustrating...
Below is the code tt i think looks more logically.
Can someone tell me why none seems to work? Thanks...
Feature 1 -- wanted to try out AppendText
Feature 2 -- wanted the robot to detect a blip is submitted
Feature 3 -- wanted the robot to add a blip with the content of the
old blip deleted.
from waveapi import events
from waveapi import model
from waveapi import robot
def OnParticipantsChanged(properties, context):
"""Invoked when any participants have been added/removed."""
added = properties['participantsAdded']
for p in added:
Notify(context)
def OnRobotAdded(properties, context):
"""Invoked when the robot has been added."""
root_wavelet = context.GetRootWavelet()
"""feature 1"""
root_wavelet.CreateBlip().GetDocument().SetText("I'm alive!
v2").GetDocument().AppendText("xxx")
def Notify(context):
root_wavelet = context.GetRootWavelet()
root_wavelet.CreateBlip().GetDocument().SetText("Hi everybody! v2")
"""feature 2"""
def OnBlipSubmitted(properties, context):
blip = context.GetBlipById(properties['blipId'])
blip.GetDocument().AppendText("xxx")
"""feature 3"""
def OnBlipDeleted(properties, context):
blip = context.GetBlipById(properties['blipId'])
contents = blip.GetDocument().GetText()
root_wavelet = context.GetRootWavelet()
root_wavelet.CreateBlip().GetDocument().SetText(contents)
if __name__ == '__main__':
myRobot = robot.Robot('appName',
image_url='http://appName.appspot.com/icon.png',
version='1',
profile_url='http://appName.appspot.com/')
myRobot.RegisterHandler(events.WAVELET_PARTICIPANTS_CHANGED,
OnParticipantsChanged)
myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded)
"""myRobot.RegisterHandler(events.BLIP_SUMBITTED, OnBlipSubmitted)
myRobot.RegisterHandler(events.BLIP_DELETED, OnBlipDeleted)"""
myRobot.Run()
--
You received this message because you are subscribed to the Google Groups
"Google Wave API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-wave-api?hl=en.