From 4e8b4105376855fc760123ffbe102864f70f7a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Sun, 6 Dec 2020 20:40:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=92=AD=E6=8A=A5=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index a0fbd1d..eadbd54 100644 --- a/server.js +++ b/server.js @@ -10,7 +10,22 @@ const app = express() app.get('/sms', (req, res) => { const params = req.query console.log("收到请求,参数:%s", params) - let text = "收到" + params.title.replace(" 86", "") + ",短信内容:" + params.msg + let title = params.title + // 去掉大区号 + // .replace("86", "") + // 去掉空格 + // .replace(" ", "") + // 如果发信人不是手机号,不播报 + let phone = title.match(/[0-9]/g).join("") + if (phone.startsWith('86')){ + phone = phone.substr(2) + } + console.log('发信人:', phone) + if (phone.length !== 11 && phone.length !== 5) { + console.log('发信人不是手机号,拒绝处理') + return 'pass' + } + let text = "收到" + title + ",短信内容:" + params.msg // 登录小米账号 const miClient = new XiaoAi(user, pwd) // 让小爱同学说话