简体   繁体   English

将Hubot输入保存为变量

[英]Saving Hubot Input to a Variable

All I can find in the documentation is .hear("specific phrase") , or similar methods of processing input. 我在文档中只能找到.hear("specific phrase")或类似的处理输入方法。 Is there a way to simply store all input to the bot as a variable? 有没有一种方法可以简单地将对机器人的所有输入都存储为变量? The reason for this is that I intend on filtering this input through an NLP library to allow for natural language input to the bot. 原因是我打算通过NLP库过滤此输入,以允许将自然语言输入到bot。 Any help is appreciated. 任何帮助表示赞赏。

hubot on github . Hubot在github上

I think what you're asking is if you can take what the person says to hubot, and put that into a variable. 我认为您要问的是您是否可以接受该人所说的话,并将其放入变量中。 I do this with the following code: 我使用以下代码执行此操作:

module.exports = function(robot) {
robot.hear(/^(.*)/, function(msg) {
var content = msg.match.input;

});
}

Then, you can do whatever you want with the "content" variable. 然后,您可以使用“ content”变量进行任何操作。 If you have any further questions, I'd be happy to answer them, assuming you haven't solved your problem already. 如果您还有其他问题,假设您尚未解决问题,我很乐意回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM