简体   繁体   中英

Hubot script only works in Slack when I directly message the robot

Right now, my Hubot robot is techinically working. If I direct message this message to the robot in Slack:

qbot !npm bower

It will reply with this link:

https://www.npmjs.com/package/bower

It also works if I just do:

!npm bower

However, if I say either of those messages in the general channel, the robot doesn't do anything. Any help would be appreciated! Here is the script if it helps at all:

# 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

自从我自己做以来已经有很长时间了,但是我相信您想从想要使用它的频道中按名称来/invite您的hubot。请参阅此处的文档: https : //github.com/slackhq/ hubot-松弛#配置

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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