Skip to content

Commit

Permalink
mask nicknames in IRC with unicode word joiners
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ranlvor committed Aug 5, 2016
1 parent 1dcf2c5 commit 1a9d6bc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ircbot/ircbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 1a9d6bc

Please sign in to comment.