From f181a1968554baa18bf8e1c5f90af75f37393c77 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Sun, 13 Apr 2014 10:26:49 -0700 Subject: [PATCH] Starting to move things around for the new client adapter --- README.md | 65 ++-------------------------------------------------- package.json | 3 ++- 2 files changed, 4 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index adad2c5a..45527e85 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,7 @@ This is a modified set of instructions based on the [instructions on the Hubot w - Add the [config variables](#adapter-configuration). For example: % heroku config:add HEROKU_URL=http://soothing-mists-4567.herokuapp.com - % heroku config:add HUBOT_SLACK_TOKEN=dqqQP9xlWXAq5ybyqKAU0axG - % heroku config:add HUBOT_SLACK_TEAM=myteam + % heroku config:add HUBOT_SLACK_TOKEN=xoxp-1234-5678-91011-00e4dd % heroku config:add HUBOT_SLACK_BOTNAME=slack-hubot - Deploy and start the bot: @@ -51,68 +50,8 @@ This adapter uses the following environment variables: #### HUBOT\_SLACK\_TOKEN -This is the service token you are given when you add Hubot to your Team Services. - -#### HUBOT\_SLACK\_TEAM - -This is your team's Slack subdomain. For example, if your team is `https://myteam.slack.com/`, you would enter `myteam` here. +This is the API token for the Slack user you would like to run Hubot under. #### HUBOT\_SLACK\_BOTNAME Optional. What your Hubot is called on Slack. If you entered `slack-hubot` here, you would address your bot like `slack-hubot: help`. Otherwise, defaults to `slackbot`. - -#### HUBOT\_SLACK\_CHANNELMODE - -Optional. If you entered `blacklist`, Hubot will not post in the rooms specified by HUBOT_SLACK_CHANNELS, or alternately *only* in those rooms if `whitelist` is specified instead. Defaults to `blacklist`. - -#### HUBOT\_SLACK\_CHANNELS - -Optional. A comma-separated list of channels to either be blacklisted or whitelisted, depending on the value of HUBOT_SLACK_CHANNELMODE. - -#### HUBOT\_SLACK\_LINK\_NAMES - -Optional. By default, Slack will not linkify channel names (starting with a '#') and usernames (starting with an '@'). You can enable this behavior by setting HUBOT_SLACK_LINK_NAMES to 1. Otherwise, defaults to 0. See [Slack API : Message Formatting Docs](https://api.slack.com/docs/formatting) for more information. - -## Under the Hood - -#### Receiving Messages: - -The slack adapter adds a path to the robot's router that will accept POST requests to: - -`/hubot/slack-webhook` - -Source: [https://github.com/tinyspeck/hubot-slack/blob/2.2.0/src/slack.coffee#L161-L177](https://github.com/tinyspeck/hubot-slack/blob/2.2.0/src/slack.coffee#L161-L177) - -Expected parameters: - -- text -- user_id -- user_name -- channel_id -- channel_name - -If there is a message and it can deduce an author from those paramters, it'll create a new [TextMessage](https://github.com/github/hubot/blob/v2.7.2/src/message.coffee#L14) object and have the robot receive it, from there proceeding down the regular hubot path. - -#### Sending Messages - -When a script calls `send()` or `reply()` this adapter makes a POST request to your team's specific URL webhook: - -`https://.slack.com/services/hooks/hubot` - -with a JSON-formatted body including the following dictionary: - -- username -- channel -- text -- link_names (optionally) - -#### Message to a specific room: - -Sometime, it's useful to send a message regardless of the channel's activity (like `robot.hear` or `robot.response`). Hubot has [`robot.messageRoom`](https://github.com/github/hubot/blob/v2.8.0/src/robot.coffee#L401-L409) available for this use case. - -Slack API uses channel ID's by default, which uses computer-friendly alphanumeric ID. To use the pretty names, prefix it with a hash. - -```coffeescript -robot.respond /hello$/i, (msg) -> - robot.messageRoom '#general', 'hello there' -``` diff --git a/package.json b/package.json index d9e47476..712b4029 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "mocha": "~1.13.0", "hubot": "~2.6.4", "grunt-contrib-watch": "~0.5.3", - "grunt-shell": "~0.5.0" + "grunt-shell": "~0.5.0", + "node-slack": "~0.9.0" }, "main": "./src/slack", "engines": {