Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #coding:utf8
  2. '''\
  3. author: chenyan
  4. 自动转发短信
  5. '''
  6. import android
  7. import time
  8.  
  9. droid = android.Android()
  10. stop = False
  11.  
  12. def not_harass(sms_body):
  13. '''\
  14. 判断骚扰短信
  15. '''
  16. if '验证码' in sms_body:
  17. return True
  18. if '您' in sms_body\
  19. or '你好' in sms_body\
  20. or '尊敬的' in sms_body\
  21. or '长期' in sms_body\
  22. or '本公司' in sms_body\
  23. or '退订' in sms_body:
  24. print '判断为骚扰短信,未转发:',sms_body,'\n'
  25. return False
  26. return True
  27.  
  28. def do_transfer():
  29. '''\
  30. 获取未读短信,检查短信内容,转发,标记为已读
  31. '''
  32. global stop
  33. sms_id_list = droid.smsGetMessageIds(True).result
  34. for sms_id in sms_id_list:
  35. sms_body = droid.smsGetMessageById(sms_id)\
  36. .result['body']\
  37. .encode('utf8')
  38. if sms_body == 'stop':
  39. stop = True
  40. return
  41. if not_harass(sms_body):
  42. droid.smsSend('1××××××4201', sms_body)
  43. droid.smsMarkMessageRead(sms_id_list, True)
  44.  
  45. while not stop:
  46. do_transfer()
  47. time.sleep(1.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement