From 9327810bbfe9cf0da2415d223fc642d943ff2ade Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 7 Sep 2019 20:01:40 +0200 Subject: Add tengo example for nick color filter. See #881 --- contrib/outmessage-irccolornick.tengo | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 contrib/outmessage-irccolornick.tengo diff --git a/contrib/outmessage-irccolornick.tengo b/contrib/outmessage-irccolornick.tengo new file mode 100644 index 00000000..a16ab64e --- /dev/null +++ b/contrib/outmessage-irccolornick.tengo @@ -0,0 +1,14 @@ +// See https://github.com/42wim/matterbridge/issues/881 +// Generates a colored nick for each msgUsername, with example to filter specific codes + +text := import("text") +fmt := import("fmt") +if outProtocol == "irc" { + // generate a color for a nick, make sure it isn't 0 or 15 + colorCode := len(msgUsername)+bytes(msgUsername)[0]%14 + 2 + // example if we want to use colorCode 3 when we have calculated colorcode 14 + if colorCode == 14 { + colorCode = 3 + } + msgUsername=fmt.sprintf("\x03%02d%s\x0F", colorCode, msgUsername) +} -- cgit v1.2.3