Skip to content

Instantly share code, notes, and snippets.

@morrah
Last active September 26, 2018 14:08
Show Gist options
  • Save morrah/c4e770934243515b26b2185abe07d4bf to your computer and use it in GitHub Desktop.
Save morrah/c4e770934243515b26b2185abe07d4bf to your computer and use it in GitHub Desktop.
qpython script for sms forwarding
# TODO: subscribe SMS_RECEIVED_ACTION instead of polling
import androidhelper
import sys
from time import sleep
FORWARD_TO = '+79218887766'
LIMIT = 3
counter = 0
droid = androidhelper.Android()
while True:
sleep(5)
sms_list = droid.smsGetMessages(True).result
for sms in sms_list:
print (sms)
droid.smsMarkMessageRead([int(sms['_id'])], True)
droid.smsSend(FORWARD_TO, '%s: %s' % (sms['address'], sms['body']))
counter += 1
if counter >= LIMIT:
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment