本文整理汇总了Python中twisted.words.xish.domish.Element.firstChildElement方法的典型用法代码示例。如果您正苦于以下问题:Python Element.firstChildElement方法的具体用法?Python Element.firstChildElement怎么用?Python Element.firstChildElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.words.xish.domish.Element
的用法示例。
在下文中一共展示了Element.firstChildElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onMessage
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import firstChildElement [as 别名]
def onMessage(self, element: Element):
msgType = element.getAttribute("type")
recipient = JID(element.getAttribute("to"))
sender = JID(element.getAttribute("from"))
text = element.firstChildElement().__str__()
if msgType == "chat":
self.getClient(sender).sendMessage(recipient, text)
else:
raise NotImplementedError
示例2: __setRegister
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import firstChildElement [as 别名]
def __setRegister(self, data: Element, sender: JID, identifier: str):
try:
user = sender.userhost()
token = data.firstChildElement().firstChildElement().firstChildElement().firstChildElement().__str__()
except Exception as e:
# Fail registration
print("Register reponse processing failed: " + e.__str__())
# FIXME: Send negative response here !!!
self.__sendIqResult(sender.full(), self.h2x.config.JID, identifier, "jabber:iq:register")
return
self.h2x.registerUser(user, token)
# Send registration done
self.__sendIqResult(sender.full(), self.h2x.config.JID, identifier, "jabber:iq:register")
# Request subscription
self.h2x.sendPresence(sender, "subscribe")