开发者

google wave OnBlipSubmitted

I'm try开发者_JAVA技巧ing to create a wave robot, and I have the basic stuff working. I'm trying to create a new blip with help text when someone types @help but for some reason it doesnt create it. I'm getting no errors in the log console, and I'm seeing the info log 'in @log'

def OnBlipSubmitted(properties, context):
  # Get the blip that was just submitted.
  blip = context.GetBlipById(properties['blipId'])
  text = blip.GetDocument().GetText()
  if text.startswith('@help') == True:
    logging.info('in @help')
    blip.CreateChild().GetDocument().SetText('help text')


if it just started working, I have two suggestions...

-->Have you been updating the Robot Version in the constructor? You should change the values as you update changes so that the caches can be updated.

if __name__ == '__main__':                                          
    myRobot = robot.Robot('waverobotdev',
                           image_url = baseurl + 'assets/wave_robot_icon.png',
                           version = '61',  # <-------------HERE
                           profile_url = baseurl)

-->The server connection between Wave and AppSpot has recently been extremely variable. Sometimes it takes 10+ minutes for the AppSpot server to receive my event, othertimes a few seconds. Verify you're receiving the events you expect.

Edit: The code you provided looks good, so I wouldn't expect you're doing anything wrong in that respect.


Have you tried using Append() instead of SetText()? That's what I'd do in my C# API - I haven't used the Python API, but I'd imagine it's similar. Here's a sample from my demo robot:

protected override void OnBlipSubmitted(IEvent e)
{
    if (e.Blip.Document.Text.Contains("robot"))
    {
        IBlip blip = e.Blip.CreateChild();
        ITextView textView = blip.Document;
        textView.Append("Are you talking to me?");
    }
}

That works fine.

EDIT: Here's the resulting JSON from the above code:

{
  "javaClass": "com.google.wave.api.impl.OperationMessageBundle",
  "version": "173784133",
  "operations": {
    "javaClass": "java.util.ArrayList",
    "list": [
      {
        "javaClass": "com.google.wave.api.impl.OperationImpl",
        "type": "BLIP_CREATE_CHILD",
        "waveId": "googlewave.com!w+PHAstGbKC",
        "waveletId": "googlewave.com!conv+root",
        "blipId": "b+Iw_Xw7FCC",
        "index": -1,
        "property": {
          "javaClass": "com.google.wave.api.impl.BlipData",
          "annotations": {
            "javaClass": "java.util.ArrayList",
            "list": []
          },
          "lastModifiedTime": -1,
          "contributors": {
            "javaClass": "java.util.ArrayList",
            "list": []
          },
          "waveId": "googlewave.com!w+PHAstGbKC",
          "waveletId": "googlewave.com!conv+root",
          "version": -1,
          "parentBlipId": null,
          "creator": null,
          "content": "\nAre you talking to me?",
          "blipId": "410621dc-d7a1-4be5-876c-0a9d313858bb",
          "elements": {
            "map": {},
            "javaClass": "java.util.HashMap"
          },
          "childBlipIds": {
            "javaClass": "java.util.ArrayList",
            "list": []
          }
        }
      },
      {
        "javaClass": "com.google.wave.api.impl.OperationImpl",
        "type": "DOCUMENT_APPEND",
        "waveId": "googlewave.com!w+PHAstGbKC",
        "waveletId": "googlewave.com!conv+root",
        "blipId": "410621dc-d7a1-4be5-876c-0a9d313858bb",
        "index": 0,
        "property": "Are you talking to me?"
      }
    ]
  }
}

How does that compare with the JSON which comes out of your robot?


For some reason it just started working. I think the google wave is spotty.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜