From 22e3e63895ee333fce68ed6f4bc9d7f5bcc50d83 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Thu, 10 Mar 2022 09:18:37 +0100 Subject: [PATCH] add new filter to sms --- main.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index c94478b..2daae9f 100644 --- a/main.py +++ b/main.py @@ -110,22 +110,25 @@ def handle_sms(sms): date = str(sms.time)[0:10] if date == str(datetime.date.today()): logger.info("this sms is for today") - logger.info("try to extract the otp") - pattern = r'\d{6,8}' - # if re.match(pattern, sms.text): - match = re.search(pattern, sms.text) - otp = match.group(0) - logger.info("otp is " + otp) - commandor.send_otp(otp) - # wait for the sms for 20 seconds - global is_finished - while not is_finished: - time.sleep(2) - is_finished = True - global current_gsm_modem - if current_gsm_modem: - logger.info("will close used modem") - current_gsm_modem.close() + if "rendez-vous" in sms.text: + logger.info("try to extract the otp") + pattern = r'\d{6,8}' + # if re.match(pattern, sms.text): + match = re.search(pattern, sms.text) + otp = match.group(0) + logger.info("otp is " + otp) + commandor.send_otp(otp) + # wait for the sms for 20 seconds + global is_finished + while not is_finished: + time.sleep(2) + is_finished = True + global current_gsm_modem + if current_gsm_modem: + logger.info("will close used modem") + current_gsm_modem.close() + else: + logger.info("the sms is not for RDV") else: logger.info("the sms is not for today")