view link2contact.py @ 0:d31fcb953080 default tip

A quick script which will allow you to add a link to someone via kopete.
author darius@inchoate.localdomain
date Mon, 19 Nov 2007 23:28:23 +1030
parents
children
line wrap: on
line source

#!/usr/bin/env python

import sys
import dcopext
import subprocess

if (len(sys.argv) < 2):
	sys.stderr.write("Bad usage:\n")
	sys.stderr.write(sys.argv[0] + " url [url] [url]\n")
	sys.exit(1)
	
dcopClient = dcopext.DCOPClient()
assert(dcopClient.attach())
kopete = dcopext.DCOPApp('kopete', dcopClient)
ok, contacts = kopete.KopeteIface.reachableContacts()
assert(ok)

print contacts
cmd = ['kdialog', '--menu', 'Please choose a contact']
for c in contacts:
	print "Adding " + str(c)
	cmd.append(str(c))
	cmd.append(str(c))

print cmd
c = subprocess.Popen(cmd, stdout=subprocess.PIPE)
answer = c.communicate()
name = answer[0].strip() 
print name
assert(c.wait() == 0)

print "Looking up " + name
ok, accts = kopete.KopeteIface.contactsForDisplayName(name)
assert(ok)
for a in accts:
	print " |" + a + "| ",
print


msg = ""
for a in sys.argv[1:]:
	msg = msg + a + "\n"
	
ok, remsg = kopete.KopeteIface.messageContact(accts[0], msg)
assert(ok)
print "Got - " + remsg