Permalink
Browse files

Merge branch 'master' of github.com:github/hubot

  • Loading branch information...
2 parents 0101f3b + 9608678 commit fe6bcdcbf9085441ca99c1da2edbc4102852c9d1 @tombell tombell committed Jul 24, 2012
Showing with 56 additions and 5 deletions.
  1. +3 −3 src/robot.coffee
  2. +52 −1 src/scripts/help.coffee
  3. +1 −1 src/scripts/roles.coffee
View
@@ -249,14 +249,14 @@ class Robot
for i, line of body.split "\n"
break unless line[0] is '#' or line.substr 0, 2 is '//'
- cleaned_line = line[2..line.length].replace "\n", ""
+ cleaned_line = line[2..line.length].replace("\n", "")
- if cleaned_line.length isnt 0 and cleaned_line.toLowerCase() isnt 'none'
+ if cleaned_line.length isnt 0 and cleaned_line.trim().toLowerCase() isnt 'none'
if cleaned_line[0..1] isnt ' '
current_section = cleaned_line.replace(':', '').toLowerCase()
else
if current_section is 'commands'
- @commands.push cleaned_line
+ @commands.push cleaned_line.trim()
# Public: A helper send function which delegates to the adapter's send
# function.
@@ -5,9 +5,51 @@
# hubot help - Displays all of the help commands that Hubot knows about.
# hubot help <query> - Displays all help commands that match <query>.
#
+# URLS:
+# /hubot/help
+#
# Notes:
# These commands are grabbed from comment blocks at the top of each file.
+helpContents = (name, commands) ->
+
+ """
+<html>
+ <head>
+ <title>#{name} Help</title>
+ <style type="text/css">
+ body {
+ background: #d3d6d9;
+ color: #636c75;
+ text-shadow: 0 1px 1px rgba(255, 255, 255, .5);
+ font-family: Helvetica, Arial, sans-serif;
+ }
+ h1 {
+ margin: 8px 0;
+ padding: 0;
+ }
+ .commands {
+ font-size: 13px;
+ }
+ p {
+ border-bottom: 1px solid #eee;
+ margin: 6px 0 0 0;
+ padding-bottom: 5px;
+ }
+ p:last-child {
+ border: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>#{name} Help</h1>
+ <div class="commands">
+ #{commands}
+ </div>
+ </body>
+</html>
+ """
+
module.exports = (robot) ->
robot.respond /help\s*(.*)?$/i, (msg) ->
cmds = robot.helpCommands()
@@ -19,6 +61,15 @@ module.exports = (robot) ->
emit = cmds.join "\n"
unless robot.name.toLowerCase() is 'hubot'
- emit = emit.replace /(H|h)ubot/g, robot.name
+ emit = emit.replace /hubot/ig, robot.name
msg.send emit
+
+ robot.router.get '/hubot/help', (req, res) ->
+ cmds = robot.helpCommands()
+ emit = "<p>#{cmds.join '</p><p>'}</p>"
+
+ emit = emit.replace /hubot/ig, "<b>#{robot.name}</b>"
+
+ res.setHeader 'content-type', 'text/html'
+ res.end helpContents robot.name, emit
@@ -16,7 +16,7 @@ module.exports = (robot) ->
"Be more specific, I know #{users.length} people named like that: #{(user.name for user in users).join(", ")}"
robot.respond /who is @?([\w .-]+)\?*$/i, (msg) ->
- name = msg.match[1]
+ name = msg.match[1].trim()
if name is "you"
msg.send "Who ain't I?"

0 comments on commit fe6bcdc

Please sign in to comment.