Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

PurpleConvImSend doesn't work on group ...

2010-10-12
2013-01-14
  • Nathan Hunter
    Nathan Hunter
    2010-10-12

    I'm using a python script with the dbus interface to send messages to my buddies. It works perfectly, except it won't send messages to group conversations. There's no error message or exception, it just silently fails to do what it's meant to do. I've posted my script below in case I've made a mistake in it. Is PurpleConvImSend not meant to work with group chats? Should I be using a different function? Any help/suggestions are appreciated.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    #!/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")
    for conv in purple.PurpleGetConversations():
        user = purple.PurpleConversationGetName(conv)
        name = purple.PurpleBuddyGetAlias(purple.PurpleFindBuddy(purple.PurpleConversationGetAccount(conv), user))
        if len(sys.argv) == 1:
            print user + '|' + name
        elif user == sys.argv[1]:
            purple.PurpleConvImSend(purple.PurpleConvIm(conv), sys.argv[2])
            print "Sending \""+sys.argv[2]+"\" to "+sys.argv[1]
    
     
  • Etan Reisner
    Etan Reisner
    2010-10-26

    PurpleConvImSend will only send to an IM conversation (two-person). In pidgin terms that's what IM means. To send to chats you would need to get the PurpleConvChat data from the conversation and use PurpleConvChatSend.

     
  • Nathan Hunter
    Nathan Hunter
    2010-10-26

    Thanks for the help! I'm surprised PurpleConvImSend isn't mentioned on this page. Is there a more comprehensive list of functions available via Dbus?

    I've now modified the script to work with group chats. Here it is for future reference:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    #!/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")
    for conv in purple.PurpleGetConversations():
        user = purple.PurpleConversationGetName(conv)
        name = purple.PurpleBuddyGetAlias(purple.PurpleFindBuddy(purple.PurpleConversationGetAccount(conv), user))
        if len(sys.argv) == 1:
            print user + '|' + name
        elif user == sys.argv[1]:
            if purple.PurpleConversationGetType(conv) == 1:
                purple.PurpleConvImSend(purple.PurpleConvIm(conv), sys.argv[2])
            elif purple.PurpleConversationGetType(conv) == 2:
                purple.PurpleConvChatSend(purple.PurpleConvChat(conv), sys.argv[2])
            print "Sending \""+sys.argv[2]+"\" to "+sys.argv[1]
    
     
  • Etan Reisner
    Etan Reisner
    2010-10-29

    The DBus api is more-or-less just the C api, so the C api documentation is the resource. The howto is a "getting started" guide not a comprehensive listing. It should also be possible to introspect a running pidgin via the normal DBus introspection system to discover the API.