Google Wave 机器人内嵌回复

发布于 2024-08-08 02:55:55 字数 491 浏览 7 评论 0 原文

我最近一直在为 google wave 开发我的第一个机器人,它所做的一个重要部分是将内联回复插入到 blip 中。我一辈子都不知道该怎么做!

API 文档有一个函数 InsertInlineBlip 听起来很有希望,但是调用它似乎没有做任何事情!

编辑:: 看来这是一个已知的错误。然而,问题仍然是插入内联 blip 的正确方法是什么?我假设是这样的:

inline = blip.GetDocument().InsertInlineBlip(positionInText)
inline.GetDocument().SetText("some text")

I've been working on my first robot for google wave recently, a vital part of what it does is to insert inline replies into a blip. I can't for the life of me figure out how to do this!

The API docs have a function InsertInlineBlip which sounded promising, however calling that doesn't appear to do anything!

EDIT::
It seems that this is a known bug. However, the question still stands what is the correct way to insert an inline blip? I'm assuming something like this:

inline = blip.GetDocument().InsertInlineBlip(positionInText)
inline.GetDocument().SetText("some text")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

弥繁 2024-08-15 02:55:55

如果您查看 OpBasedDocument.InsertInlineBlip() 的 >sourcecode 您将看到以下内容:

 412 -  def InsertInlineBlip(self, position): 
 413      """Inserts an inline blip into this blip at a specific position. 
 414   
 415      Args: 
 416        position: Position to insert the blip at. 
 417   
 418      Returns: 
 419        The JSON data of the blip that was created. 
 420      """ 
 421      blip_data = self.__context.builder.DocumentInlineBlipInsert( 
 422          self._blip.waveId, 
 423          self._blip.waveletId, 
 424          self._blip.blipId, 
 425          position) 
 426      # TODO(davidbyttow): Add local blip element. 
 427      return self.__context.AddBlip(blip_data) 

我认为 TODO 注释表明此功能尚未激活。该方法应该是可调用的并正确返回,但是我怀疑文档操作未应用于全局文档。

您在帖子中包含的语法看起来是正确的。正如您在上面看到的, InsertInlineBlip() 返回 AddBlip() 的值,即 ...dun, dun, dun... 一个 blip。

 543 -  def AddBlip(self, blip_data): 
 544      """Adds a transient blip based on the data supplied. 
 545   
 546      Args: 
 547        blip_data: JSON data describing this blip. 
 548   
 549      Returns: 
 550        An OpBasedBlip that may have operations applied to it. 
 551      """ 
 552      blip = OpBasedBlip(blip_data, self) 
 553      self.blips[blip.GetId()] = blip 
 554      return blip 

编辑:
值得注意的是,Insert 方法 InsertInlineBlip(self,position) 的方法签名与 Insert 方法 InsertElement(self,position, element) 显着不同。 InsertInlineBlip() 不需要插入元素参数。看来 InsertInlineBlip() 的当前逻辑更像是 Blip.CreateChild(),它返回一个要使用的新子 blip。由此我们可以怀疑这个 API 会随着功能的添加而改变。

If you look at the sourcecode for OpBasedDocument.InsertInlineBlip() you will see the following:

 412 -  def InsertInlineBlip(self, position): 
 413      """Inserts an inline blip into this blip at a specific position. 
 414   
 415      Args: 
 416        position: Position to insert the blip at. 
 417   
 418      Returns: 
 419        The JSON data of the blip that was created. 
 420      """ 
 421      blip_data = self.__context.builder.DocumentInlineBlipInsert( 
 422          self._blip.waveId, 
 423          self._blip.waveletId, 
 424          self._blip.blipId, 
 425          position) 
 426      # TODO(davidbyttow): Add local blip element. 
 427      return self.__context.AddBlip(blip_data) 

I think the TODO comment suggests this feature is not yet active. The method should be callable and return correctly, however I suspect that the document operation is not applied to the global document.

The syntax you included in your post looks correct. As you can see above, InsertInlineBlip() returns the value of AddBlip(), which is ...dun, dun, dun... a blip.

 543 -  def AddBlip(self, blip_data): 
 544      """Adds a transient blip based on the data supplied. 
 545   
 546      Args: 
 547        blip_data: JSON data describing this blip. 
 548   
 549      Returns: 
 550        An OpBasedBlip that may have operations applied to it. 
 551      """ 
 552      blip = OpBasedBlip(blip_data, self) 
 553      self.blips[blip.GetId()] = blip 
 554      return blip 

EDIT:
It is interesting to note that the method signature of the Insert method InsertInlineBlip(self, position) is significantly different from the Insert method InsertElement(self, position, element). InsertInlineBlip() doesn't take an element parameter to insert. It seems the current logic for InsertInlineBlip() is more like Blip.CreateChild(), which returns a new child blip with which to work. From this we can suspect that this API will change as the functionality is added.

我三岁 2024-08-15 02:55:55

这可能是一个错误

It could be a possible bug.

救赎№ 2024-08-15 02:55:55

这以前似乎是一个错误,但是今天的更新有望修复它:
http://code.google.com/p/google-wave-资源/wiki/WaveAPIsChangeLog

This appears to have previously been a bug, however, an update today has hopefully fixed it:
http://code.google.com/p/google-wave-resources/wiki/WaveAPIsChangeLog

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文