我想3個功能從這裏教程添加到機器人: http://code.google.com/apis/wave/extensions/robots/python-tutorial.html做簡單的事情與谷歌Wave機器人
之前將所有這些功能,我的機器人是否按預期運行。 現在仍然顯示出奇怪的特徵(在blip內容的bck處顯示「v2」),但是沒有任何新功能出現! 我嘗試了不同的方式alr,仍然不起作用。令人沮喪...下面是我認爲看起來更邏輯的代碼。 有人可以告訴我爲什麼沒有人似乎工作?謝謝...
特點1 - 想嘗試AppendText通過
特點2 - 希望機器人能夠檢測曇花一現提交
特點3 - 希望機器人添加曇花一現用的內容舊的blip已刪除。
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()
編輯:(重要!) 我只注意到它似乎在正常模式VS沙盒模式HV不同的行爲。在正常模式下,我看到兩個閃爍「我還活着!v2」和「大家好!v2」,但在沙箱模式下,我只能看到第一個。 Werid ......在兩種情況下我看到了附加文本...
爲什麼我評論這一部分 「」「myRobot.RegisterHandler(events.BLIP_SUMBITTED,OnBlipSubmitted) myRobot.RegisterHandler(events.BLIP_DELETED,OnBlipDeleted原因)「」「」 是因爲沒有評論它,機器人根本沒有做任何事情!
'events.BLIP_SUMBITTED'看起來拼錯了我。 – 2011-07-06 21:07:46