python - Google wave 机器人内联回复

标签 python google-wave

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

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

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

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

最佳答案

如果您查看 sourcecode对于 OpBasedDocument.InsertInlineBlip(),您将看到以下内容:

 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() returns the valueAddBlip(),这是...dun, dun, dun... 一个信号。

 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 会随着功能的添加而改变。

关于python - Google wave 机器人内联回复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1561655/

相关文章:

python - Opsgenie powershell 警报帖子不起作用

real-time - 为什么 Google Docs 的运营转型会偏向删除?

java - Apache wave behind 公司代理;或者 jetty 不尊重代理属性

.net - 如何使用 .NET 进行全双工编程?

python - 无法连接以在openzmq中的现有tcp连接中打开另一个tcp连接

python - 如何在python中打印百分比值?

python - 仅在单击屏幕后才会出现窗口

clojure - Clojure Pedestal 框架中的架构模型是否是类似于 Google Wave 的操作转换?

.net - .Net 版 Google Wave

python - 如何在python3中计算ANSI CRC16多项式(0x8005)?