diff --git a/builtin.go b/builtin.go index e39c5ee..4c8a19d 100644 --- a/builtin.go +++ b/builtin.go @@ -129,6 +129,8 @@ func handleConnect(c *Client, e Event) { // nickCollisionHandler helps prevent the client from having conflicting // nicknames with another bot, user, etc. +// +//goland:noinspection GoUnusedParameter func nickCollisionHandler(c *Client, e Event) { if c.Config.HandleNickCollide == nil { c.Cmd.Nick(c.GetNick() + "_") @@ -146,6 +148,7 @@ func handlePING(c *Client, e Event) { c.Cmd.Pong(e.Last()) } +//goland:noinspection GoUnusedParameter func handlePONG(c *Client, e Event) { c.conn.lastPong.Store(time.Now()) } diff --git a/cap_tags.go b/cap_tags.go index 3b3b066..6ba6262 100644 --- a/cap_tags.go +++ b/cap_tags.go @@ -51,9 +51,12 @@ type Tags map[string]string // ParseTags parses out the key-value map of tags. raw should only be the tag // data, not a full message. For example: -// @aaa=bbb;ccc;example.com/ddd=eee +// +// @aaa=bbb;ccc;example.com/ddd=eee +// // NOT: -// @aaa=bbb;ccc;example.com/ddd=eee :nick!ident@host.com PRIVMSG me :Hello +// +// @aaa=bbb;ccc;example.com/ddd=eee :nick!ident@host.com PRIVMSG me :Hello // // Technically, there is a length limit of 4096, but the server should reject // tag messages longer than this. @@ -249,10 +252,6 @@ func (t Tags) Get(key string) (tag string, success bool) { // Set escapes given value and saves it as the value for given key. Note that // this is not concurrent safe. func (t Tags) Set(key, value string) error { - if t == nil { - t = make(Tags) - } - if !validTag(key) { return fmt.Errorf("tag key %q is invalid", key) } diff --git a/codebook.go b/codebook.go index 36cbd42..095291e 100644 --- a/codebook.go +++ b/codebook.go @@ -4,6 +4,7 @@ package girc IRCNumToStr takes in a numeric IRC code and returns the relevant girc name. IRCNumToStr accepts a string because that's how we tend to receive the codes. */ +//goland:noinspection GoUnusedExportedFunction func IRCNumToStr(code string) string { if _, ok := noTranslate[code]; ok { return code diff --git a/commands.go b/commands.go index 192c80c..f8d3728 100644 --- a/commands.go +++ b/commands.go @@ -120,6 +120,7 @@ func (cmd *Commands) Messagef(target, format string, a ...interface{}) { // server.) var ErrInvalidSource = errors.New("event has nil or invalid source address") +// ErrDontKnowUser is returned when a method needs to know the origin of an event, var ErrDontKnowUser = errors.New("failed to lookup target user") // Reply sends a reply to channel or user, based on where the supplied event diff --git a/constants.go b/constants.go index b9af805..f879f78 100644 --- a/constants.go +++ b/constants.go @@ -5,6 +5,8 @@ package girc // Standard CTCP based constants. +// +//goland:noinspection ALL const ( CTCP_ACTION = "ACTION" CTCP_PING = "PING" @@ -20,6 +22,8 @@ const ( // Emulated event commands used to allow easier hooks into the changing // state of the client. +// +//goland:noinspection ALL const ( UPDATE_STATE = "CLIENT_STATE_UPDATED" // when channel/user state is updated. UPDATE_GENERAL = "CLIENT_GENERAL_UPDATED" // when general state (client nick, server name, etc) is updated. @@ -33,6 +37,8 @@ const ( ) // User/channel prefixes :: RFC1459. +// +//goland:noinspection ALL const ( DefaultPrefixes = "(ov)@+" // the most common default prefixes ModeAddPrefix = "+" // modes are being added @@ -48,6 +54,8 @@ const ( ) // User modes :: RFC1459; section 4.2.3.2. +// +//goland:noinspection ALL const ( UserModeInvisible = "i" // invisible UserModeOperator = "o" // server operator @@ -56,6 +64,8 @@ const ( ) // Channel modes :: RFC1459; section 4.2.3.1. +// +//goland:noinspection ALL const ( ModeDefaults = "beI,k,l,imnpst" // the most common default modes @@ -75,6 +85,8 @@ const ( ) // IRC commands :: RFC2812; section 3 :: RFC2813; section 4. +// +//goland:noinspection ALL const ( ADMIN = "ADMIN" AWAY = "AWAY" @@ -127,6 +139,8 @@ const ( ) // Numeric IRC reply mapping :: RFC2812; section 5. +// +//goland:noinspection ALL const ( RPL_WELCOME = "001" RPL_YOURHOST = "002" @@ -270,6 +284,8 @@ const ( ) // IRCv3 commands and extensions :: http://ircv3.net/irc/. +// +//goland:noinspection ALL const ( AUTHENTICATE = "AUTHENTICATE" MONITOR = "MONITOR" @@ -293,6 +309,8 @@ const ( ) // Numeric IRC reply mapping for ircv3 :: http://ircv3.net/irc/. +// +//goland:noinspection ALL const ( RPL_LOGGEDIN = "900" RPL_LOGGEDOUT = "901" @@ -313,6 +331,8 @@ const ( ) // Numeric IRC event mapping :: RFC2812; section 5.3. +// +//goland:noinspection ALL const ( RPL_STATSCLINE = "213" RPL_STATSNLINE = "214" @@ -341,6 +361,8 @@ const ( ) // Misc. +// +//goland:noinspection ALL const ( ERR_TOOMANYMATCHES = "416" // IRCNet. RPL_GLOBALUSERS = "266" // aircd/hybrid/bahamut, used on freenode. @@ -351,6 +373,8 @@ const ( ) // As seen in the wild. +// +//goland:noinspection ALL const ( RPL_WHOISAUTHNAME = "330" RPL_WHOISTLS = "671" diff --git a/go.mod b/go.mod index 771ea37..a88783c 100644 --- a/go.mod +++ b/go.mod @@ -3,14 +3,7 @@ module github.com/yunginnanet/girc-atomic go 1.19 require ( + git.tcp.direct/kayos/common v0.7.6 github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de github.com/orcaman/concurrent-map v1.0.0 ) - -require ( - git.tcp.direct/kayos/common v0.7.6 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/rs/zerolog v1.27.0 // indirect - golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect -) diff --git a/go.sum b/go.sum index af355d6..49e8760 100644 --- a/go.sum +++ b/go.sum @@ -2,31 +2,18 @@ git.tcp.direct/kayos/common v0.7.6 h1:RThBVa6xKF6ybRURBgzobEHsRi8nYoYp3Z1PE2qtKx git.tcp.direct/kayos/common v0.7.6/go.mod h1:jVbdX9prBrx9e3aTsNpu643brGVgpLvysl40/F5U2cE= github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA= github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HDbW65HOY= github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs= -github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U= github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/handler.go b/handler.go index 59cc8fa..dbe6a0a 100644 --- a/handler.go +++ b/handler.go @@ -552,6 +552,8 @@ func (e *HandlerError) String() string { // DefaultRecoverHandler can be used with Config.RecoverFunc as a default // catch-all for panics. This will log the error, and the call trace to the // debug log (see Config.Debug), or os.Stdout if Config.Debug is unset. +// +//goland:noinspection GoUnusedExportedFunction func DefaultRecoverHandler(client *Client, err *HandlerError) { if client.Config.Debug == nil { fmt.Println(err.Error()) diff --git a/util.go b/util.go deleted file mode 100644 index 26056cc..0000000 --- a/util.go +++ /dev/null @@ -1,11 +0,0 @@ -package girc - -import ( - "math/rand" - "time" -) - -func randSleep() { - rand.Seed(time.Now().UnixNano()) - time.Sleep(time.Duration(rand.Intn(25)) * time.Millisecond) -}