Skip to content

Instantly share code, notes, and snippets.

@jgrgt
Created October 15, 2010 09:03
Show Gist options
  • Save jgrgt/627881 to your computer and use it in GitHub Desktop.
Save jgrgt/627881 to your computer and use it in GitHub Desktop.
# This script connects to an account in your Pidgin and sends an IM message
# to one of your contacts. You can pass the message as the first command
# line argument to the script. The default message is "Poke!". Change the
# NAME, PROTOCOL and TO variables at the beginning of the script to your
# liking. Make sure the account is enabled in your Pidgin or the script
# will fail.
import dbus
import sys
# Change this
NAME = "john@gmail.com"
PROTOCOL = "prpl-jabber"
PURPLE_CONV_TYPE_IM = 1
TO = "alice@gmail.com"
if len(sys.argv) > 1:
message = sys.argv[1]
else:
message = "Poke!"
bus = dbus.SessionBus()
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
account = purple.PurpleAccountsFind(NAME, PROTOCOL)
conversation = purple.PurpleConversationNew(PURPLE_CONV_TYPE_IM, account, TO)
im = purple.PurpleConvIm(conversation)
purple.PurpleConvImSend(im, message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment