mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
bump irc-go for the IRCMessage rename
This commit is contained in:
parent
2fbbfb1337
commit
e957a89ee2
13 changed files with 119 additions and 117 deletions
52
vendor/github.com/goshuirc/irc-go/ircmsg/message.go
generated
vendored
52
vendor/github.com/goshuirc/irc-go/ircmsg/message.go
generated
vendored
|
|
@ -48,10 +48,10 @@ var (
|
|||
ErrorBadParam = errors.New("Cannot have an empty param, a param with spaces, or a param that starts with ':' before the last parameter")
|
||||
)
|
||||
|
||||
// IrcMessage represents an IRC message, as defined by the RFCs and as
|
||||
// IRCMessage represents an IRC message, as defined by the RFCs and as
|
||||
// extended by the IRCv3 Message Tags specification with the introduction
|
||||
// of message tags.
|
||||
type IrcMessage struct {
|
||||
type IRCMessage struct {
|
||||
Prefix string
|
||||
Command string
|
||||
Params []string
|
||||
|
|
@ -64,12 +64,12 @@ type IrcMessage struct {
|
|||
// 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() {
|
||||
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) {
|
||||
func (msg *IRCMessage) GetTag(tagName string) (present bool, value string) {
|
||||
if len(tagName) == 0 {
|
||||
return
|
||||
} else if tagName[0] == '+' {
|
||||
|
|
@ -82,13 +82,13 @@ func (msg *IrcMessage) GetTag(tagName string) (present bool, value string) {
|
|||
}
|
||||
|
||||
// HasTag returns whether a tag is present.
|
||||
func (msg *IrcMessage) HasTag(tagName string) (present bool) {
|
||||
func (msg *IRCMessage) HasTag(tagName string) (present bool) {
|
||||
present, _ = msg.GetTag(tagName)
|
||||
return
|
||||
}
|
||||
|
||||
// SetTag sets a tag.
|
||||
func (msg *IrcMessage) SetTag(tagName, tagValue string) {
|
||||
func (msg *IRCMessage) SetTag(tagName, tagValue string) {
|
||||
if len(tagName) == 0 {
|
||||
return
|
||||
} else if tagName[0] == '+' {
|
||||
|
|
@ -105,7 +105,7 @@ func (msg *IrcMessage) SetTag(tagName, tagValue string) {
|
|||
}
|
||||
|
||||
// DeleteTag deletes a tag.
|
||||
func (msg *IrcMessage) DeleteTag(tagName string) {
|
||||
func (msg *IRCMessage) DeleteTag(tagName string) {
|
||||
if len(tagName) == 0 {
|
||||
return
|
||||
} else if tagName[0] == '+' {
|
||||
|
|
@ -116,14 +116,14 @@ func (msg *IrcMessage) DeleteTag(tagName string) {
|
|||
}
|
||||
|
||||
// UpdateTags is a convenience to set multiple tags at once.
|
||||
func (msg *IrcMessage) UpdateTags(tags map[string]string) {
|
||||
func (msg *IRCMessage) UpdateTags(tags map[string]string) {
|
||||
for name, value := range tags {
|
||||
msg.SetTag(name, value)
|
||||
}
|
||||
}
|
||||
|
||||
// AllTags returns all tags as a single map.
|
||||
func (msg *IrcMessage) AllTags() (result map[string]string) {
|
||||
func (msg *IRCMessage) AllTags() (result map[string]string) {
|
||||
result = make(map[string]string, len(msg.tags)+len(msg.clientOnlyTags))
|
||||
for name, value := range msg.tags {
|
||||
result[name] = value
|
||||
|
|
@ -135,23 +135,23 @@ func (msg *IrcMessage) AllTags() (result map[string]string) {
|
|||
}
|
||||
|
||||
// ClientOnlyTags returns the client-only tags (the tags with the + prefix).
|
||||
// The returned map may be internal storage of the IrcMessage object and
|
||||
// The returned map may be internal storage of the IRCMessage object and
|
||||
// should not be modified.
|
||||
func (msg *IrcMessage) ClientOnlyTags() map[string]string {
|
||||
func (msg *IRCMessage) ClientOnlyTags() map[string]string {
|
||||
return msg.clientOnlyTags
|
||||
}
|
||||
|
||||
// ParseLine creates and returns a message from the given IRC line.
|
||||
func ParseLine(line string) (ircmsg IrcMessage, err error) {
|
||||
func ParseLine(line string) (ircmsg IRCMessage, err error) {
|
||||
return parseLine(line, 0, 0)
|
||||
}
|
||||
|
||||
// ParseLineStrict creates and returns an IrcMessage from the given IRC line,
|
||||
// ParseLineStrict creates and returns an IRCMessage from the given IRC line,
|
||||
// taking the maximum length into account and truncating the message as appropriate.
|
||||
// If fromClient is true, it enforces the client limit on tag data length (4094 bytes),
|
||||
// allowing the server to return ERR_INPUTTOOLONG as appropriate. If truncateLen is
|
||||
// nonzero, it is the length at which the non-tag portion of the message is truncated.
|
||||
func ParseLineStrict(line string, fromClient bool, truncateLen int) (ircmsg IrcMessage, err error) {
|
||||
func ParseLineStrict(line string, fromClient bool, truncateLen int) (ircmsg IRCMessage, err error) {
|
||||
maxTagDataLength := MaxlenTagData
|
||||
if fromClient {
|
||||
maxTagDataLength = MaxlenClientTagData
|
||||
|
|
@ -167,7 +167,7 @@ func trimInitialSpaces(str string) string {
|
|||
return str[i:]
|
||||
}
|
||||
|
||||
func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg IrcMessage, err error) {
|
||||
func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg IRCMessage, err error) {
|
||||
if strings.IndexByte(line, '\x00') != -1 {
|
||||
err = ErrorLineContainsBadChar
|
||||
return
|
||||
|
|
@ -264,7 +264,7 @@ func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg IrcMe
|
|||
}
|
||||
|
||||
// helper to parse tags
|
||||
func (ircmsg *IrcMessage) parseTags(tags string) (err error) {
|
||||
func (ircmsg *IRCMessage) parseTags(tags string) (err error) {
|
||||
for 0 < len(tags) {
|
||||
tagEnd := strings.IndexByte(tags, ';')
|
||||
endPos := tagEnd
|
||||
|
|
@ -297,8 +297,8 @@ func (ircmsg *IrcMessage) parseTags(tags string) (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MakeMessage provides a simple way to create a new IrcMessage.
|
||||
func MakeMessage(tags map[string]string, prefix string, command string, params ...string) (ircmsg IrcMessage) {
|
||||
// MakeMessage provides a simple way to create a new IRCMessage.
|
||||
func MakeMessage(tags map[string]string, prefix string, command string, params ...string) (ircmsg IRCMessage) {
|
||||
ircmsg.Prefix = prefix
|
||||
ircmsg.Command = command
|
||||
ircmsg.Params = params
|
||||
|
|
@ -306,8 +306,8 @@ func MakeMessage(tags map[string]string, prefix string, command string, params .
|
|||
return ircmsg
|
||||
}
|
||||
|
||||
// Line returns a sendable line created from an IrcMessage.
|
||||
func (ircmsg *IrcMessage) Line() (result string, err error) {
|
||||
// Line returns a sendable line created from an IRCMessage.
|
||||
func (ircmsg *IRCMessage) Line() (result string, err error) {
|
||||
bytes, err := ircmsg.line(0, 0, 0, 0)
|
||||
if err == nil {
|
||||
result = string(bytes)
|
||||
|
|
@ -315,17 +315,17 @@ func (ircmsg *IrcMessage) Line() (result string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// LineBytes returns a sendable line created from an IrcMessage.
|
||||
func (ircmsg *IrcMessage) LineBytes() (result []byte, err error) {
|
||||
// LineBytes returns a sendable line created from an IRCMessage.
|
||||
func (ircmsg *IRCMessage) LineBytes() (result []byte, err error) {
|
||||
result, err = ircmsg.line(0, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
|
||||
// LineBytesStrict returns a sendable line, as a []byte, created from an IrcMessage.
|
||||
// LineBytesStrict returns a sendable line, as a []byte, created from an IRCMessage.
|
||||
// fromClient controls whether the server-side or client-side tag length limit
|
||||
// is enforced. If truncateLen is nonzero, it is the length at which the
|
||||
// non-tag portion of the message is truncated.
|
||||
func (ircmsg *IrcMessage) LineBytesStrict(fromClient bool, truncateLen int) ([]byte, error) {
|
||||
func (ircmsg *IRCMessage) LineBytesStrict(fromClient bool, truncateLen int) ([]byte, error) {
|
||||
var tagLimit, clientOnlyTagDataLimit, serverAddedTagDataLimit int
|
||||
if fromClient {
|
||||
// enforce client max tags:
|
||||
|
|
@ -345,8 +345,8 @@ 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) {
|
||||
// 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 {
|
||||
return nil, ErrorCommandMissing
|
||||
}
|
||||
|
|
|
|||
2
vendor/github.com/goshuirc/irc-go/ircmsg/tags.go
generated
vendored
2
vendor/github.com/goshuirc/irc-go/ircmsg/tags.go
generated
vendored
|
|
@ -27,7 +27,7 @@ func init() {
|
|||
// EscapeTagValue takes a value, and returns an escaped message tag value.
|
||||
//
|
||||
// This function is automatically used when lines are created from an
|
||||
// IrcMessage, so you don't need to call it yourself before creating a line.
|
||||
// IRCMessage, so you don't need to call it yourself before creating a line.
|
||||
func EscapeTagValue(inString string) string {
|
||||
return valtoescape.Replace(inString)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue