diff --git a/go.mod b/go.mod index e8b11553..1969d66f 100644 --- a/go.mod +++ b/go.mod @@ -9,10 +9,11 @@ require ( github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1 github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 + github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce github.com/go-sql-driver/mysql v1.6.0 github.com/go-test/deep v1.0.6 // indirect github.com/gorilla/websocket v1.4.2 - github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef + github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef // indirect github.com/onsi/ginkgo v1.12.0 // indirect github.com/onsi/gomega v1.9.0 // indirect github.com/oragono/confusables v0.0.0-20201108231250-4ab98ab61fb1 // indirect diff --git a/go.sum b/go.sum index 1c98d076..c673b188 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1 h1:WLHTOodthV github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1/go.mod h1:mov+uh1DPWsltdQnOdzn08UO9GsJ3MEvhtu0Ci37fdk= github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 h1:QSJIdpr3HOzJDPwxT7hp7WbjoZcS+5GqVvsBscqChk0= github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775/go.mod h1:d2qvgjD0TvGNSvUs+mZgX090RiJlrzUYW6vtANGOy3A= +github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce h1:RfyjeynouKZjmnN8WGzCSrtuHGZ9dwfSYBq405FPoqs= +github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce/go.mod h1:2vi7KNpIPWnReB5hmLpl92eMywQvuIeIIGdt/FQCph0= github.com/ergochat/websocket v1.4.2-oragono1 h1:plMUunFBM6UoSCIYCKKclTdy/TkkHfUslhOfJQzfueM= github.com/ergochat/websocket v1.4.2-oragono1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= diff --git a/irc/channel.go b/irc/channel.go index 1fdd4332..785d5914 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -13,7 +13,7 @@ import ( "sync" - "github.com/goshuirc/irc-go/ircutils" + "github.com/ergochat/irc-go/ircutils" "github.com/ergochat/ergo/irc/caps" "github.com/ergochat/ergo/irc/history" diff --git a/irc/chanserv.go b/irc/chanserv.go index ec5c421c..35099472 100644 --- a/irc/chanserv.go +++ b/irc/chanserv.go @@ -13,7 +13,7 @@ import ( "github.com/ergochat/ergo/irc/modes" "github.com/ergochat/ergo/irc/sno" "github.com/ergochat/ergo/irc/utils" - "github.com/goshuirc/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircfmt" ) const chanservHelp = `ChanServ lets you register and manage channels.` diff --git a/irc/client.go b/irc/client.go index cff4669a..d8f566d7 100644 --- a/irc/client.go +++ b/irc/client.go @@ -17,9 +17,9 @@ import ( "time" ident "github.com/ergochat/go-ident" - "github.com/goshuirc/irc-go/ircfmt" - "github.com/goshuirc/irc-go/ircmsg" - "github.com/goshuirc/irc-go/ircreader" + "github.com/ergochat/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircmsg" + "github.com/ergochat/irc-go/ircreader" "github.com/ergochat/ergo/irc/caps" "github.com/ergochat/ergo/irc/connection_limits" diff --git a/irc/commands.go b/irc/commands.go index 59a46839..04865ea9 100644 --- a/irc/commands.go +++ b/irc/commands.go @@ -6,7 +6,7 @@ package irc import ( - "github.com/goshuirc/irc-go/ircmsg" + "github.com/ergochat/irc-go/ircmsg" ) // Command represents a command accepted from a client. diff --git a/irc/config.go b/irc/config.go index e88ff285..ebc5cc18 100644 --- a/irc/config.go +++ b/irc/config.go @@ -24,7 +24,7 @@ import ( "time" "code.cloudfoundry.org/bytefmt" - "github.com/goshuirc/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircfmt" "gopkg.in/yaml.v2" "github.com/ergochat/ergo/irc/caps" diff --git a/irc/handlers.go b/irc/handlers.go index 7f27519b..e3fb2fe1 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -20,9 +20,9 @@ import ( "strings" "time" - "github.com/goshuirc/irc-go/ircfmt" - "github.com/goshuirc/irc-go/ircmsg" - "github.com/goshuirc/irc-go/ircutils" + "github.com/ergochat/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircmsg" + "github.com/ergochat/irc-go/ircutils" "golang.org/x/crypto/bcrypt" "github.com/ergochat/ergo/irc/caps" diff --git a/irc/hostserv.go b/irc/hostserv.go index 77f9c31d..86ddf760 100644 --- a/irc/hostserv.go +++ b/irc/hostserv.go @@ -8,7 +8,7 @@ import ( "fmt" "regexp" - "github.com/goshuirc/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircfmt" "github.com/ergochat/ergo/irc/utils" ) diff --git a/irc/ircconn.go b/irc/ircconn.go index 29efbf8d..088909a2 100644 --- a/irc/ircconn.go +++ b/irc/ircconn.go @@ -8,9 +8,9 @@ import ( "net" "unicode/utf8" + "github.com/ergochat/irc-go/ircmsg" + "github.com/ergochat/irc-go/ircreader" "github.com/gorilla/websocket" - "github.com/goshuirc/irc-go/ircmsg" - "github.com/goshuirc/irc-go/ircreader" "github.com/ergochat/ergo/irc/utils" ) diff --git a/irc/message_cache.go b/irc/message_cache.go index f6ea17eb..16ac168c 100644 --- a/irc/message_cache.go +++ b/irc/message_cache.go @@ -6,7 +6,7 @@ package irc import ( "time" - "github.com/goshuirc/irc-go/ircmsg" + "github.com/ergochat/irc-go/ircmsg" "github.com/ergochat/ergo/irc/caps" "github.com/ergochat/ergo/irc/utils" diff --git a/irc/monitor.go b/irc/monitor.go index c5370b5f..aa3818b5 100644 --- a/irc/monitor.go +++ b/irc/monitor.go @@ -6,7 +6,7 @@ package irc import ( "sync" - "github.com/goshuirc/irc-go/ircmsg" + "github.com/ergochat/irc-go/ircmsg" ) // MonitorManager keeps track of who's monitoring which nicks. diff --git a/irc/nickname.go b/irc/nickname.go index ec652d77..6e31cf4a 100644 --- a/irc/nickname.go +++ b/irc/nickname.go @@ -13,7 +13,7 @@ import ( "github.com/ergochat/ergo/irc/modes" "github.com/ergochat/ergo/irc/sno" "github.com/ergochat/ergo/irc/utils" - "github.com/goshuirc/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircfmt" ) var ( diff --git a/irc/nickserv.go b/irc/nickserv.go index 0b7f9424..364435ff 100644 --- a/irc/nickserv.go +++ b/irc/nickserv.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/goshuirc/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircfmt" "github.com/ergochat/ergo/irc/custime" "github.com/ergochat/ergo/irc/passwd" diff --git a/irc/responsebuffer.go b/irc/responsebuffer.go index 50cca702..bacfbc11 100644 --- a/irc/responsebuffer.go +++ b/irc/responsebuffer.go @@ -9,7 +9,7 @@ import ( "github.com/ergochat/ergo/irc/caps" "github.com/ergochat/ergo/irc/utils" - "github.com/goshuirc/irc-go/ircmsg" + "github.com/ergochat/irc-go/ircmsg" ) const ( diff --git a/irc/server.go b/irc/server.go index 697f5028..618f013b 100644 --- a/irc/server.go +++ b/irc/server.go @@ -20,7 +20,7 @@ import ( "time" "unsafe" - "github.com/goshuirc/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircfmt" "github.com/ergochat/ergo/irc/caps" "github.com/ergochat/ergo/irc/connection_limits" diff --git a/irc/services.go b/irc/services.go index df4003cf..10a50fa3 100644 --- a/irc/services.go +++ b/irc/services.go @@ -12,8 +12,8 @@ import ( "time" "github.com/ergochat/ergo/irc/utils" - "github.com/goshuirc/irc-go/ircfmt" - "github.com/goshuirc/irc-go/ircmsg" + "github.com/ergochat/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircmsg" ) // defines an IRC service, e.g., NICKSERV diff --git a/irc/snomanager.go b/irc/snomanager.go index 52ff0ec1..53be04d7 100644 --- a/irc/snomanager.go +++ b/irc/snomanager.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/ergochat/ergo/irc/sno" - "github.com/goshuirc/irc-go/ircfmt" + "github.com/ergochat/irc-go/ircfmt" ) // SnoManager keeps track of which clients to send snomasks to. diff --git a/irc/uban.go b/irc/uban.go index 7e5821a5..5e910754 100644 --- a/irc/uban.go +++ b/irc/uban.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/goshuirc/irc-go/ircmsg" + "github.com/ergochat/irc-go/ircmsg" "github.com/ergochat/ergo/irc/custime" "github.com/ergochat/ergo/irc/flatip" diff --git a/vendor/github.com/goshuirc/irc-go/LICENSE b/vendor/github.com/ergochat/irc-go/LICENSE similarity index 100% rename from vendor/github.com/goshuirc/irc-go/LICENSE rename to vendor/github.com/ergochat/irc-go/LICENSE diff --git a/vendor/github.com/goshuirc/irc-go/ircfmt/doc.go b/vendor/github.com/ergochat/irc-go/ircfmt/doc.go similarity index 100% rename from vendor/github.com/goshuirc/irc-go/ircfmt/doc.go rename to vendor/github.com/ergochat/irc-go/ircfmt/doc.go diff --git a/vendor/github.com/goshuirc/irc-go/ircfmt/ircfmt.go b/vendor/github.com/ergochat/irc-go/ircfmt/ircfmt.go similarity index 100% rename from vendor/github.com/goshuirc/irc-go/ircfmt/ircfmt.go rename to vendor/github.com/ergochat/irc-go/ircfmt/ircfmt.go diff --git a/vendor/github.com/goshuirc/irc-go/ircmsg/doc.go b/vendor/github.com/ergochat/irc-go/ircmsg/doc.go similarity index 100% rename from vendor/github.com/goshuirc/irc-go/ircmsg/doc.go rename to vendor/github.com/ergochat/irc-go/ircmsg/doc.go diff --git a/vendor/github.com/goshuirc/irc-go/ircmsg/message.go b/vendor/github.com/ergochat/irc-go/ircmsg/message.go similarity index 100% rename from vendor/github.com/goshuirc/irc-go/ircmsg/message.go rename to vendor/github.com/ergochat/irc-go/ircmsg/message.go diff --git a/vendor/github.com/goshuirc/irc-go/ircmsg/tags.go b/vendor/github.com/ergochat/irc-go/ircmsg/tags.go similarity index 100% rename from vendor/github.com/goshuirc/irc-go/ircmsg/tags.go rename to vendor/github.com/ergochat/irc-go/ircmsg/tags.go diff --git a/vendor/github.com/goshuirc/irc-go/ircreader/ircreader.go b/vendor/github.com/ergochat/irc-go/ircreader/ircreader.go similarity index 100% rename from vendor/github.com/goshuirc/irc-go/ircreader/ircreader.go rename to vendor/github.com/ergochat/irc-go/ircreader/ircreader.go diff --git a/vendor/github.com/goshuirc/irc-go/ircutils/doc.go b/vendor/github.com/ergochat/irc-go/ircutils/doc.go similarity index 100% rename from vendor/github.com/goshuirc/irc-go/ircutils/doc.go rename to vendor/github.com/ergochat/irc-go/ircutils/doc.go diff --git a/vendor/github.com/goshuirc/irc-go/ircutils/hostnames.go b/vendor/github.com/ergochat/irc-go/ircutils/hostnames.go similarity index 100% rename from vendor/github.com/goshuirc/irc-go/ircutils/hostnames.go rename to vendor/github.com/ergochat/irc-go/ircutils/hostnames.go diff --git a/vendor/github.com/ergochat/irc-go/ircutils/unicode.go b/vendor/github.com/ergochat/irc-go/ircutils/unicode.go new file mode 100644 index 00000000..6e1cf445 --- /dev/null +++ b/vendor/github.com/ergochat/irc-go/ircutils/unicode.go @@ -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() +} diff --git a/vendor/github.com/goshuirc/irc-go/ircutils/userhost.go b/vendor/github.com/ergochat/irc-go/ircutils/userhost.go similarity index 100% rename from vendor/github.com/goshuirc/irc-go/ircutils/userhost.go rename to vendor/github.com/ergochat/irc-go/ircutils/userhost.go diff --git a/vendor/github.com/goshuirc/irc-go/ircutils/unicode.go b/vendor/github.com/goshuirc/irc-go/ircutils/unicode.go deleted file mode 100644 index 14f628e3..00000000 --- a/vendor/github.com/goshuirc/irc-go/ircutils/unicode.go +++ /dev/null @@ -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 -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 019e89d5..732bb349 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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