我将Howdy.ai的Botkit用于一个简单的bot应用程序,并使其在VPS的node.js上运行。基本上,我从这里为Slack应用程序自定义了示例,现在正努力使机器人保持活动状态-经过一段不确定的时间后,关闭了Slack API的RTM通道,我找不到合适的重新连接方法。到目前为止,我尝试了
controller.on('rtm_close',function(bot) {
console.log('** The RTM api just closed. Trying reconnect...');
// Try a reconnect
bot.startRTM(function(err) {
if (!err) {
trackBot(bot);
} else {
console.log('** The RTM api couldn\'t be reopened. It\'s closed now.');
}
});
});
该trackBot
函数控制日志记录:
function trackBot(bot) {
_bots[bot.config.token] = bot;
}
似乎我错过了整个方法的工作原理。如有任何帮助,我们深表感谢!
要启用重新连接,您需要将retry
config值设置为true
// Launch bot
bot = controller.spawn({
retry: true,
token: 'xxx'
})
https://github.com/howdyai/botkit/blob/master/readme-slack.md#slack-controller
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句