如果我们有用于msn的Pidgin代码:
#!/usr/bin/python
import sys, dbus, gobject;
bus = dbus.SessionBus()
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
msnusers = (["someon@hotmail.com", "someoneelse@msn.com", "thatguy@hotmail.com", "somethingoranother@hotmail.com"])
for msn_id in msnusers:
account_id = purple.PurpleAccountsGetAllActive()[0]
conversation = purple.PurpleConversationNew(1, account_id, msn_id)
im = purple.PurpleConvIm(conversation)
purple.PurpleConvImSend(im, 'hi')
我需要用同样的方式为whatsapp但我却找不到它。
我试了一下,但它不工作:
#!/usr/bin/python
import sys, dbus, gobject;
bus = dbus.SessionBus()
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
wpusrs = str(96895605520)
for i in wpusrs:
account = purple.PurpleAccountsGetAllActive()
conversation = purple.PurpleConversationNew(1,account,i)
im = purple.PurpleConvIm(conversation)
purple.PurpleConvImSend(im,'hi')
感谢大家的重播…我找到我需要的了
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 number")
conv_im = purple_int.PurpleConvIm(conv)
purple_int.PurpleConvImSend(conv_im, "This is your message")