SleekXMPP的一个分支,TLS证书验证已禁用,仅用于与sucks项目一起使用
项目描述
这个SleekXMPP的分支TLS证书验证已禁用,专门用于wpietri/sucks。这是Ecovacs证书问题的一个临时解决方案。
SleekXMPP是一个MIT许可的Python 2.7/3.4+ XMPP库,并被Kevin Smith、Remko Tronçon和Peter Saint-Andre所著的XMPP: The Definitive Guide中的示例所采用。如果您是通过阅读《Definitive Guide》来到这里的,请参阅有关更新示例到SleekXMPP最新版本的说明。
SleekXMPP的设计目标和理念是
- 依赖项数量少
安装和使用SleekXMPP应该尽可能简单,无需处理长依赖链。
作为减少依赖项的一部分,SleekXMPP在thirdparty目录中包含了一些第三方模块。从该模块导入时,首先尝试导入已安装的现有版本,如果可能的话。
- 每个XEP都是一个插件
遵循Python的“包含电池”方法,目标是支持所有当前活跃的XEPs(最终和草案)。由于XEP支持是通过易于创建的插件实现的,因此希望为实施和创建实验性XEPs提供坚实的基础。
- 易于合作
尽可能让SleekXMPP通过合理的默认值和适当的抽象实现“即插即用”。XML可以很丑陋,但不必如此。
获取代码
从PyPI获取最新稳定版本
pip install sleekxmpp
最新版本的SleekXMPP源代码可在Github上找到。发布版本位于master分支,而最新开发版本位于develop分支。
安装DNSPython
如果您使用Python3并且希望使用dnspython,您将需要检出并安装python3分支
git clone http://github.com/rthalley/dnspython cd dnspython git checkout python3 python3 setup.py install
讨论
提供邮件列表和XMPP聊天室,以讨论SleekXMPP并获取帮助。
文档和测试
文档既可以在代码中找到,也可以在/docs中的Sphinx项目中找到。要生成Sphinx文档,请遵循以下命令。HTML输出将在docs/_build/html
cd docs make html open _build/html/index.html
运行SleekXMPP的测试套件
python testall.py
SleekXMPP模板
使用SleekXMPP的项目通常遵循设置客户端/组件连接和配置的基本模式。以下是SleekXMPP项目所需的模板概要。有关SleekXMPP项目的更详细原型,请参阅文档或示例目录
import logging
from sleekxmpp import ClientXMPP
from sleekxmpp.exceptions import IqError, IqTimeout
class EchoBot(ClientXMPP):
def __init__(self, jid, password):
ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message)
# If you wanted more functionality, here's how to register plugins:
# self.register_plugin('xep_0030') # Service Discovery
# self.register_plugin('xep_0199') # XMPP Ping
# Here's how to access plugins once you've registered them:
# self['xep_0030'].add_feature('echo_demo')
# If you are working with an OpenFire server, you will
# need to use a different SSL version:
# import ssl
# self.ssl_version = ssl.PROTOCOL_SSLv3
def session_start(self, event):
self.send_presence()
self.get_roster()
# Most get_*/set_* methods from plugins use Iq stanzas, which
# can generate IqError and IqTimeout exceptions
#
# try:
# self.get_roster()
# except IqError as err:
# logging.error('There was an error getting the roster')
# logging.error(err.iq['error']['condition'])
# self.disconnect()
# except IqTimeout:
# logging.error('Server is taking too long to respond')
# self.disconnect()
def message(self, msg):
if msg['type'] in ('chat', 'normal'):
msg.reply("Thanks for sending\n%(body)s" % msg).send()
if __name__ == '__main__':
# Ideally use optparse or argparse to get JID,
# password, and log level.
logging.basicConfig(level=logging.DEBUG,
format='%(levelname)-8s %(message)s')
xmpp = EchoBot('somejid@example.com', 'use_getpass')
xmpp.connect()
xmpp.process(block=True)
致谢
- 主要作者: Nathan Fritz
-
Nathan也是XMPPHP和Seesmic-AS3-XMPP的作者,并且曾是XMPP委员会的成员。
- 合著者: Lance Stout
- 贡献者
Brian Beggs (macdiesel)
Dann Martens (dannmartens)
Florent Le Coz (louiz)
Kevin Smith (Kev,http://kismith.co.uk)
Remko Tronçon (remko,http://el-tramo.be)
Te-jé Rogers (te-je)
Thom Nichols (tomstrummer)
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。