Dbus.Array (Reading pidgin messages from python)

367 Views Asked by At

I am trying to read a message on a pidgin window using python. I have read Pidgin how to and I using the following code:

purple.PurpleGetConversations()

and I get the following output:

dbus.Array([dbus.Int32(14414)], signature=dbus.Signature('i'))

I dont know how to access the elements of this dbus.Array

Best Regards

PD: I am interested in reading the messages, if there is a better way please let me know

Progress update: If anyone else is interested in this, I came up with an alternative solution. Pidgin leaves chat logs in ~/purple, from python you can open this files and use regex to read all msgs.

(If there is a more straigthforward way please tell me)

2

There are 2 best solutions below

0
On BEST ANSWER

I found it, Here is the resulting code:

    convID = purple.PurpleGetConversations()

    msgpos = purple.PurpleConversationGetMessageHistory(convID[0])[0]

    print purple.PurpleConversationMessageGetMessage(msgpos) 

This will print the last message from an open chat

2
On

You need to use PurpleConversationGetChatData method, it takes conversation id as a parameter (14414 in your case).

I have javascript client generated from introspection xml, it might be helpful addition to a dbus documentation - https://github.com/sidorares/node-pidgin/blob/master/index.js