如何在google talk中使用wokkel:(错误)twisted.words.协议.萨斯加布朗斯加姆萨斯加布朗斯加姆萨斯加布朗斯加姆萨斯加布尔萨斯加布朗斯加姆萨斯加布尔萨斯加布朗斯加姆萨斯加布尔萨斯加布尔萨斯加布尔萨斯)

2024-06-01 05:13:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我试了一下给出的答案。查找问题here,发现一些东西表明这是完全没有希望的here

我已经尝试过升级我的openssl(macports)并尝试安装pyopenssl(macports)。尽管我以前在macports上遇到过问题,但我已经成功地使用xmppy和sleekxmpp。因此,我不得不怀疑wokkel和googletalk之间是否存在某种不兼容(如第三个链接所示),这对我来说似乎很奇怪,因为googletalk(据我所知)是一种非常流行的通信媒介。在

我的问题很简单,自2008年以来,是否有人成功地让沃克尔与google talk合作,如果成功了,是怎么做到的?在

这就是我所拥有的:

from twisted.words.xish import domish
from wokkel.xmppim import MessageProtocol, AvailablePresence

class EchoBotProtocol(MessageProtocol):
  def connectionMade(self):
      print "Connected!"

      # send initial presence
      self.send(AvailablePresence())

  def connectionLost(self, reason):
      print "Disconnected!"

  def onMessage(self, msg):
      print str(msg)

      if msg["type"] == 'chat' and hasattr(msg, "body"):
          reply = domish.Element((None, "message"))
          reply["to"] = msg["from"]
          reply["from"] = msg["to"]
          reply["type"] = 'chat'
          reply.addElement("body", content="echo: " + str(msg.body))

          self.send(reply)

from twisted.application import service
from twisted.words.protocols.jabber import jid
from wokkel.client import XMPPClient

application = service.Application("echobot")

xmppclient = XMPPClient(jid.internJID("someuser@example.com/echobot"), "pass")
xmppclient.logTraffic = False
echobot = EchoBotProtocol()
echobot.setHandlerParent(xmppclient)
xmppclient.setServiceParent(application)

Tags: fromimportselfsendapplicationdeftwistedbody