node.js - 在hubot brain中生成表格并插入值

标签 node.js redis hubot

我试图在 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.getrobot.brain.set 操作 JSON 对象,而不仅仅是字符串。只需在大脑中放置一个包含您选择的数据结构的对象,并在必要时将其取回。

关于node.js - 在hubot brain中生成表格并插入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25145797/

相关文章:

c# - 通过 HTTP 连接到 Azure Redis 缓存

未触发 redis sentinel 客户端重新配置脚本

amazon-web-services - 如何在不使用 stunnel 的情况下从加密的 Amazon ElastiCache Redis 服务器读取写入?

javascript - 如果我太早在 robots.brain 中设置一个值,它会被 hubot-redis-brain 覆盖

javascript - Angular : how to pass $scope variables into the Node. js 服务器。

node.js - Mongoose 的分页结果,带有引用文档的过滤器

coffeescript - 使用hubot检测用户何时离开或进入 channel

node.js - 如何在hubot中没有脚本目录的脚本中发送消息?

angularjs - 如何使用 Angular js 和 Node.js 通过动态生成的字段将数据发布到 mongodb

javascript - 在 Sequelize 中不小心吞下了非空约束(可能是 bluebird 中的错误处理 promise 搞砸了)