comparison sat/plugins/plugin_xep_0334.py @ 2652:baccc27d5c5c

plugin XEP-0334: added a method to add hint directly to elements (i.e. on domish.Element instead of message data)
author Goffi <goffi@goffi.org>
date Sat, 11 Aug 2018 18:24:55 +0200
parents 56f94936df1e
children 5060cbeec01e
comparison
equal deleted inserted replaced
2651:ebcff5423465 2652:baccc27d5c5c
83 if hint in self.HINTS: 83 if hint in self.HINTS:
84 hints.add(hint) 84 hints.add(hint)
85 else: 85 else:
86 log.error(u"Unknown hint: {}".format(hint)) 86 log.error(u"Unknown hint: {}".format(hint))
87 87
88 def addHintElements(self, message_elt, hints):
89 """Add hints elements to message stanza
90
91 @param message_elt(domish.Element): stanza where hints must be added
92 @param hints(iterable(unicode)): hints to add
93 """
94 for hint in hints:
95 message_elt.addElement((NS_HINTS, hint))
96
88 def _sendPostXmlTreatment(self, mess_data): 97 def _sendPostXmlTreatment(self, mess_data):
89 if "hints" in mess_data: 98 if "hints" in mess_data:
90 for hint in mess_data["hints"]: 99 self.addHintElements(mess_data[u"xml"], mess_data[u"hints"])
91 mess_data[u"xml"].addElement((NS_HINTS, hint))
92 return mess_data 100 return mess_data
93 101
94 def sendMessageTrigger( 102 def sendMessageTrigger(
95 self, client, mess_data, pre_xml_treatments, post_xml_treatments 103 self, client, mess_data, pre_xml_treatments, post_xml_treatments
96 ): 104 ):