谷歌Wave OnBlipSubmitted
-
21-09-2019 - |
题
我试图创建一个波机器人,和我有基本的东西的工作。我想,当有人类型@help来创建帮助文本一个新的消息,但是由于某种原因,它不创建它。我越来越没有错误日志控制台,我看到“在@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')
解决方案 3
出于某种原因,刚开始工作。我认为,谷歌波是参差不齐的。
其他提示
如果它刚开始工作时,我有两个建议......
- >已经在构造函数中你一直在更新版本的机器人?当您更新变化,使缓存可以更新你应该改变的值。
if __name__ == '__main__':
myRobot = robot.Robot('waverobotdev',
image_url = baseurl + 'assets/wave_robot_icon.png',
version = '61', # <-------------HERE
profile_url = baseurl)
- >波和Appspot上之间的服务器连接最近一直非常可变的。有时需要10+分钟,Appspot上服务器接收我的事件,othertimes几秒钟。验证您收到您所期望的事件。
编辑: 你的代码提供很好看,所以我不希望你做什么错事在这方面。
您是否尝试过使用Append()
代替SetText()
?这就是我在我的C#API做的 - 我还没有使用Python的API,但我想它类似。下面是从我的演示机器人的示例:
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?");
}
}
这工作正常。
编辑:这里从上面的代码是生成的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?"
}
]
}
}
那如何与来自你的机器人吗?JSON的比较
不隶属于 StackOverflow