Skip to content

Instantly share code, notes, and snippets.

@timani
Last active August 2, 2016 05:25
Show Gist options
  • Save timani/7316c18b17817ce33548a714dbd00233 to your computer and use it in GitHub Desktop.
Save timani/7316c18b17817ce33548a714dbd00233 to your computer and use it in GitHub Desktop.
tmunyaradzi:hubot-tracker tmunyaradzi$ export NVM_DIR="$HOME/.nvm"
tmunyaradzi:hubot-tracker tmunyaradzi$ nvm
-bash: nvm: command not found
tmunyaradzi:hubot-tracker tmunyaradzi$ [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
tmunyaradzi:hubot-tracker tmunyaradzi$ nvm
Node Version Manager
Note: <version> refers to any version-like string nvm understands. This includes:
- full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
- default (built-in) aliases: node, stable, unstable, iojs, system
- custom aliases you define with `nvm alias foo`
Usage:
nvm --help Show this message
nvm --version Print out the latest released version of nvm
nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available
--reinstall-packages-from=<version> When installing, reinstall packages installed in <node|iojs|node version number>
--lts When installing, only select from LTS (long-term support) versions
--lts=<LTS name> When installing, only select from versions for a specific LTS line
nvm uninstall <version> Uninstall a version
nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.
nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available.
nvm use [--silent] <version> Modify PATH to use <version>. Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
--lts=<LTS name> Uses automatic alias for provided LTS line, if available.
nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
--lts=<LTS name> Uses automatic alias for provided LTS line, if available.
nvm run [--silent] <version> [<args>] Run `node` on <version> with <args> as arguments. Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
--lts=<LTS name> Uses automatic alias for provided LTS line, if available.
nvm current Display currently activated version
nvm ls List installed versions
nvm ls <version> List versions matching a given <version>
nvm ls-remote List remote versions available for install
--lts When listing, only show LTS (long-term support) versions
nvm ls-remote <version> List remote versions available for install, matching a given <version>
--lts When listing, only show LTS (long-term support) versions
--lts=<LTS name> When listing, only show versions for a specific LTS line
nvm version <version> Resolve the given description to a single local version
nvm version-remote <version> Resolve the given description to a single remote version
--lts When listing, only select from LTS (long-term support) versions
--lts=<LTS name> When listing, only select from versions for a specific LTS line
nvm deactivate Undo effects of `nvm` on current shell
nvm alias [<pattern>] Show all aliases beginning with <pattern>
nvm alias <name> <version> Set an alias named <name> pointing to <version>
nvm unalias <name> Deletes the alias named <name>
nvm reinstall-packages <version> Reinstall global `npm` packages contained in <version> to current version
nvm unload Unload `nvm` from shell
nvm which [<version>] Display path to installed node version. Uses .nvmrc if available
Example:
nvm install v0.10.32 Install a specific version number
nvm use 0.10 Use the latest available 0.10.x release
nvm run 0.10.32 app.js Run app.js using node v0.10.32
nvm exec 0.10.32 node app.js Run `node app.js` with the PATH pointing to node v0.10.32
nvm alias default 0.10.32 Set default node version on a shell
Note:
to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)
tmunyaradzi:hubot-tracker tmunyaradzi$ nvm list
-> system
node -> stable (-> N/A) (default)
iojs -> N/A (default)
tmunyaradzi:hubot-tracker tmunyaradzi$ nvm install node
Downloading https://nodejs.org/dist/v6.3.1/node-v6.3.1-darwin-x64.tar.gz...
######################################################################## 100.0%
Now using node v6.3.1 (npm v3.10.3)
Creating default alias: default -> node (-> v6.3.1)
tmunyaradzi:hubot-tracker tmunyaradzi$ nvm install node
v6.3.1 is already installed.
Now using node v6.3.1 (npm v3.10.3)
tmunyaradzi:hubot-tracker tmunyaradzi$ nvm use node
Now using node v6.3.1 (npm v3.10.3)
tmunyaradzi:hubot-tracker tmunyaradzi$ ls -la
total 8
drwxr-xr-x 4 tmunyaradzi staff 136 Aug 1 21:21 .
drwxr-xr-x 21 tmunyaradzi staff 714 Aug 1 20:51 ..
drwxr-xr-x 7 tmunyaradzi staff 238 Aug 1 20:58 node_modules
-rw-r--r-- 1 tmunyaradzi staff 159 Aug 1 20:58 package.json
tmunyaradzi:hubot-tracker tmunyaradzi$ rm -rf node_modules/
tmunyaradzi:hubot-tracker tmunyaradzi$ ls la
ls: la: No such file or directory
tmunyaradzi:hubot-tracker tmunyaradzi$ ls -la
total 8
drwxr-xr-x 3 tmunyaradzi staff 102 Aug 1 21:22 .
drwxr-xr-x 21 tmunyaradzi staff 714 Aug 1 20:51 ..
-rw-r--r-- 1 tmunyaradzi staff 159 Aug 1 20:58 package.json
tmunyaradzi:hubot-tracker tmunyaradzi$ cat package.json
{
"dependencies": {
"hubot": ">= 2.5.1",
"hubot-scripts": ">= 2.4.2",
"hubot-script-boilerplate": ">= 0.0.0",
"hubot-slack": " >= 2.6"
}
}
tmunyaradzi:hubot-tracker tmunyaradzi$ npm install
/Users/tmunyaradzi/Pivotal/hubot-tracker
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
...
tmunyaradzi:hubot-tracker tmunyaradzi$ yo hubot
_____________________________
/ \
//\ | Extracting input for |
////\ _____ | self-replication process |
//////\ /_____\ \ /
======= |[^_/\_]| /----------------------------
| | _|___@@__|__
+===+/ /// \_\
| |_\ /// HUBOT/\\
|___/\// / \\
\ / +---+
\____/ | |
| //| +===+
\// |xx|
? Owner Timani Tunduwani <[email protected]>
? Bot name hubot-tracker
? Description A simple helpful robot for your Company
? Bot adapter slack
create bin/hubot
create bin/hubot.cmd
create Procfile
create README.md
create external-scripts.json
create hubot-scripts.json
create .gitignore
create package.json
create scripts/example.coffee
create .editorconfig
_____________________________
_____ / \
\ \ | Self-replication process |
| | _____ | complete... |
|__\\| /_____\ \ Good luck with that. /
|//+ |[^_/\_]| /----------------------------
| | _|___@@__|__
+===+/ /// \_\
| |_\ /// HUBOT/\\
|___/\// / \\
\ / +---+
\____/ | |
| //| +===+
\// |xx|
[email protected] /Users/tmunyaradzi/Pivotal/hubot-tracker
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
...
tmunyaradzi:hubot-tracker tmunyaradzi$ ls -la
total 64
drwxr-xr-x 12 tmunyaradzi staff 408 Aug 1 21:25 .
drwxr-xr-x 21 tmunyaradzi staff 714 Aug 1 20:51 ..
-rw-r--r-- 1 tmunyaradzi staff 197 May 19 14:45 .editorconfig
-rw-r--r-- 1 tmunyaradzi staff 39 May 19 14:45 .gitignore
-rw-r--r-- 1 tmunyaradzi staff 24 Aug 1 21:25 Procfile
-rw-r--r-- 1 tmunyaradzi staff 7916 Aug 1 21:25 README.md
drwxr-xr-x 4 tmunyaradzi staff 136 Aug 1 21:25 bin
-rw-r--r-- 1 tmunyaradzi staff 213 Aug 1 21:25 external-scripts.json
-rw-r--r-- 1 tmunyaradzi staff 2 Aug 1 21:25 hubot-scripts.json
drwxr-xr-x 175 tmunyaradzi staff 5950 Aug 1 21:25 node_modules
-rw-r--r-- 1 tmunyaradzi staff 665 Aug 1 21:25 package.json
drwxr-xr-x 3 tmunyaradzi staff 102 Aug 1 21:25 scripts
tmunyaradzi:hubot-tracker tmunyaradzi$ bin/hubot
hubot-tracker> [Mon Aug 01 2016 21:36:35 GMT-0700 (PDT)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.
Your hubot-scripts.json is empty, so you just need to remove it.
[Mon Aug 01 2016 21:36:35 GMT-0700 (PDT)] ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s | grep web-url | cut -d= -f2)`
[Mon Aug 01 2016 21:36:35 GMT-0700 (PDT)] INFO hubot-redis-brain: Using default redis on localhost:6379
hubot-tracker> help
usage:
history
exit, \q - close shell and exit
help, \? - print this usage
clear, \c - clear the terminal screen
hubot-tracker> pug me
hubot-tracker> exit
tmunyaradzi:hubot-tracker tmunyaradzi$ vim external-scripts.json
tmunyaradzi:hubot-tracker tmunyaradzi$ vim external-scripts.json
tmunyaradzi:hubot-tracker tmunyaradzi$ bin/hubot
hubot-tracker> [Mon Aug 01 2016 21:37:51 GMT-0700 (PDT)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.
Your hubot-scripts.json is empty, so you just need to remove it.
Error parsing JSON data from external-scripts.json: SyntaxError: Unexpected token # in JSON at position 41
tmunyaradzi:hubot-tracker tmunyaradzi$ vim external-scripts.json
Press ENTER or type command to continue
tmunyaradzi:hubot-tracker tmunyaradzi$ vim external-scripts.json
tmunyaradzi:hubot-tracker tmunyaradzi$ bin/hubot
hubot-tracker> [Mon Aug 01 2016 21:38:33 GMT-0700 (PDT)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.
Your hubot-scripts.json is empty, so you just need to remove it.
[Mon Aug 01 2016 21:38:33 GMT-0700 (PDT)] INFO hubot-redis-brain: Using default redis on localhost:6379
hubot-tracker> exit
tmunyaradzi:hubot-tracker tmunyaradzi$ rm hubot-scripts.json
tmunyaradzi:hubot-tracker tmunyaradzi$ bin/hubot
hubot-tracker> [Mon Aug 01 2016 21:38:59 GMT-0700 (PDT)] INFO hubot-redis-brain: Using default redis on localhost:6379
hubot-tracker> exit
tmunyaradzi:hubot-tracker tmunyaradzi$ cat external-scripts.json
[
"hubot-diagnostics",
"hubot-help",
"hubot-google-images",
"hubot-google-translate",
"hubot-pugme",
"hubot-maps",
"hubot-redis-brain",
"hubot-rules",
"hubot-shipit"
]
# 1. Use the Slack token and Slack adapter to connect to the Slack instance.
# It will be possible to directly interact with the bot from Slack with the hubot instance running locally.
tmunyaradzi:hubot-tracker tmunyaradzi$ HUBOT_SLACK_TOKEN=xxxx-xxxxxx-k6U37lJw4sphMDyRICfEHBRn ./bin/hubot --adapter slack
[Mon Aug 01 2016 22:16:19 GMT-0700 (PDT)] INFO Logged in as tracker-bot of 830 60th st
[Mon Aug 01 2016 22:16:20 GMT-0700 (PDT)] INFO Slack client now connected
[Mon Aug 01 2016 22:16:20 GMT-0700 (PDT)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Mon Aug 01 2016 22:16:20 GMT-0700 (PDT)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
# 2. type the following commands to the bot
timani [10:16 PM]
@tracker-bot: create story foo
tracker-botBOT [10:16 PM]
I am about to create a story! message: Here is my title - foo
timani [10:16 PM]
@tracker-bot: show story foo (edited)
[10:16]
@tracker-bot: show story foo
tracker-botBOT [10:16 PM]
I am about to show a story! message: Here is my ID - foo

Formatting a message in slack

slackapi/hubot-slack#170 (comment)

module.exports = (robot) ->
  robot.respond /create story (.*)/i, (msg) ->
    msg.send "I am about to create a story! message: Here is my title - #{msg.match[1]} "

  robot.respond /show story (.*)/i, (msg) ->
    msg.send "I am about to show a story! message: Here is my ID - #{msg.match[1]} "
    msg.send({
      attachments: [{
          title: 'a title',
          fallback: 'a fallback'
          title_link: 'http://example.com',
      }],
      username: process.env.HUBOT_SLACK_BOTNAME,
      as_user: true,
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment