Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

Commit

Permalink
modify format of notification message
Browse files Browse the repository at this point in the history
  • Loading branch information
Hironsan committed Feb 28, 2017
1 parent 319de44 commit 6da3ec3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/ConsoleErrorInputFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public List<Pair<String, ConsoleViewContentType>> applyFilter(String text, Conso
if (outputType.equals(ConsoleViewContentType.SYSTEM_OUTPUT) && text.trim().startsWith("Process finished with exit code")) {
HandledMessage hm = HandledMessage.create(this.errorStack, this.projectContent);
if(hm != null) {
System.out.println(hm);
//System.out.println(hm);
for (SlackChannel slackChannel: SlackStorage.getInstance().channelsRegistry) {
SlackPost post = new SlackPost(slackChannel);
String message = hm.toString();
System.out.println(message);
String detail = slackChannel.getId() + " is in trouble with the following error.";
//System.out.println(message);
String detail = slackChannel.getId() + " is in trouble with the following error!";
try {
post.pushMessage(message, detail);
} catch (IOException e) {
Expand Down
2 changes: 2 additions & 0 deletions src/com/chakki_works/watchme/HandledMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ public static HandledMessage create(String rawMessage, ProjectFileContent conten
public String toString(){
String msg = "";
msg += String.format("%s(%d) \n", this.sourceFile, this.sourceLine);
msg += String.format("> ...\n");
for(int i = 0; i < this.sourceCodes.length; i++){
if(i == this.sourceCodes.length / 2){
msg += String.format("> `%s`\n", this.sourceCodes[i]); // center code
}else{
msg += String.format("> %s\n", this.sourceCodes[i]);
}
}
msg += String.format("> ...\n");
msg += String.format("Error \n ```%s```", this.error);

return msg;
Expand Down
11 changes: 6 additions & 5 deletions src/com/chakki_works/watchme/SlackChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ public String getPayloadMessage(String title, String message) {


String payload = "{" +
"\"attachments\" : [{" +
"\"title\" : \"" + title + "\"," +
"\"text\" : \"" + message + "\"," +
"\"mrkdwn_in\" : [\"title\", \"text\"]" +
"}]," +
"\"text\" : \"*" + title + "*\n" + message + "\"," +
//"\"attachments\" : [{" +
//"\"title\" : \"" + title + "\"," +
//"\"text\" : \"" + message + "\"," +
//"\"mrkdwn_in\" : [\"title\", \"text\"]" +
//"}]," +
"\"username\" : \"" + this.getSenderName() + "\"," +
"\"icon_url\" : \"" + this.getSenderIcon() + "\"";
String channel = this.getChannelName();
Expand Down

0 comments on commit 6da3ec3

Please sign in to comment.