Guest
Public paste!

Untitled

By: a guest | Mar 20th, 2010 | Syntax: Python | Size: 1.61 KB | Hits: 106 | Expires: Never
Copy text to clipboard
  1. import Skype4Py, datetime, re, httplib
  2. from urllib import urlencode
  3.  
  4. skype = Skype4Py.Skype()
  5. skype.Attach()
  6.  
  7. def message(msg, status):
  8.     print 'msg: '+ msg.Body+':'+status
  9.     print 'user: '+ msg.FromHandle
  10.     if status == 'SENDING' or status == 'READ':
  11.         if re.search('.date', msg.Body):
  12.             print '>> find date!'
  13.             today = datetime.date.today()
  14.             skype.SendMessage(msg.FromHandle, 'Today is '+str(today))
  15.         if re.search('.md5', msg.Body):
  16.             md5s = msg.Body.split('md5')
  17.             md5 = md5s[1].strip()
  18.             conn = httplib.HTTPConnection("www.md5.rednoize.com")
  19.             conn.request("GET", "?q="+ md5)
  20.             response = conn.getresponse()
  21.             data = response.read()
  22.             result = re.findall('<div id="result" >(.+?)</div>', data)
  23.             skype.SendMessage(msg.FromHandle, 'MD5: '+str(result[0]))
  24.             conn.close()
  25.         if re.search('.send', msg.Body):
  26.             send = msg.Body.strip('send')
  27.             number = send.split(' ')[0]
  28.             text = send.split(' ')[1]
  29.             sendname = 'Secret'
  30.             params = urlencode({'action': 'send','numTo': int(number), 'text': str(text), 'numFrom': str(sendname), 'numFromNr': str(number)})
  31.             headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
  32.             conns = httplib.HTTPConnection("smsbox.lv")
  33.             conns.request("POST", "/smsbox.sender.proces?action=send", params, headers)
  34.             skype.SendMessage(msg.FromHandle, 'Message Sent to '+int(number))
  35.             conns.close()
  36.  
  37.  
  38.  
  39.  
  40.  
  41. skype.OnMessageStatus = message
  42.  
  43. while(True): pass