Give your boss the illusion of managing you… with pidgin and dbus

30Jun09

Dilbert.com

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 :P .

#!/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()
About these ads


32 Responses to “Give your boss the illusion of managing you… with pidgin and dbus”

  1. Awesome. So nice. :)

  2. just great.

  3. 3 Baishampayan Ghose

    Nice. You should also tell people that the script expects a file called “questions” in the current directory with a question on each line :)

  4. 4 reddit

    Logs or it didn’t happen

  5. 8 bigon

    A telepathy version of the script someone?

  6. Logs or it didn’t happen..

  7. You should modify the script so that you can see the results of your fun :-)

  8. 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…

  9. Thanks for introducing me to the WTFPL.

  10. carbon dating or it didnt happen

  11. Not as cool as Python but I made an AppleScript version in case anyone was interested: http://www.tannr.com/?p=6

  12. 18 twomonkeysayoyo

    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.

  13. 19 ygd-coder

    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()

  14. Sup3rkiddo, you’ve grown up now… *sigh*
    Awesome, btw :D

  15. 23 Dieter

    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 ;)


  1. 1 Tanner's Website » Send preset messages automatically with Adium and AppleScript
  2. 2 Give your boss the illusion of managing you… with pidgin and dbus « Netcrema - creme de la social news via digg + delicious + stumpleupon + reddit
  3. 3 Josh Mather » Bookmarks for July 6th through August 11th
  4. 4 Kevin Haines (khaines) 's status on Wednesday, 12-Aug-09 02:46:39 UTC - Identi.ca
  5. 5 Squirrel Hacker » Daily Digest for August 12th
  6. 6 Georg (isnochys) 's status on Friday, 14-Aug-09 07:27:58 UTC - Identi.ca
  7. 7 Dreaming When Awake - I wish I could stop wasting my time! » Blog Archive » Send automatic status updates to your boss with Python, iCalendar, xmpp and email
  8. 8 Catchup blogging… » J’s blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: