def send_sms(number, text): sms = SMS() sms.number = number sms.text = text sms.state = SMS.STATE_NEW sms.received = False sms.save() add_processor_jobs(sms)
def recv_sms(): new = False for message in device.get_message_list(): number = message.number date = message.date text = message.text if not SMS.objects.filter(date=date, number=number, text=text).exists(): sms = SMS() sms.number = number sms.text = text sms.date = date sms.state = SMS.STATE_NEW sms.received = False sms.save() add_processor_jobs(sms) new = True device.del_message(message) return new