Changeset 288 in code for trunk/upstream.go
- Timestamp:
- May 1, 2020, 5:51:22 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/upstream.go
r287 r288 11 11 "strings" 12 12 "time" 13 "unicode" 14 "unicode/utf8" 13 15 14 16 "github.com/emersion/go-sasl" … … 237 239 } 238 240 241 func isWordBoundary(r rune) bool { 242 switch r { 243 case '-', '_', '|': 244 return false 245 case '\u00A0': 246 return true 247 default: 248 return !unicode.IsLetter(r) && !unicode.IsNumber(r) 249 } 250 } 251 252 func isHighlight(text, nick string) bool { 253 for { 254 i := strings.Index(text, nick) 255 if i < 0 { 256 return false 257 } 258 259 // Detect word boundaries 260 var left, right rune 261 if i > 0 { 262 left, _ = utf8.DecodeLastRuneInString(text[:i]) 263 } 264 if i < len(text) { 265 right, _ = utf8.DecodeRuneInString(text[i+len(nick):]) 266 } 267 if isWordBoundary(left) && isWordBoundary(right) { 268 return true 269 } 270 271 text = text[i+len(nick):] 272 } 273 } 274 239 275 func (uc *upstreamConn) handleMessage(msg *irc.Message) error { 240 276 var label string … … 306 342 uc.produce(target, msg, nil) 307 343 308 highlight := strings.Contains(text, uc.nick) && msg.Prefix.Name != uc.nick344 highlight := msg.Prefix.Name != uc.nick && isHighlight(text, uc.nick) 309 345 if ch, ok := uc.network.channels[target]; ok && ch.Detached && highlight { 310 346 uc.forEachDownstream(func(dc *downstreamConn) {
Note:
See TracChangeset
for help on using the changeset viewer.