0
robot.brain
のプロパティをスクリプトのmodule.exports
に初期化すると、動作しません(下のコードを参照)。応答中に初期化すると動作します。私の仮説は、ハッボット - レディス - 脳の正しいものによって上書きされるのだろうか?どのように私はいいやり方でそれを修正するのですか?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
});
};