Give your boss the illusion of managing you… with pidgin and dbus
30Jun09
Oh yeah!. With the power of DBus and libpurple APIs it is possible to give your boss the illusion of managing you. Just run the following script (under WTFPL). Tested with jabber accounts in a live office environment
.
#!/usr/bin/env python
# By Sudharshan S, released under WTFPL
import dbus
import gobject
import time
class PointyHairedBoss:
def __init__(self, boss_id, source, frequency=30):
self.boss_id = boss_id
self.source = source
self.frequency = frequency
bus = dbus.SessionBus()
_pidgin_proxy = bus.get_object("im.pidgin.purple.PurpleService", \
"/im/pidgin/purple/PurpleObject")
self.purple = dbus.Interface (_pidgin_proxy, "im.pidgin.purple.PurpleService")
# FIXME:
account_id = self.purple.PurpleAccountsGetAllActive()[0]
self.boss_conversation = self.purple.PurpleConversationNew(1, account_id, self.boss_id)
self.boss_im = self.purple.PurpleConvIm(self.boss_conversation)
print self.boss_im
def start_nonsense(self):
question_list = open(self.source)
for q in question_list:
self.purple.PurpleConvImSend(self.boss_im, q)
time.sleep(self.frequency)
if __name__ == "__main__":
# Change the jabber id and the path to your questions, with an optional frequency
o = PointyHairedBoss("foo@gmail.com", "questions")
o.start_nonsense()
Filed under: FOSS and Linux, programming, Python, Rants, Tips | 32 Comments
Tags: comicstrip, dbus, dilbert, im, moronity, pidgin, pointyhairedboss, purple, Python, snippet, wally, wtfpl

Awesome. So nice.
just great.
Nice. You should also tell people that the script expects a file called “questions” in the current directory with a question on each line
Logs or it didn’t happen
I don’t have logs but I was hung upside down from the ceiling when my boss caught the act…
pics or it didnt happen
wtf? is this 4chan now?
A telepathy version of the script someone?
Logs or it didn’t happen..
You should modify the script so that you can see the results of your fun
It opens up an IM window in pidgin anyway. So you do get to see the replies
That’s actually pretty brilliant… too bad my boss sits right around the corner from me. He’d come over and answer the questions in person…
Thanks for introducing me to the WTFPL.
Its also a valid Free Software license
Compatible with the GPL too i believe.
carbon dating or it didnt happen
Not as cool as Python but I made an AppleScript version in case anyone was interested: http://www.tannr.com/?p=6
hell I did this in 10 minutes with applescript and adium. Funny thing is Adium uses the pidgin libraries, yet is SO MUCH THE MORE AWESOME.
Here is some of my output…
Would you like me to insert the screen and erase the bell?
Don’t you think I should blow on the server to rotate the document?
Can I populate the jack if I login to the application?
Unfortunately it seems like he installed an 8ball application to answer me…
Concentrate and ask again.
It is decidedly so.
Ask again later.
Here’s the code for an eight-ball responder.
#!/usr/bin/python
# By Vineel A, released under WTFPL
import dbus
import gobject
import time
import random
from dbus.mainloop.glib import DBusGMainLoop
def recieve(account, sender, message, conversation, flags):
## print ‘Account: ‘, account
## print ‘Sender: ‘, sender
## print ‘Message: ‘, message
## print ‘Conversation:’, conversation
## print ‘Flags: ‘, flags
answers = ['As I see it, yes.',
'It is certain.',
'It is decidedly so.',
'Most likely.',
'Outlook good.',
'Signs point to yes.',
'Without a doubt.',
'Yes.',
'Yes - definitely.',
'You may rely on it.',
'Reply hazy, try again.',
'Ask again later.',
'Better not tell you now.',
'Cannot predict now.',
'Concentrate and ask again.',
"Don't count on it.",
'My reply is no.',
'My sources say no.',
'Outlook not so good.',
'Very doubtful.']
answer = random.choice(answers)
bus = dbus.SessionBus()
obj = bus.get_object(‘im.pidgin.purple.PurpleService’,
‘/im/pidgin/purple/PurpleObject’)
purple = dbus.Interface(obj, ‘im.pidgin.purple.PurpleInterface’)
account_id = purple.PurpleAccountsGetAllActive()[0]
boss_conversation = purple.PurpleConversationNew(1, account_id, sender)
boss_im = purple.PurpleConvIm(boss_conversation)
time.sleep(1)
purple.PurpleConvImSend(boss_im, answer)
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(recieve,
dbus_interface=’im.pidgin.purple.PurpleInterface’,
signal_name=’ReceivedImMsg’)
loop = gobject.MainLoop()
loop.run()
Praise me for posting this to reddit: http://www.reddit.com/r/programming/comments/99hed/give_your_boss_the_illusion_of_managing_you_with/
hi reddit.. thanks
Sup3rkiddo, you’ve grown up now… *sigh*
Awesome, btw
Not to be pointing out the obvious but wouldn’t it be easier to write these as Pidgin and Adium plugins?
True, but more brownie points are reserved for not-so-straightforward solutions when it comes to annoying your bosses