现在,我的 Hubot 机器人在技术上正在工作。如果我将此消息直接发送给 Slack 中的机器人:
qbot !npm bower
它将回复此链接:
https://www.npmjs.com/package/bower
如果我这样做,它也会起作用:
!npm bower
但是,如果我在通用 channel 中说出任何一条消息,机器人不会执行任何操作。任何帮助,将不胜感激!这是脚本(如果有帮助的话):
# Description:
# Get a link to an npm module
#
# Dependencies:
# request
#
# Configuration:
# None
#
# Commands:
# qbot !npm <module>
request = require "request"
module.exports = (robot) ->
robot.hear /\!npm (.*)/i, (res) ->
module = res.match[1]
query = "https://www.npmjs.com/package/#{module}"
request query, (error, response, body) ->
unless error or response.statusCode is 404
res.send query
最佳答案
自从我自己完成此操作以来已经很长时间了,但我相信您想从您想要使用它的 channel 中按名称/invite
您的 hubot。请参阅此处的文档:https://github.com/slackhq/hubot-slack#configuration
关于javascript - Hubot 脚本仅在我直接向机器人发送消息时在 Slack 中有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35144638/