add new filter to sms
This commit is contained in:
@@ -110,22 +110,25 @@ def handle_sms(sms):
|
|||||||
date = str(sms.time)[0:10]
|
date = str(sms.time)[0:10]
|
||||||
if date == str(datetime.date.today()):
|
if date == str(datetime.date.today()):
|
||||||
logger.info("this sms is for today")
|
logger.info("this sms is for today")
|
||||||
logger.info("try to extract the otp")
|
if "rendez-vous" in sms.text:
|
||||||
pattern = r'\d{6,8}'
|
logger.info("try to extract the otp")
|
||||||
# if re.match(pattern, sms.text):
|
pattern = r'\d{6,8}'
|
||||||
match = re.search(pattern, sms.text)
|
# if re.match(pattern, sms.text):
|
||||||
otp = match.group(0)
|
match = re.search(pattern, sms.text)
|
||||||
logger.info("otp is " + otp)
|
otp = match.group(0)
|
||||||
commandor.send_otp(otp)
|
logger.info("otp is " + otp)
|
||||||
# wait for the sms for 20 seconds
|
commandor.send_otp(otp)
|
||||||
global is_finished
|
# wait for the sms for 20 seconds
|
||||||
while not is_finished:
|
global is_finished
|
||||||
time.sleep(2)
|
while not is_finished:
|
||||||
is_finished = True
|
time.sleep(2)
|
||||||
global current_gsm_modem
|
is_finished = True
|
||||||
if current_gsm_modem:
|
global current_gsm_modem
|
||||||
logger.info("will close used modem")
|
if current_gsm_modem:
|
||||||
current_gsm_modem.close()
|
logger.info("will close used modem")
|
||||||
|
current_gsm_modem.close()
|
||||||
|
else:
|
||||||
|
logger.info("the sms is not for RDV")
|
||||||
else:
|
else:
|
||||||
logger.info("the sms is not for today")
|
logger.info("the sms is not for today")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user