Python XEP 0280采用光滑的XmPP获得碳纤维消息体
我已经用Python框架sleekxmpp创建了一个小型XMPP客户机。我使用以下代码创建连接类:Python XEP 0280采用光滑的XmPP获得碳纤维消息体,python,python-2.7,xmpp,xmppframework,Python,Python 2.7,Xmpp,Xmppframework,我已经用Python框架sleekxmpp创建了一个小型XMPP客户机。我使用以下代码创建连接类: class Client(ClientXMPP): def __init__(self, jid, password): ClientXMPP.__init__(self, jid, password) self.register_plugin('xep_0280') self.add_event_handler("session_start
class Client(ClientXMPP):
def __init__(self, jid, password):
ClientXMPP.__init__(self, jid, password)
self.register_plugin('xep_0280')
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message)
self.add_event_handler("carbon_received", self.carbon_received)
self.add_event_handler("carbon_sent", self.carbon_sent)
我得到一个消息或碳类的回调。在message函数中,我可以使用msg[“body”]获取消息正文,但是如何从carbons消息获取消息正文呢
我尝试以与消息funktion相同的方式获取它,但它只返回一个空字符串。如果我做了一个类型的msg[“forwarded”],我得到了“”,但我不能得到消息正文
我使用的回调函数:
def message(self, msg):
sendMsg(msg["to"], msg["body"])
print msg["body"]
def carbon_received(self, msg):
print "carbon_received"
#print type(msg['forwarded'])
#print msg['forwarded']["stanza"]
#print msg
def carbon_sent(self, msg):
print "carbon_sent"
#print type(msg['forwarded'])
#print msg['forwarded']["stanza"]
#print msg