3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-29 23:49:25 +01:00
ergo/irc/caps/constants.go

71 lines
1.8 KiB
Go
Raw Normal View History

// Copyright (c) 2017 Daniel Oaks <daniel@danieloaks.net>
// released under the MIT license
package caps
import "errors"
// Capability represents an optional feature that a client may request from the server.
type Capability uint
// actual capability definitions appear in defs.go
var (
nameToCapability map[string]Capability
NoSuchCap = errors.New("Unsupported capability name")
)
// Name returns the name of the given capability.
func (capability Capability) Name() string {
return capabilityNames[capability]
}
func NameToCapability(name string) (result Capability, err error) {
result, found := nameToCapability[name]
if !found {
err = NoSuchCap
}
return
}
2017-10-07 14:19:37 +02:00
// Version is used to select which max version of CAP the client supports.
type Version uint
const (
// Cap301 refers to the base CAP spec.
Cap301 Version = 301
// Cap302 refers to the IRCv3.2 CAP spec.
Cap302 Version = 302
)
2018-02-03 12:15:07 +01:00
// State shows whether we're negotiating caps, finished, etc for connection registration.
type State uint
const (
// NoneState means CAP hasn't been negotiated at all.
NoneState State = iota
// NegotiatingState means CAP is being negotiated and registration should be paused.
NegotiatingState State = iota
// NegotiatedState means CAP negotiation has been successfully ended and reg should complete.
NegotiatedState State = iota
)
2018-06-26 04:50:57 +02:00
const (
// LabelTagName is the tag name used for the labeled-response spec.
// https://ircv3.net/specs/extensions/labeled-response.html
2020-01-28 03:10:16 +01:00
LabelTagName = "label"
2019-12-23 21:26:37 +01:00
// More draft names associated with draft/multiline:
MultilineBatchType = "draft/multiline"
MultilineConcatTag = "draft/multiline-concat"
2020-12-22 03:59:46 +01:00
// draft/relaymsg:
RelaymsgTagName = "draft/relaymsg"
2018-06-26 04:50:57 +02:00
)
func init() {
nameToCapability = make(map[string]Capability)
for capab, name := range capabilityNames {
nameToCapability[name] = Capability(capab)
}
}