mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 10:10:08 -08:00
upgrade irc-go to latest master
This commit is contained in:
parent
b2207ef373
commit
3d13c1bc5f
4 changed files with 23 additions and 6 deletions
22
vendor/github.com/goshuirc/irc-go/ircmsg/message.go
generated
vendored
22
vendor/github.com/goshuirc/irc-go/ircmsg/message.go
generated
vendored
|
|
@ -52,10 +52,19 @@ type IrcMessage struct {
|
|||
Prefix string
|
||||
Command string
|
||||
Params []string
|
||||
forceTrailing bool
|
||||
tags map[string]string
|
||||
clientOnlyTags map[string]string
|
||||
}
|
||||
|
||||
// ForceTrailing ensures that when the message is serialized, the final parameter
|
||||
// will be encoded as a "trailing parameter" (preceded by a colon). This is
|
||||
// almost never necessary and should not be used except when having to interact
|
||||
// with broken implementations that don't correctly interpret IRC messages.
|
||||
func (msg *IrcMessage) ForceTrailing() {
|
||||
msg.forceTrailing = true
|
||||
}
|
||||
|
||||
// GetTag returns whether a tag is present, and if so, what its value is.
|
||||
func (msg *IrcMessage) GetTag(tagName string) (present bool, value string) {
|
||||
if len(tagName) == 0 {
|
||||
|
|
@ -321,6 +330,10 @@ func (ircmsg *IrcMessage) LineBytesStrict(fromClient bool, truncateLen int) ([]b
|
|||
return ircmsg.line(tagLimit, clientOnlyTagDataLimit, serverAddedTagDataLimit, truncateLen)
|
||||
}
|
||||
|
||||
func paramRequiresTrailing(param string) bool {
|
||||
return len(param) == 0 || strings.IndexByte(param, ' ') != -1 || param[0] == ':'
|
||||
}
|
||||
|
||||
// line returns a sendable line created from an IrcMessage.
|
||||
func (ircmsg *IrcMessage) line(tagLimit, clientOnlyTagDataLimit, serverAddedTagDataLimit, truncateLen int) ([]byte, error) {
|
||||
if len(ircmsg.Command) < 1 {
|
||||
|
|
@ -376,11 +389,12 @@ func (ircmsg *IrcMessage) line(tagLimit, clientOnlyTagDataLimit, serverAddedTagD
|
|||
|
||||
for i, param := range ircmsg.Params {
|
||||
buf.WriteByte(' ')
|
||||
if len(param) < 1 || strings.IndexByte(param, ' ') != -1 || param[0] == ':' {
|
||||
if i != len(ircmsg.Params)-1 {
|
||||
return nil, ErrorBadParam
|
||||
}
|
||||
requiresTrailing := paramRequiresTrailing(param)
|
||||
lastParam := i == len(ircmsg.Params)-1
|
||||
if (requiresTrailing || ircmsg.forceTrailing) && lastParam {
|
||||
buf.WriteByte(':')
|
||||
} else if requiresTrailing && !lastParam {
|
||||
return nil, ErrorBadParam
|
||||
}
|
||||
buf.WriteString(param)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue