ZeroConf 使用 Python 聊天
我正在尝试为我们的帮助台系统设置一个 Bonjour(或 Ahavi)聊天机器人,它可以根据菜单系统回答基本问题。我的问题的基础是如何让 python 创建机器人,以便它作为聊天客户端连接到网络。
基本上,我的网络上使用 iChat 或 Empathy(或任何能够通过本地网络查看用户的聊天程序)的任何人都应该看到该机器人,就像他们看到其他用户一样。实际的机器人部分编程起来非常简单,但我不知道如何将其连接到网络上。
我研究过 ZeroConf,但我不太确定它是如何工作的,或者如何使用 python 运行聊天服务。我已经看到对 pybonjour、avahi 的 python 绑定和 pyzeroconf 的引用,但同样,我不知道如何设置它们。
如果有人能给出一个例子,或者参考,甚至是一篇关于这个主题的好文章,我们将不胜感激。谢谢!
科里
I am trying to set up a Bonjour (or Ahavi) chatbot for our helpdesk system that would answer basic questions based on a menu system. The basis of my question is how do I get python to create the bot so that it connects to the network as a chat client.
Basically, anyone on my network with iChat or Empathy (or any chat program able to view users over the local network) should see the bot just as they see another user. The actual bot part would be quite simple to program, but I have no idea how to get it on the network.
I have looked into ZeroConf, but I'm not exactly sure how it works, or how to get a chat service running with python. I have seen references to pybonjour, python bindings for avahi, and pyzeroconf, but again, I have no idea how to set them up.
If anyone could give an example, or reference, or even a good article to read on the subject, it would be much appreciated. Thanks!
Kory
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你想要做什么和如何做之间存在脱节。 Zeroconf/Avahi 是关于服务发现的。你所描述的是一个聊天机器人。聊天机器人连接到现有的聊天服务器。苹果公司的 iChat 稍微模糊了这些界限。
iChat(大概还有其他实现该协议的聊天客户端)使用 Bonjour 来提供避免外部服务器连接的方法。
本质上,您需要做的是实现一个也使用 Bonjour 的聊天服务器。 Bonjour 部分宣传服务,聊天部分处理实际通信。您可能希望使用 python 库进行心灵感应,例如 python-telepathy 或 python-empathy [Telepathy][1]。 iChat 似乎使用 AIM,因此这将是需要研究的协议。 IIRC 它还支持 XMPP,因此 XMPP python 库可能是一个选项。
我会考虑使用 [bonjour-py][2] 来宣传该服务。这可能有点棘手,但听起来很有趣。 bonjour-py 页面还有许多其他术语,如果不能满足您的需求,您可以搜索。
[1]: http://telepathy.freedesktop.org/wiki/ Telepathy 主页
[2] :http://www.mcs.anl.gov/research/项目/accessgrid/bonjour-py/ bonjour-py
What you have here is a disconnect between what you want to do and how to do it. Zeroconf/Avahi are about service discovery. What you describe is a chat bot. Chat bots connect to an existing chat server. Apple with iChat has slightly blurred these lines.
iChat (and presumably other chat clients that implement the protocol) uses Bonjour to provide a means of avoiding outside server connections.
Essentially what you would need to do is to implement a chat server that also utilizes Bonjour. The Bonjour part advertises the service, and the chat portion handles the actual communication. You would likely want to use python libraries for telepathy such as python-telepathy or python-empathy [Telepathy][1]. iChat seems to speak AIM, so that would be the protocol to look into. IIRC it also supports XMPP so so the XMPP python libraries might be an option.
I'd look at using [bonjour-py][2] to advertise the service. It might be a bit tricky, but does sound interesting. The bonjour-py page has numerous other terms you can search on if it doesn't meet your needs.
[1]: http://telepathy.freedesktop.org/wiki/ Telepathy Home
[2]: http://www.mcs.anl.gov/research/projects/accessgrid/bonjour-py/ bonjour-py
最简单的方法是使用 Telepathy Salut 或 Pidgin/libpurple,并通过 D-Bus 与其对话。
The easiest thing to do is to use Telepathy Salut or Pidgin/libpurple, and talk with it over D-Bus.