def send(self, event, users, instance, paths):
self.client.reconnectAndReauth()
for user, templates in users.items():
jid = self._get_jid(user)
if not self.enabled(event, user, paths) or jid is None:
continue
template = self._get_template(templates)
if template is None:
continue
params = self.prepare(template, instance)
message = xmpp.protocol.Message(jid, body=params['short_description'].encode('utf-8'),
subject=params['subject'].encode('utf-8'), typ='chat')
html = xmpp.Node('html', {'xmlns': 'http://jabber.org/protocol/xhtml-im'})
text = u"<body xmlns='http://www.w3.org/1999/xhtml'>" + markdown2.markdown(params['short_description'],
extras=["link-patterns"],
link_patterns=link_registry.link_patterns(
request),
safe_mode=True) + u"</body>"
html.addChild(node=xmpp.simplexml.XML2Node(text.encode('utf-8')))
message.addChild(node=html)
self.client.send(message)
self.client.disconnected()
评论列表
文章目录