2020-12-05 09:44:51 +08:00
|
|
|
const express = require('express')
|
|
|
|
const XiaoAi = require('xiaoai-tts')
|
|
|
|
|
|
|
|
// 输入小米账户名,密码
|
|
|
|
const user = process.env.MIUSER
|
|
|
|
const pwd = process.env.MIPWD
|
|
|
|
|
|
|
|
const app = express()
|
|
|
|
|
|
|
|
app.get('/sms', (req, res) => {
|
|
|
|
const params = req.query
|
|
|
|
console.log("收到请求,参数:%s", params)
|
|
|
|
let text = "收到" + params.title.replace(" 86", "") + ",短信内容:" + params.msg
|
2020-12-06 20:08:06 +08:00
|
|
|
// 登录小米账号
|
|
|
|
const miClient = new XiaoAi(user, pwd)
|
|
|
|
// 让小爱同学说话
|
2020-12-05 09:44:51 +08:00
|
|
|
miClient.say(text)
|
|
|
|
res.end('success');
|
|
|
|
})
|
|
|
|
|
|
|
|
let server = app.listen(18888, () => {
|
|
|
|
let host = server.address().address;
|
|
|
|
let port = server.address().port;
|
|
|
|
|
|
|
|
console.log("应用实例,访问地址为 http://%s:%s", host, port)
|
|
|
|
})
|
|
|
|
|