Changeset 498 in code for trunk/irc.go
- Timestamp:
- Apr 13, 2021, 4:54:58 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/irc.go
r492 r498 5 5 "sort" 6 6 "strings" 7 "unicode" 8 "unicode/utf8" 7 9 8 10 "gopkg.in/irc.v3" … … 602 604 return entry.value.(deliveredClientMap) 603 605 } 606 607 func isWordBoundary(r rune) bool { 608 switch r { 609 case '-', '_', '|': 610 return false 611 case '\u00A0': 612 return true 613 default: 614 return !unicode.IsLetter(r) && !unicode.IsNumber(r) 615 } 616 } 617 618 func isHighlight(text, nick string) bool { 619 for { 620 i := strings.Index(text, nick) 621 if i < 0 { 622 return false 623 } 624 625 // Detect word boundaries 626 var left, right rune 627 if i > 0 { 628 left, _ = utf8.DecodeLastRuneInString(text[:i]) 629 } 630 if i < len(text) { 631 right, _ = utf8.DecodeRuneInString(text[i+len(nick):]) 632 } 633 if isWordBoundary(left) && isWordBoundary(right) { 634 return true 635 } 636 637 text = text[i+len(nick):] 638 } 639 }
Note:
See TracChangeset
for help on using the changeset viewer.