Example #1
0
    delete_bulk_sms()

if opts.delete_last or opts.delete_msg:
    if opts.delete_last:
        msgid = droid.smsGetMessageIds(False).result[0]
    else:
        msgid = int(opts.delete_msg)
    print 'Deleting msg', msgid, 
    # droid.smsDeleteMessage(msgid)
    print '...done'
    exit(0)

if opts.bulk_sms_show:
    msgs = [m for m in droid.smsGetMessages(False).result if is_bulk_sms(m)]
elif opts.num_msgs:
    # num_msgs implies get "read" messages
    msgids = droid.smsGetMessageIds(False).result[:opts.num_msgs]
    msgs = [droid.smsGetMessageById(msgid).result for msgid in msgids]
else:
    msgs = droid.smsGetMessages(not opts.read).result

for i, msg in enumerate(msgs):
    print '[{id} {alpha}] {num}: {msg}'.format(id=msg['_id'],
                                               alpha=chr(ord('a')+i),
                                               num=num_to_name(msg['address']),
                                               msg=msg['body'])

if not opts.dont_mark and not opts.read and not opts.num_msgs and not opts.bulk_sms_show:
    droid.smsMarkMessageRead([msg['_id'] for msg in msgs], True)

Example #2
0
File: sms.py Project: ngkabra/asms
            except ValueError:
                choice = None
        return names[choice]


if opts.replyto or opts.ReplyToLast:
    if opts.ReplyToLast:
        msgid = droid.smsGetMessageIds(False).result[0]
    else:
        try:
            msgid = int(opts.replyto)
        except ValueError:
            "maybe it is an relative alphabet"
            relid = ord(opts.replyto) - ord("a")
            msgid = droid.smsGetMessageIds(False).result[relid]
    msg = droid.smsGetMessageById(msgid).result
    to_num = msg["address"]
else:
    to_num = opts.to or opts.phone


if not to_num:
    print "No recipient specified"
    exit(1)

recipients = [pick_mobile(num) for num in to_num.split(",")]

msg = " ".join(args) or ""

if opts.forward:
    "Add this name+number to the sms msg"