Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand reply-in-private for user.id, custom message #20

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/help.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
# /hubot/help
#
# Configuration:
# HUBOT_HELP_REPLY_IN_PRIVATE
# HUBOT_HELP_REPLY_IN_PRIVATE - Reply in private to `help`
# HUBOT_HELP_PRIVATE_MSG - Message to inform user that hubot replied in public
# HUBOT_HELP_USE_ID - Reply to user id instead of user name
#
# Notes:
# These commands are grabbed from comment blocks at the top of each file.
Expand Down Expand Up @@ -56,9 +58,11 @@ helpContents = (name, commands) ->
"""

module.exports = (robot) ->
replyInPrivate = process.env.HUBOT_HELP_REPLY_IN_PRIVATE
replyInPrivate = process.env.HUBOT_HELP_REPLY_IN_PRIVATE
privateNotifMessage = process.env.HUBOT_HELP_PRIVATE_MSG || 'replied to you in private!'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most replies are structured @${author}, ${msg} from what I've seen on adapters, so it's lowercase to not make those look odd.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you can make it whatever you want.

useId = process.env.HUBOT_HELP_USE_ID

robot.respond /help(?:\s+(.*))?$/i, (msg) ->
robot.respond /help(?:\s+(.*))?$/i, id: "hubot.help", (msg) ->
cmds = renamedHelpCommands(robot)
filter = msg.match[1]

Expand All @@ -71,9 +75,13 @@ module.exports = (robot) ->

emit = cmds.join "\n"

if replyInPrivate and msg.message?.user?.name?
msg.reply 'replied to you in private!'
robot.send {room: msg.message?.user?.name}, emit
if replyInPrivate and (msg.message?.user?.name? || msg.message?.user?.id?)
if(msg.message?.user?.name != msg.room && msg.message?.user?.id != msg.room)
msg.reply privateNotifMessage
if useId && msg.message?.user?.id?
robot.send {room: msg.message?.user?.id}, emit
else
robot.send {room: msg.message?.user?.name}, emit
else
msg.reply emit

Expand Down