[英]google wave OnBlipSubmitted
I'm trying 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. 当有人键入@help时,我试图用帮助文本创建一个新的blip,但是由于某种原因它没有创建它。 I'm getting no errors in the log console, and I'm seeing the info log 'in @log' 我在日志控制台中没有任何错误,并且看到了信息日志“ @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. -> Wave和AppSpot之间的服务器连接最近变化很大。 Sometimes it takes 10+ minutes for the AppSpot server to receive my event, othertimes a few seconds. 有时,AppSpot服务器要花10多分钟才能收到我的事件,有时还需要几秒钟。 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()
? 您是否尝试过使用Append()
而不是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. 这就是我在C#API中所做的-我还没有使用Python API,但是我想它是相似的。 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: 编辑:这是从上面的代码生成的JSON:
{
"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? 与您的机器人发出的JSON相比如何?
For some reason it just started working. 由于某种原因,它才开始工作。 I think the google wave is spotty. 我认为Google Wave参差不齐。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.