Skip to content

Commit

Permalink
pull out max parameters constant in isupport impl
Browse files Browse the repository at this point in the history
  • Loading branch information
slingamn committed Feb 11, 2024
1 parent 6b7bfe0 commit f691b8c
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 f691b8c

Please sign in to comment.