0
robot.brain
의 속성을 내 스크립트 본문 module.exports
에 초기화하면 작동하지 않습니다 (아래 코드 참조). 응답하는 동안 초기화하면 작동합니다. 내 가설이 허비 -Redis-brain correct에 의해 덮어 쓰여지는 것입니까? 어떻게하면 좋을까요?robot.brain의 값을 너무 일찍 설정하면 hubot-redis-brain으로 덮어 씁니다.
module.exports = (robot) => {
robot.logger.debug("Setting the fucking property");
robot.brain.set("stringproperty", "stringvalue");
robot.logger.debug("SET!");
// logs these two entries before 'INFO hubot-redis-brain: Data for hubot brain retrieved from Redis'
const respondAndLog = (res, message) => {
robot.logger.debug("Responding: " + message);
res.reply(message);
};
robot.respond(/get_stringproperty/, (res) => {
respondAndLog(res, `${robot.brain.get("stringproperty")}`);
// prints null. WTF?
});
robot.respond(/get_laterinitializedproperty/, (res) => {
robot.brain.set("laterinitializedproperty", "laterinitializedvalue");
respondAndLog(res, `${robot.brain.get("laterinitializedproperty")}`);
// prints laterinitializedproperty, works OK
});
};