Advertisement
Azelphur

Untitled

Apr 18th, 2012
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. #
  4. # Azelphur's quick and ugly Bitcoin-OTC Pidgin auto auth script
  5. # Usage: run the script, enter your GPG password, type ;;eauth YourNick, be happy.
  6. # License: GPL
  7. #
  8.  
  9. VOICEME = True # You can change this if you like
  10.  
  11. import dbus
  12. import gobject
  13. import re
  14. import urllib2
  15. import gnupg
  16. import sys
  17. from getpass import getpass
  18. from dbus.mainloop.glib import DBusGMainLoop
  19.  
  20. class PidginOTC:
  21.     def __init__(self):
  22.         self.msg = re.compile('^Request successful for user .+?, hostmask .+. Get your encrypted OTP from (http:\/\/bitcoin-otc.com\/otps\/.+)$')
  23.         self.gpg = gnupg.GPG()
  24.         self.passphrase = getpass("Enter your GPG passphrase: ")
  25.         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
  26.         bus = dbus.SessionBus()
  27.         obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
  28.         self.purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
  29.  
  30.         bus.add_signal_receiver(self.ReceivedImMsg,
  31.                                 dbus_interface="im.pidgin.purple.PurpleInterface",
  32.                                 signal_name="ReceivedImMsg")
  33.  
  34.         loop = gobject.MainLoop()
  35.  
  36.         loop.run()
  37.  
  38.     def ReceivedImMsg(self, account, sender, message, conversation, flags):
  39.         if sender == 'gribble':
  40.             match = self.msg.match(message)
  41.             if match:
  42.                 print 'recieved request from gribble, grabbing', match.group(1)
  43.                 data = urllib2.urlopen(match.group(1)).read()
  44.                 decrypted = str(self.gpg.decrypt(data, passphrase=self.passphrase))
  45.                 reply = ";;gpg everify "+decrypted
  46.                 print 'replying with', reply
  47.                 self.purple.PurpleConvImSend(self.purple.PurpleConvIm(conversation), reply)
  48.                 if VOICEME:
  49.                     self.purple.PurpleConvImSend(self.purple.PurpleConvIm(conversation), ";;voiceme")
  50.  
  51. PidginOTC()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement