Send Notification to pidgin via python 2.4
题
In my application I want to send notifications to users through their pidgin internet messanger using python 2.4.
Does anyone can show some light on how this can be done?
解决方案
Here is an example code using dbus (with Python 2.7, cannot test it with 2.4), but the problem is that it opens a conversation window. I haven't find a way to hide/close/minimize the window.
import dbus
session_bus = dbus.SessionBus()
purple_obj = session_bus.get_object("im.pidgin.purple.PurpleService",
"/im/pidgin/purple/PurpleObject")
purple_int = dbus.Interface(purple_obj,
"im.pidgin.purple.PurpleInterface")
my_account_id = purple_int.PurpleAccountsGetAllActive()[0] # or some other account from yours
conv = purple_int.PurpleConversationNew(1, my_account_id, "recipient's email")
conv_im = purple_int.PurpleConvIm(conv)
purple_int.PurpleConvImSend(conv_im, "This is your message")
不隶属于 StackOverflow