jabber.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:fir_async_plugin 作者: gcrahay 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号