Skip to content

Commit

Permalink
Merge pull request #2127 from slingamn/isupport_thirteen
Browse files Browse the repository at this point in the history
pull out max parameters constant in isupport impl
  • Loading branch information
slingamn committed Feb 13, 2024
2 parents 6b7bfe0 + f691b8c commit 52d15a4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions irc/isupport/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import (

const (
maxLastArgLength = 400

/* Modern: "As the maximum number of message parameters to any reply is 15,
the maximum number of RPL_ISUPPORT tokens that can be advertised is 13."
<nickname> [up to 13 parameters] <human-readable trailing>
*/
maxParameters = 13
)

// List holds a list of ISUPPORT tokens
Expand Down Expand Up @@ -95,7 +101,7 @@ func (il *List) GetDifference(newil *List) [][]string {
length += len(token)
}

if len(cache) == 13 || len(token)+length >= maxLastArgLength {
if len(cache) == maxParameters || len(token)+length >= maxLastArgLength {
replies = append(replies, cache)
cache = make([]string, 0)
length = 0
Expand Down Expand Up @@ -138,7 +144,7 @@ func (il *List) RegenerateCachedReply() (err error) {
length += len(token)
}

if len(cache) == 13 || len(token)+length >= maxLastArgLength {
if len(cache) == maxParameters || len(token)+length >= maxLastArgLength {
il.CachedReply = append(il.CachedReply, cache)
cache = make([]string, 0)
length = 0
Expand Down

0 comments on commit 52d15a4

Please sign in to comment.