使用 libpurple 的好例子?

发布于 2024-09-11 08:40:19 字数 283 浏览 8 评论 0原文

我家里有一台旧机器,其中一个 这台机器的作用是检测特定的门是否在 房子刚刚开门或关门。

现在,我让那台机器在私人主页上发布了一条推文 推特帐户。

我现在想为这台机器提供自己的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蛮可爱 2024-09-18 08:40:19

我个人认为 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.

撩动你心 2024-09-18 08:40:19

我以前在 bash 脚本中做过类似的事情。不幸的是,代码丢失了,但您可能希望将 dbus 视为解决方案的一部分。代码相对简单。

这个关于更新 pidgin 状态的页面可能是一个很好的开始观点。

对于您的应用程序,它可能就像以下一样简单:(

purple-remote uri 'aim:goim?screenname=yourimhandle&message="front door open"'

观看引用!)

请参阅 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:

purple-remote uri 'aim:goim?screenname=yourimhandle&message="front door open"'

(Watch the quoting!)

See purple-remote(1).

呆萌少年 2024-09-18 08:40:19

我与龙战斗^W不存在的文档,这似乎是合理的:-)
有时间将一些东西组合在一起,我认为可能值得快速检查一下。

重要的是要知道,要使用内部 DBus 服务,

  1. 请在例如屏幕中运行它很长时间:),
  2. Purple-remote 应该运行在
    相同的 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.

Important and good to know, that to use the internal DBus services,

  1. run this in e.g. screen for a long time :),
  2. the purple-remote should be run in
    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! :-)

新雨望断虹 2024-09-18 08:40:19

您绝对应该查看 libpurple 源代码 (libpurple/example/nullclient.c) 中提供的 nullclient.c 。 c).它执行登录服务器并添加一些有用的回调。要发送消息,请将其添加到(例如)函数signed_on中:

PurpleConvIm im;
im.conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, "[email protected]");
purple_conv_im_send(&im, "open door");

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:

PurpleConvIm im;
im.conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, "[email protected]");
purple_conv_im_send(&im, "open door");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文