Changeset 463 in code for trunk/irc.go


Ignore:
Timestamp:
Mar 15, 2021, 10:41:37 PM (4 years ago)
Author:
contact
Message:

Passthrough some ISUPPORT tokens

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/irc.go

    r392 r463  
    1818)
    1919
    20 const maxMessageLength = 512
     20const (
     21        maxMessageLength = 512
     22        maxMessageParams = 15
     23)
    2124
    2225// The server-time layout, as defined in the IRCv3 spec.
     
    349352}
    350353
     354func generateIsupport(prefix *irc.Prefix, nick string, tokens []string) []*irc.Message {
     355        maxTokens := maxMessageParams - 2 // 2 reserved params: nick + text
     356
     357        var msgs []*irc.Message
     358        for len(tokens) > 0 {
     359                var msgTokens []string
     360                if len(tokens) > maxTokens {
     361                        msgTokens = tokens[:maxTokens]
     362                        tokens = tokens[maxTokens:]
     363                } else {
     364                        msgTokens = tokens
     365                        tokens = nil
     366                }
     367
     368                msgs = append(msgs, &irc.Message{
     369                        Prefix:  prefix,
     370                        Command: irc.RPL_ISUPPORT,
     371                        Params:  append(append([]string{nick}, msgTokens...), "are supported"),
     372                })
     373        }
     374
     375        return msgs
     376}
     377
    351378type joinSorter struct {
    352379        channels []string
Note: See TracChangeset for help on using the changeset viewer.