Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit a64227f

Browse files
Adding the httpcat plugin. Returns a specified http status code as portrayed by a cat.
1 parent 42ae651 commit a64227f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/scripts/httpcat.coffee

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Description:
2+
# Loads a specified HTTP cat error image from
3+
# http://httpcats.herokuapp.com/
4+
# based on user input
5+
#
6+
# Dependencies:
7+
# none
8+
#
9+
# Configuration:
10+
# None
11+
#
12+
# Commands:
13+
# hubot httpcat <status> - get your status cat image
14+
#
15+
# hubot httpcat help - explains usage
16+
#
17+
# Notes:
18+
# None
19+
#
20+
# Author:
21+
# @commadelimited
22+
23+
codes = [100, 101, 200, 201, 202, 204, 206, 207, 300, 301, 303, 304, 305, 307, 400, 401, 402, 403, 404,
24+
405, 406, 408, 409, 410, 411, 413, 414, 416, 417, 418, 422, 423, 424, 425, 426, 429, 431, 444,
25+
450, 500, 502, 503, 506, 507, 508, 509, 599]
26+
27+
module.exports = (robot) ->
28+
robot.respond /httpcat (\d{3})/i, (msg) ->
29+
status = msg.match[1]
30+
31+
if (codes.indexOf(status))
32+
msg.send 'http://httpcats.herokuapp.com/' + status + '.jpg'
33+
else
34+
msg.send 'Sorry nothing found'
35+
36+
37+
robot.respond /httpcat help/i, (msg) ->
38+
msg.send "Usage: httpcat <http status code>; a number"

0 commit comments

Comments
 (0)