Skip to content

Commit

Permalink
Add close reason to Slack closed ticket message
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyCurtis committed Nov 24, 2016
1 parent 49e843e commit 48a5094
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void run(CommandSender sender, String[] args) {
}

// Broadcast to slack
Slack.notifyCloseTicket(id, senderName, submitterName);
Slack.notifyCloseTicket(id, senderName, submitterName, reason);

return;
}
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/me/rafaskb/ticketmaster/integrations/Slack.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void notifyNewTicket(Ticket ticket)
"• _To claim:_ `/ticket claim %d`",
"• _To teleport to:_ `/ticket tp %d`",
"• _To comment:_ `/ticket comment %d <message>`",
"• _To close:_ `/ticket close %d`",
"• _To close:_ `/ticket close %d <reason>`",
"• _There are %d open tickets (including this one)_"
};

Expand Down Expand Up @@ -95,15 +95,25 @@ public static void notifyClaimTicket(int id, String who, String submitter)
sendMessage(msg);
}

public static void notifyCloseTicket(int id, String who, String submitter)
public static void notifyCloseTicket(int id, String who, String submitter, String reason)
{
SlackMessage msg = new SlackMessage();
msg.setIcon(who);

String text;
if ( who.equals(submitter) )
msg.setText("*%s* closed their own ticket ~*#%d*~", who, id);
text = String.format("*%s* closed their own ticket ~*#%d*~", who, id);
else
msg.setText("*%s* closed *%s's* ticket ~*#%d*~", who, submitter, id);
text = String.format("*%s* closed *%s's* ticket ~*#%d*~", who, submitter, id);

if (reason == null)
msg.setText(text);
else
msg.setText(new String[]
{
text + ":",
"> _%s_"
}, reason);

sendMessage(msg);
}
Expand Down

0 comments on commit 48a5094

Please sign in to comment.