我试图在 hubot 中创建一个值表,他将它的值传递给 redis-brain.coffee 但我只知道一种方法:robot.brain.get("blablabla")。 这将从 redis-brain 获取一个字符串,我需要某种表格。
我将如何使用它: 第一次调用此函数时,hubot 会将完整的数据库加载到内存中,然后,如果有
robot.catchAll (msg) ->
if not quiet
text = msg.message.text
ector.setUser msg.message.user.name
if not loaded_brain
ector_brain = robot.brain.get('ector_brain') #need to be some type of table - In mysql should be like a select
ector.addEntry ector_brain
loaded_brain = true
else
ector.addEntry text
ector_brain = ector_brain+text #this line should insert the value of text inside ector_brain table. -- In mysql shoud be like an insert into
ector.linkNodesToLastSentence previousResponseNodes
response = ector.generateResponse()
previousResponseNodes = response.nodes
msg.reply response.sentence
那么,如何从 hubot 在 redis 中创建表?
最佳答案
robot.brain.get
和 robot.brain.set
操作 JSON 对象,而不仅仅是字符串。只需在大脑中放置一个包含您选择的数据结构的对象,并在必要时将其取回。
关于node.js - 在hubot brain中生成表格并插入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25145797/