0

In my application I want to send notifications to users through their pidgin internet messanger using python 2.4.

Does anyone can show some light on how this can be done?

Linger
  • 14,942
  • 23
  • 52
  • 79
shiva
  • 2,674
  • 4
  • 23
  • 37
  • Do you want to send a message to the user on the current pc, or to send a message from him to another user? Or to display just some kind of notification? – Tisho Jul 06 '12 at 13:55
  • @Tisho I want to send message from him to another user – shiva Jul 06 '12 at 14:11

1 Answers1

2

Here is an example code using dbus (with Python 2.7, cannot test it with 2.4), but the problem is that it opens a conversation window. I haven't find a way to hide/close/minimize the window.

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 email")
conv_im = purple_int.PurpleConvIm(conv)
purple_int.PurpleConvImSend(conv_im, "This is your message")
Tisho
  • 8,320
  • 6
  • 44
  • 52
  • can we implement this like sending message from a server to user – shiva Jul 06 '12 at 15:12
  • As long as you have pidgin installed, and an account set up - I guess so. You'll just need to start it, so it will probably need a graphic session...haven't tested it in such environment. – Tisho Jul 06 '12 at 15:14