优化播报逻辑
This commit is contained in:
parent
ce4e7cdc44
commit
4e8b410537
17
server.js
17
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)
|
||||
// 让小爱同学说话
|
||||
|
Loading…
Reference in New Issue
Block a user