 
 module.exports = (robot) ->
 
-  send = (context, message, prependUsername=no) ->
-    robot.adapter.customMessage
-      channel: context.message.room
-      text: "#{if prependUsername then "<@#{context.message.user.id}> " else ""}#{message}"
+  send = (context, message) ->
+    payload = channel: context.message.room
+    if _(message).isString()
+      payload.text = message
+    else
+      payload = _(payload).extend message
+    robot.adapter.customMessage payload
 
   getNotifications = ->
     robot.brain.get('github-notifications') or []

    saveNotifications notificationsToKeep
    notifications.length - (notificationsToKeep.length)

  listOpenPullRequestsForRoom = (room, user) ->
    repo = repos[room]
    if not repo

    .then (prs) ->
      return Promise.all prs.map (pr) ->
        return if not pr
        assignee = lookupUserWithGithub pr.assignee
        return Promise.all [ pr, assignee ]
    .then (prs) ->
      attachments = []
      attachments.push buildGithubAttachment p[0], p[1] for p in prs when p
      if attachments.length is 0
        message = "No matching pull requests found"
      else
        message = attachments: attachments
      send message: room: room, message
    .catch ( error ) ->
      console.log error.stack
