我正在通过Heroku中的telegram bot
运行node.js
我将要想为一个假值,并且在本地可以,但是在heroku中不起作用。
我该如何解决?
let p = false;
bot.onText(/\/book/, (msg) => {
bot.sendMessage(msg.chat.id, 'This is your Book'); // ok
p = true; // not work in Heroku and still is false
});
bot.on('message', (msg) => {
bot.sendMessage(msg.chat.id, p); // p is still false
p = false;
});
我正在使用此库和heroku配置:(https://github.com/yagop/node-telegram-bot-api/blob/master/examples/webhook/heroku.js)
我只想在我的情况为真时得到消息
1 :) bot.onText(// book /)
2 :) p = true;
3 :) //听任何类型的消息。与bot.on('message', (msg) => {
package.json:
"scripts": {
"update:packages": "npm update --save-dev && npm update --save",
"prebuild": "npm run clean",
"preinstall": "npm install pm2 -g",
"start": "pm2-runtime src/index.js -i max",
"test": "eslint .",
"build": "cross-env NODE_ENV=production babel --out-dir lib src",
"dev": "cross-env NODE_ENV=development babel-watch src/index.js",
"dev-inspect": "cross-env NODE_ENV=development babel-watch --inspect --debug-brk src/index.js",
"clean": "rimraf lib"
},