mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
use ergochat/irc-go instead of goshuirc/irc-go
This commit is contained in:
parent
66af8cd63c
commit
4910aefa37
32 changed files with 95 additions and 53 deletions
62
vendor/github.com/ergochat/irc-go/ircutils/unicode.go
generated
vendored
Normal file
62
vendor/github.com/ergochat/irc-go/ircutils/unicode.go
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright (c) 2021 Shivaram Lingamneni
|
||||
// Released under the MIT License
|
||||
|
||||
package ircutils
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// truncate a message, taking care not to make valid UTF8 into invalid UTF8
|
||||
func TruncateUTF8Safe(message string, byteLimit int) (result string) {
|
||||
if len(message) <= byteLimit {
|
||||
return message
|
||||
}
|
||||
message = message[:byteLimit]
|
||||
for i := 0; i < (utf8.UTFMax - 1); i++ {
|
||||
r, n := utf8.DecodeLastRuneInString(message)
|
||||
if r == utf8.RuneError && n <= 1 {
|
||||
message = message[:len(message)-1]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
// Sanitizes human-readable text to make it safe for IRC;
|
||||
// assumes UTF-8 and uses the replacement character where
|
||||
// applicable.
|
||||
func SanitizeText(message string, byteLimit int) (result string) {
|
||||
var buf strings.Builder
|
||||
|
||||
for _, r := range message {
|
||||
if r == '\x00' || r == '\r' {
|
||||
continue
|
||||
} else if r == '\n' {
|
||||
if buf.Len()+2 <= byteLimit {
|
||||
buf.WriteString(" ")
|
||||
continue
|
||||
} else {
|
||||
break
|
||||
}
|
||||
} else if unicode.IsSpace(r) {
|
||||
if buf.Len()+1 <= byteLimit {
|
||||
buf.WriteString(" ")
|
||||
} else {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
rLen := utf8.RuneLen(r)
|
||||
if buf.Len()+rLen <= byteLimit {
|
||||
buf.WriteRune(r)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
25
vendor/github.com/goshuirc/irc-go/ircutils/unicode.go
generated
vendored
25
vendor/github.com/goshuirc/irc-go/ircutils/unicode.go
generated
vendored
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright (c) 2021 Shivaram Lingamneni
|
||||
// Released under the MIT License
|
||||
|
||||
package ircutils
|
||||
|
||||
import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// truncate a message, taking care not to make valid UTF8 into invalid UTF8
|
||||
func TruncateUTF8Safe(message string, byteLimit int) (result string) {
|
||||
if len(message) <= byteLimit {
|
||||
return message
|
||||
}
|
||||
message = message[:byteLimit]
|
||||
for i := 0; i < (utf8.UTFMax - 1); i++ {
|
||||
r, n := utf8.DecodeLastRuneInString(message)
|
||||
if r == utf8.RuneError && n <= 1 {
|
||||
message = message[:len(message)-1]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return message
|
||||
}
|
||||
10
vendor/modules.txt
vendored
10
vendor/modules.txt
vendored
|
|
@ -19,6 +19,12 @@ github.com/ergochat/confusables
|
|||
# github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775
|
||||
## explicit
|
||||
github.com/ergochat/go-ident
|
||||
# github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce
|
||||
## explicit
|
||||
github.com/ergochat/irc-go/ircfmt
|
||||
github.com/ergochat/irc-go/ircmsg
|
||||
github.com/ergochat/irc-go/ircreader
|
||||
github.com/ergochat/irc-go/ircutils
|
||||
# github.com/go-sql-driver/mysql v1.6.0
|
||||
## explicit
|
||||
github.com/go-sql-driver/mysql
|
||||
|
|
@ -29,10 +35,6 @@ github.com/go-sql-driver/mysql
|
|||
github.com/gorilla/websocket
|
||||
# github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef
|
||||
## explicit
|
||||
github.com/goshuirc/irc-go/ircfmt
|
||||
github.com/goshuirc/irc-go/ircmsg
|
||||
github.com/goshuirc/irc-go/ircreader
|
||||
github.com/goshuirc/irc-go/ircutils
|
||||
# github.com/onsi/ginkgo v1.12.0
|
||||
## explicit
|
||||
# github.com/onsi/gomega v1.9.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue