我正在使用bot框架,我每24小时主动开始一个问答游戏。这个代码看起来像
bot.beginDialog(user.address, '/runChallenge', args, (error) => {
if (error) {
// error ocurred while starting new conversation. Channel not supported?
console.log(JSON.stringify(error), user.address)
bot.send(new builder.Message()
.text("The rat nibbled the wires before we could start the game for you. Sorry about that :(")
.address(user.address));
}
})
几个问题
我可以在我的bot.js文件中创建一个名为players的全局变量 并在每次调用bot.dialog('/ quiz')时将其递增1 在其第一个瀑布步骤内。鉴于该文件包含一次 一开始,一旦我增加它,我想我将不得不重置它
或者我可以在cron作业函数中使用局部变量 可以将另一个名为playersCount的参数作为args传递给对话框 它将是一个局部变量,但我不确定这是不是 正确的方法