diff --git a/bots/humbug_trac.py b/bots/humbug_trac.py index f032ef3..40faab3 100644 --- a/bots/humbug_trac.py +++ b/bots/humbug_trac.py @@ -50,12 +50,11 @@ class HumbugPlugin(Component): def ticket_created(self, ticket): """Called when a ticket is created.""" - content = "%s created new %s in component %s:\n%s" % (ticket.values.get("reporter"), - markdown_ticket_url(ticket), - ticket.values.get("component"), - ticket.values.get("summary")) + content = "%s created %s in component **%s**, priority **%s**:\n" % \ + (ticket.values.get("reporter"), markdown_ticket_url(ticket), + ticket.values.get("component"), ticket.values.get("priority")) if ticket.values.get("description") != "": - content += ":%s" % markdown_block(ticket.values.get("description")) + content += "%s" % markdown_block(ticket.values.get("description")) send_update(ticket, content) def ticket_changed(self, ticket, comment, author, old_values): @@ -64,23 +63,25 @@ class HumbugPlugin(Component): `old_values` is a dictionary containing the previous values of the fields that have changed. """ - content = "%s updated %s:\n\n" % (author, markdown_ticket_url(ticket)) - if "summary" not in old_values: - content += "(%s)\n" % (ticket.values.get("summary"),) + content = "%s updated %s" % (author, markdown_ticket_url(ticket)) + if comment: + content += ' with comment: %s\n\n' % (markdown_block(comment,)) + else: + content += ":\n\n" + field_changes = [] for key in old_values.keys(): if key == "description": content += '- Changed %s from %s to %s' % (key, markdown_block(old_values.get(key)), markdown_block(ticket.values.get(key))) elif old_values.get(key) == "": - content += '- Added %s **%s**\n' % (key, ticket.values.get(key)) + field_changes.append('%s: => **%s**' % (key, ticket.values.get(key))) elif ticket.values.get(key) == "": - content += '- Remove %s **%s**\n' % (key, old_values.get(key)) + field_changes.append('%s: **%s** => ""' % (key, old_values.get(key))) else: - content += '- Changed %s from **%s** to **%s**\n' % (key, old_values.get(key), - ticket.values.get(key)) + field_changes.append('%s: **%s** => **%s**' % (key, old_values.get(key), + ticket.values.get(key))) + content += ", ".join(field_changes) - if comment: - content += '- Added a comment: %s' % (markdown_block(comment,)) send_update(ticket, content) def ticket_deleted(self, ticket):