Reword some events. Nicer formatting. Highlight issue keys
1 files changed, 21 insertions(+), 3 deletions(-)

M googlechat.groovy
M googlechat.groovy +21 -3
@@ 175,7 175,14 @@ class SimpleChatMessage implements ChatM
 	}
 	String comment() {
 		if (event.comment) {
-			def formattedComment = event.comment?.body?.replaceAll(~"\\{noformat\\}\\r?", '```')?.replaceAll(~"\\{color[#:0-9a-f]*\\}", "")?.replaceAll(~"^h[1-6]\\. (.*)", '*$1*')?.replaceAll(~'[\n\r]{4}', "\n")?.replaceAll(~'\\[([^|]+)\\|(http[^]]+)\\]', '<$2|$1>')?.replaceAll(~'\\{\\{(.*?)\\}\\}', '`$1`');
+			def formattedComment = event.comment?.body?.
+				replaceAll(~"\\{noformat\\}\\r?", '```')?.
+				replaceAll(~"\\{color[#:0-9a-f]*\\}", "")?.
+				replaceAll(~"h[1-6]\\. (.*)", '*$1*')?.
+				replaceAll(~'[\n\r]{4}', "\n")?.
+				replaceAll(~'\\[([^|]+)\\|(http[^]]+)\\]', '<$2|$1>')?.
+				replaceAll(~'\\{\\{(.*?)\\}\\}', '`$1`')?.
+				replaceAll(~'[A-Z]+-[0-9]+', "<${baseUrl}/browse/"+'$0|$0>');
 			//log "Pre-formatting: ${event.comment?.body}";
 			//log "Post-formatting: ${formattedComment}";
 			if (event?.changeLog) { 

          
@@ 186,7 193,18 @@ class SimpleChatMessage implements ChatM
 	}
 
 	String header() {
-		event.user?.displayName + " " + eventType.replaceAll('Issue Commented', 'commented on').replaceAll("Generic Event", "updated").replaceAll(~/Issue ?/, "").toLowerCase() + " " + (issue.assignee ? "${issue.assignee.displayName}'s" : "unassigned") + " " + issue.issueType?.name + " " + "<${baseUrl}/browse/${issue.key}|${issue.key} - ${issue.summary}> " + (issue.resolution ? "(${issue.status.name} / ${issue.resolution?.name})" : "") + ":\n"
+		event.user?.displayName + " " + eventType.
+			replaceAll('Commented', 'commented on').
+			replaceAll('Issue Commented', 'commented on').
+			replaceAll("Generic Event", "updated").
+			replaceAll(~"Work (.*) On Issue", '$1 work on').
+			replaceAll(~'Issue (.*) (Updated|Deleted|Edited)', '$2 $1 on').
+			replaceAll(~/Issue ?/, "").
+			toLowerCase() +
+			" " + (issue.assignee ? "${issue.assignee.displayName}'s" : "unassigned") +
+			" " + issue.issueType?.name + 
+			" " + "<${baseUrl}/browse/${issue.key}|${issue.key} - ${issue.summary}> " + (issue.resolution ? "(${issue.status.name} / ${issue.resolution?.name})" : "") + 
+			":\n"
 	}
 
 	String toJSON() 

          
@@ 195,7 213,7 @@ class SimpleChatMessage implements ChatM
 			changeLog()
 			, comment()
 			].findResults { it // keyValue() returns null for unset fields.
-			}.join("\n");
+			}.join("\n") + "\n\n"; // The newlines are to visually separate bot comments, which otherwise blend together.
 		return '{ "text": "' + textField + '" }'; 
 	}
 }