使用 libpurple 的好例子?
我家里有一台旧机器,其中一个 这台机器的作用是检测特定的门是否在 房子刚刚开门或关门。
现在,我让那台机器在私人主页上发布了一条推文 推特帐户。
我现在想为这台机器提供自己的 AIM 帐户 并让它在 AIM 上向我发送消息。唯一的消息 将发送的字面意思是“前门打开”并且 “前门关着。”
看来 libpurple 是一个常用的库 处理各种即时消息协议 甚至在 Adium 中也使用过,但它非常复杂并且 我不知道如何使用它。
有谁拥有或知道一个简单的代码示例 使用 libpurple 吗?
I have an old machine in my house and one of the things
this machine does is detect whether a particular door in
the house has just opened or closed.
Right now, I have that machine post a tweet on a private
Twitter account.
I would now like to give this machine its own AIM account
and have it send me a message on AIM. The only messages
that will be sent are literally "front door open" and
"front door closed."
It appears that libpurple is a commonly used library for
dealing with various instant messaging protocols and is
even used in Adium, but it is terribly complicated and
I can't figure out how to use it.
Does anybody have or know of a simple code sample that
uses libpurple?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我个人认为 Pidgin 的源代码很容易阅读。不过,还有更多 IM 客户端使用 libpurple,您可以查看 Wikipedia 了解更多信息细节。
I personally found the source code of Pidgin to be straightforward to read. There are many more IM clients that use libpurple, though, you can check Wikipedia for more details.
我以前在 bash 脚本中做过类似的事情。不幸的是,代码丢失了,但您可能希望将 dbus 视为解决方案的一部分。代码相对简单。
这个关于更新 pidgin 状态的页面可能是一个很好的开始观点。
对于您的应用程序,它可能就像以下一样简单:(
观看引用!)
请参阅 purple-远程(1)。
I've done this sort of thing in a bash script before. Unfortunately the code is lost, but you may want to look at dbus as a piece of the solution. The code was relatively straightforward.
This page on updating pidgin status might be a good starting point.
For your application, it might be as easy as:
(Watch the quoting!)
See purple-remote(1).
我与龙战斗^W不存在的文档,这似乎是合理的:-)
有时间将一些东西组合在一起,我认为可能值得快速检查一下。
http://koshinae.pastebin.com/t7UTReWt
http://koshinae.pastebin.com/HBQiwpDX -
发送 IM,标准输出被写回,
调用这个脚本
紫色答录机。
重要的是要知道,要使用内部 DBus 服务,
相同的 dbus 会话。我做了一个
在启动时启动会话的脚本
并导出 DBUS_SESSION_BUS_ADDRESS
在所有用户的 bashrc 中。感觉很hacky?:)
任何有更好的libpurple技能的人,请阻止我们! :-)
I fought through dragons^Wnonexistent documentations and it seems to be plausible:-)
Having some time to hack some stuff together, I think it may worth a quick check.
http://koshinae.pastebin.com/t7UTReWt
http://koshinae.pastebin.com/HBQiwpDX -
sends an IM, stdout is written back,
call this script
purple-answering-machine.
Important and good to know, that to use the internal DBus services,
the same dbus session. I made a
script that starts a session at boot
and exports DBUS_SESSION_BUS_ADDRESS
in all user's bashrc. Feels hacky?:)
Anyone with better skills with libpurple, please halp us out! :-)
您绝对应该查看 libpurple 源代码 (libpurple/example/nullclient.c) 中提供的 nullclient.c 。 c).它执行登录服务器并添加一些有用的回调。要发送消息,请将其添加到(例如)函数signed_on中:
You should definitely take a look into the nullclient.c provided in the libpurple sources (libpurple/example/nullclient.c). It performs logging into server and adds some useful callbacks. To send a message, add this to (for example) the function signed_on: