我正在使用pidgin dbus api通过编写以下python代码片段来打印我的gtalk好友的名字及其状态:
import dbus
# Initiate a connection to the Session Bus
bus = dbus.SessionBus()
# Associate Pidgin's D-Bus interface with Python objects
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
# Iterate through every active account
for acctID in purple.PurpleAccountsGetAllActive():
for buddy in purple.PurpleFindBuddies(acctID,""):
print purple.PurpleBuddyGetName(buddy),'Online' if purple.PurpleBuddyIsOnline(buddy) else 'Offline'
在Pidgin中,当我将鼠标悬停在某个特定伙伴上时,它还会显示该伙伴的资源字符串,例如 gtalk,android等。 ..它告诉我用户登录的资源从
有没有办法使用pidgins dbus api或其他方式获取此资源字符串?
请帮助 谢谢
答案 0 :(得分:0)
您可以使用wiki page:
中的脚本#!/usr/bin/env python
def my_func(account, sender, message, conversation, flags):
print sender, "said:", message
import dbus, gobject
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(my_func,
dbus_interface="im.pidgin.purple.PurpleInterface",
signal_name="ReceivedImMsg")
loop = gobject.MainLoop()
loop.run()
sender
这里会像这样:
'example@gmail.com/gmail.XXXXXXXX'用于gtalk或
其他im的'example@gmail.com/XXXXXXXX',其中X是十六进制值。