From 1a9d6bc9be69032b9e1372118dfae47eebe3c207 Mon Sep 17 00:00:00 2001 From: Ranlvor Date: Fri, 5 Aug 2016 22:35:33 +0200 Subject: [PATCH] mask nicknames in IRC with unicode word joiners Some uesrs who are connected to slack and IRC at the same time compained that the IRC-Part of the bridge mentions them every time they write anything in the slack. That's annoying. The solution is to insert an unicode word joiner after every character of the nickname. That causes the IRC-Client not to notice that their nick was mentioned supressing the annoying notification. --- ircbot/ircbot.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ircbot/ircbot.go b/ircbot/ircbot.go index 2a0b4dc..e5bad67 100644 --- a/ircbot/ircbot.go +++ b/ircbot/ircbot.go @@ -43,11 +43,20 @@ func (i *Bot) Start() (chan *MessageEvent, error) { return i.chEvents, nil } +func insertNBS(s string) string { + var buffer bytes.Buffer + for _,rune := range s { + buffer.WriteRune(rune) + buffer.WriteRune('\u2060') + } + return buffer.String() +} + func (i *Bot) SendMessage(nick, msg, channel string, flag bool) { msgBuf := bytes.NewBufferString("") if flag == true { - fmt.Fprintf(msgBuf, "%s:%s", nick, msg) + fmt.Fprintf(msgBuf, "%s:%s", insertNBS(nick), msg) } else { fmt.Fprintf(msgBuf, "%s", msg) }