diff --git a/fedmsg.d/fmn.py b/fedmsg.d/fmn.py index 7e1f303..36e372b 100644 --- a/fedmsg.d/fmn.py +++ b/fedmsg.d/fmn.py @@ -18,6 +18,20 @@ }, }, + # Colors: + "irc_color_lookup": { + "fas": "light blue", + "bodhi": "green", + "git": "red", + "tagger": "brown", + "wiki": "purple", + "logger": "orange", + "pkgdb": "teal", + "buildsys": "yellow", + "planet": "light green", + "fmn": "purple", + }, + ## Backend stuff ## # This is the list of enabled backends (so we can turn one off globally) diff --git a/fmn/consumer/backends/irc.py b/fmn/consumer/backends/irc.py index e2345b5..1849564 100644 --- a/fmn/consumer/backends/irc.py +++ b/fmn/consumer/backends/irc.py @@ -31,6 +31,25 @@ You can contact {support_email} if you have any concerns/issues/abuse. """ +mirc_colors = { + "white": 0, + "black": 1, + "blue": 2, + "green": 3, + "red": 4, + "brown": 5, + "purple": 6, + "orange": 7, + "yellow": 8, + "light green": 9, + "teal": 10, + "light cyan": 11, + "light blue": 12, + "pink": 13, + "grey": 14, + "light grey": 15, +} + def _shorten(link): if not link: @@ -62,6 +81,14 @@ def _format_message(msg, recipient, config): flt_link = _shorten(flt_link) flt = " (triggered by %s)" % flt_link + if recipient['markup_messages']: + markup = lambda s, color: "\x03%i%s\x03" % (mirc_colors[color], s) + color_lookup = config.get('irc_color_lookup', {}) + title_color = color_lookup.get(title.split('.')[0], "light grey") + title = markup(title, title_color) + if link: + link = markup(link, "teal") + return template.format(title=title, subtitle=subtitle, delta=delta, link=link, flt=flt) diff --git a/fmn/consumer/producer.py b/fmn/consumer/producer.py index abb53f8..ea38eca 100644 --- a/fmn/consumer/producer.py +++ b/fmn/consumer/producer.py @@ -107,6 +107,7 @@ def manage_batch(session, backend, pref): recipients = [{ name: value.value, 'user': pref.user.openid, + 'markup_messages': pref.markup_messages, 'triggered_by_links': pref.triggered_by_links, 'shorten_links': pref.shorten_links, } for value in pref.detail_values]