Archived:Delete Spam SMS using PySymbian
Have you receive any SMS at midnight while you are in deep sleep? Have you receive any SMS while you are important meeting and you lose your concentration? Are you receiving SMSes which are no use at all for you? Are you receiving SMS with the irritating contents in it? If any of the above question’s answer is YES then you are suffering of the SPAM SMSes. Please see the below contents about SMS spam from the popular site “Wikipedia”
“Fighting SMS spam is complicated by several factors, including the lower rate of SMS spam (compared to more abused services such as Internet email) has allowed many users and service providers to ignore the issue, and the limited availability of mobile phone spam-filtering software”
The SMS spam rate is lower but it may increase as the mobile user increases throughout the world. It is useless to wait from the network service provider to take necessary action on this issue when we have lots of programming weapons in our mobile to fight against the SMS SPAM. One can come out with more dedicated work and continuous efforts on this issue. I have made a small effort here to avoid SMS spam using a simple python program. Let’s see what’s there inside.
How the program works
The program is very simple. I have given two options for SMS spam removal. One is to add a Name/Number into the SPAM list and another is to run SPAM SMS. As soon as the name/number you add in the SPAM list, the name/number is saved into a text file in the mobile storage device. The text file will be created automatically if not exists. Now run the second option to start SPAM SMS. It will monitor every incoming SMS, will check the address of sender, compare it with each value in the text file and if it doesn’t match with any values in the text file then it will be welcomed into inbox. But, if the sender is in our spammer list, it will be punishment by deleting the SMS. Before deleting the SMS, a log is created showing which spam SMSes are deleted so that you can review it whenever you wish.
You need to install PySymbian in your mobile in order to run the program. There are several articles available about how to download and install it. Once you do this create a simple text file “vote.txt” on the path shown in the program. Create four lines in the program with initial values as 0.
Tested on device
This python program is tested on Nokia 5230.
Various options available
I have used simple text file reading or writing the spam SMS list. However one can use e32db or e32dbm to make it more structured.
#import necessary libraries
# setting the application title
appuifw.app.title = u"SPAM SMS Blocker"
mylist = [u"Add a SPAM Number/Name",u"Start SPAM Blocker",u"Exit"]
spam_adddress = box.address(msg_id)
f=open('e:\data\python\spammer.txt','r') #opens a file into read/write mode
# print "Msg Received from ",box.address(msg_id)
if data.strip() == spam_adddress.strip():
print >> fs,"Spam Message deleted from : ",spam_adddress
index = appuifw.popup_menu(mylist,u"Select")
spammer = appuifw.query(u"Type SPAM Number/Name:", "text")
f=open('e:\data\python\spammer.txt','a+') #opens a file into read/write mode
print >> f,spammer
box = inbox.Inbox()
appuifw.app.exit_key_handler = quit
print "SPAM SMS Filter is ON"
app_lock = e32.Ao_lock()
Adding spam number from menu
SPAM filter is ON
After spam filter is on script will automatically delete the SMS received from the spammer saved in our spam list.
Sample log file of SPAM delete SMS