Yuvipanda has submitted this change and it was merged.
Change subject: Add Colors to IRC output
......................................................................
Add Colors to IRC output
Change-Id: I6e44d8332a73871eb855c624d801d723cc5bdde4
---
A src/colors.js
M src/relay.js
M src/template.txt
3 files changed, 30 insertions(+), 6 deletions(-)
Approvals:
Yuvipanda: Verified; Looks good to me, approved
diff --git a/src/colors.js b/src/colors.js
new file mode 100644
index 0000000..7d494f2
--- /dev/null
+++ b/src/colors.js
@@ -0,0 +1,14 @@
+var irc_colors = require('irc-colors');
+
+exports.color = function(text, colors) {
+ var _fun = irc_colors;
+ colors = colors.split('.');
+ // irc-colors allows for linked colors, for example:
+ // irc_colors.bold.red.underline("blablabla")
+ for(var i = 0; i < colors.length; ++i) {
+ _fun = _fun[colors[i]];
+ }
+
+ colorized = _fun(text);
+ return colorized;
+};
diff --git a/src/relay.js b/src/relay.js
index acd80f7..91ae7cb 100644
--- a/src/relay.js
+++ b/src/relay.js
@@ -13,6 +13,7 @@
}
swig.init({
+ filters: require('./colors.js'),
autoescape: false,
root: __dirname
});
@@ -52,6 +53,7 @@
userName: config.userName,
realName: config.realName,
channels: allChannels,
+ stripColors: false,
floodProtection: true
});
ircClient.addListener('error', errorLog);
diff --git a/src/template.txt b/src/template.txt
index e2eb733..d5eefbe 100644
--- a/src/template.txt
+++ b/src/template.txt
@@ -1,12 +1,20 @@
-({{type}}) {{user}}:
- {% if approvals %}
- [{% for value in approvals -%}
- {{loop.key}}: {{value}}{% if not loop.last %} {% endif -%}
+({{type|color('green')}}) {{user|color('bold.teal')}}:
+ {% if approvals -%}
+ [{%- for value in approvals -%}
+ {%- if value == "1" -%}
+ {{loop.key}}: {{value|color('bold.green')}}{% if not loop.last
%} {% endif -%}
+ {%- else if value == "2" -%}
+ {{loop.key}}: {{value|color('bold.underline.green')}}{% if not
loop.last %} {% endif -%}
+ {%- else if value == "-1" -%}
+ {{loop.key}}: {{value|color('bold.red')}}{% if not loop.last
%} {% endif -%}
+ {%- else -%}
+ {{loop.key}}: {{value|color('bold.underline.red')}}{% if not
loop.last %} {% endif -%}
+ {%- endif -%}
{%- endfor -%}]
{% endif %}
{{message}}
[{{repo}}]
{% if branch %} ({{branch}}) {% endif %}
- - {{url}}
+ - {{url|color('teal')}}
{% if via %}(via {{via}}) {% endif %}
- {% if owner %}(owner: {{ owner }}){% endif %}
+ {% if owner %}(owner: {{ owner |color('bold.teal')}}){% endif %}
--
To view, visit https://gerrit.wikimedia.org/r/76016
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6e44d8332a73871eb855c624d801d723cc5bdde4
Gerrit-PatchSet: 20
Gerrit-Project: labs/tools/grrrit
Gerrit-Branch: master
Gerrit-Owner: AzaToth <[email protected]>
Gerrit-Reviewer: AzaToth <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits