Advertisement
here2share

# s60_block_caller_ultra.py

Feb 14th, 2020
1,491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # s60_block_caller_ultra.py
  2.  
  3. # To very much block blacklisted callers from also leaving a voice
  4. # message, this app will instantly hang up upon answering therefore
  5. # prevent occupying the limited allotment.
  6.  
  7. import appuifw,e32,telephone,time,messaging,contacts,re
  8.  
  9. regex = r'''\+?[0-9]{7,10}'''
  10.  
  11. def quit(): app_lock.signal()
  12. appuifw.app.exit_key_handler = quit
  13. app_lock=e32.Ao_lock()
  14.  
  15. cDB = contacts.open()
  16. entry = cDB.find('ZZZZZZ block') ###
  17.  
  18. blacklist = entry[0].find()
  19. blacklist = str(blacklist)
  20. blacklist = re.findall(regex, blacklist)
  21. blacklist = list(set(blacklist))
  22.  
  23. def stateChange((callState, number)):
  24.     print "%d:%02d" % time.localtime()[3:5],"callState",callState
  25.     if callState == telephone.EStatusRinging:
  26.         if number == "":
  27.             print "Unknown Number"
  28.             return
  29.         else:
  30.             print "Call From "+number
  31.             if number in blacklist:
  32.                 telephone.incoming_call()
  33.                 while 1:
  34.                     try:
  35.                         telephone.answer()
  36.                         break
  37.                     except:
  38.                         pass
  39.                 while 1:
  40.                     try:
  41.                         telephone.hangup()
  42.                         break
  43.                     except:
  44.                         pass
  45.  
  46. telephone.call_state(stateChange)
  47.  
  48. print 's60 Block Caller Ultra *** Commenced...'
  49. app_lock.wait()
  50. print "*** Exited."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement