diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-03-23 04:30:15 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-03-23 04:30:15 +0300 |
commit | 2df9c65eb05ee3c20ae9fe632519a81df3e7c319 (patch) | |
tree | a94c9b19bc9f8732b233856087ba728fda6200c3 | |
parent | 94f02f64d5dc2091d21037815a8f946446235596 (diff) |
sms handling upd
-rw-r--r-- | main.py | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -12,15 +12,25 @@ trusted_phone = '' def sms_handler(sms: SMS, api: WebAPI): global trusted_phone - # print(f'from: {sms.phone}') - # print(f'text: {sms.text}') + print(f'from={sms.phone}, date={sms.date}, text={sms.text}') + + # just in case + phone = sms.phone + if phone.startswith('8') and len(phone) == 11: + phone = '+7' + phone[1:] + elif phone.startswith('7') and len(phone) == 11: + phone = '+' + phone + + if phone == trusted_phone: + print('this is a trusted phone, processing...') - if sms.phone == trusted_phone: text = sms.text.lower().strip() if text == 'you shall reboot!': + print('bye bye...') api.reboot() elif text == 'yo, get me some status': + print('gathering status') info = api.device_information() signal = api.device_signal() buf = [] @@ -38,9 +48,11 @@ def sms_handler(sms: SMS, api: WebAPI): api.send_sms(phone=trusted_phone, content=buf) elif text == 'switch it off': + print('switching it off') api.dataswitch(False) elif text == 'switch it on': + print('switching it on') api.dataswitch(True) |