-2

如果我们有这个用于 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')

请帮助我:'(

4

1 回答 1

0

谢谢大家重播...我找到了我需要的东西

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")
于 2014-03-27T20:57:22.330 回答