Skip to content

Commit

Permalink
Merge pull request slackapi#45 from balbeko/userFromParams
Browse files Browse the repository at this point in the history
userFromParams, getAuthorFromRequest methods implemented
  • Loading branch information
grantmd committed Mar 19, 2014
2 parents dfaade7 + 4c8c4d4 commit 9f12929
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/slack.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Slack extends Adapter
username : @robot.name
channel : channel
text : str
link_names : @options.link_names
link_names : @options.link_names if @options?.link_names?

@post "/services/hooks/hubot", args

Expand Down Expand Up @@ -61,7 +61,7 @@ class Slack extends Adapter
username : @robot.name
channel : channel
attachments : [attachment]
link_names : @options.link_names
link_names : @options.link_names if @options?.link_names?
@post "/services/hooks/hubot", args
###################################################################
# HTML helpers.
Expand Down Expand Up @@ -115,8 +115,22 @@ class Slack extends Adapter
# Return an author object
id : req.param 'user_id'
name : req.param 'user_name'


reply_to : req.param 'channel_id'
room : req.param 'channel_name'

userFromParams: (params) ->
# hubot < 2.4.2: params = user
# hubot >= 2.4.2: params = {user: user, ...}
user = {}
if params.user
user = params.user
else
user = params

if user.room and not user.reply_to
user.reply_to = user.room

user
###################################################################
# The star.
###################################################################
Expand Down

0 comments on commit 9f12929

Please sign in to comment.