Advertisement
Azelphur

Bitcoin-OTC Auto login with pidgin

Apr 18th, 2012
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import dbus
  3. import gobject
  4. import re
  5. import urllib2
  6. import gnupg
  7. import sys
  8. from getpass import getpass
  9. from dbus.mainloop.glib import DBusGMainLoop
  10.  
  11. class PidginOTC:
  12.     def __init__(self):
  13.         self.msg = re.compile('^Request successful for user .+?, hostmask .+. Get your encrypted OTP from (http:\/\/bitcoin-otc.com\/otps\/.+)$')
  14.         self.gpg = gnupg.GPG()
  15.         self.passphrase = getpass("Enter your GPG passphrase: ")
  16.         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
  17.         bus = dbus.SessionBus()
  18.         obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
  19.         self.purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
  20.  
  21.         bus.add_signal_receiver(self.ReceivedImMsg,
  22.                                 dbus_interface="im.pidgin.purple.PurpleInterface",
  23.                                 signal_name="ReceivedImMsg")
  24.  
  25.         loop = gobject.MainLoop()
  26.  
  27.         loop.run()
  28.  
  29.     def ReceivedImMsg(self, account, sender, message, conversation, flags):
  30.         if sender == 'gribble':
  31.             match = self.msg.match(message)
  32.             if match:
  33.                 print 'recieved request from gribble, grabbing', match.group(1)
  34.                 data = urllib2.urlopen(match.group(1)).read()
  35.                 decrypted = str(self.gpg.decrypt(data, passphrase=self.passphrase))
  36.                 reply = ";;gpg everify "+decrypted
  37.                 print 'replying with', reply
  38.                 self.purple.PurpleConvImSend(self.purple.PurpleConvIm(conversation), reply)
  39.  
  40. PidginOTC()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement