我尝试了这里给出的答案。在这里查找了问题,发现了一些表明这里完全没有希望的东西
我已经尝试升级我的 openssl (macports) 并尝试安装 pyopenssl (macports)。虽然我之前在 macports 上遇到过问题,但我在 xmpppy 和 slimxmpp 上已经取得了成功。因此,我不得不怀疑 wokkel 和 google talk 之间是否存在某种不兼容(如第三个链接中所建议的那样)。这对我来说似乎很奇怪,因为 google talk (据我所知)是一种非常流行的交流媒介。
我的问题很简单,自 2008 年以来是否有人成功地让 wokkel 与 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)