-2

if we have this code for Pidgin used for msn :

#!/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')

I need use same way for whatsapp but I can't find it how

I try this but its not work :

#!/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')

Pliz Help me :'(

  • can you please be more detailed than just 'its not work'. Does it crash? Do you get an error? what parts of the code fail? – drez90 Mar 26 '14 at 20:06
  • Ignoring any functional details (we can get to those in a moment) you should pay attention to the differences between the original `account_id = ...` line and your `account = ...` line. The differences are material. Additionally, depending on the first account to be of the right type is asking to get it wrong. – Etan Reisner Mar 26 '14 at 21:41
  • Also I don't think your loop does what you expect it to unless you intend for it to operate over each digit in that number individually. And that's even assuming that the whatsapp support in pidgin/libpurple uses bare numerical strings as contact IDs. – Etan Reisner Mar 26 '14 at 22:03

1 Answers1

0

Thank you All for replay ... I found what I need

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")