You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

constants.go 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (c) 2017 Daniel Oaks <daniel@danieloaks.net>
  2. // released under the MIT license
  3. package caps
  4. import "errors"
  5. // Capability represents an optional feature that a client may request from the server.
  6. type Capability uint
  7. // actual capability definitions appear in defs.go
  8. var (
  9. nameToCapability map[string]Capability
  10. NoSuchCap = errors.New("Unsupported capability name")
  11. )
  12. // Name returns the name of the given capability.
  13. func (capability Capability) Name() string {
  14. return capabilityNames[capability]
  15. }
  16. func NameToCapability(name string) (result Capability, err error) {
  17. result, found := nameToCapability[name]
  18. if !found {
  19. err = NoSuchCap
  20. }
  21. return
  22. }
  23. // Version is used to select which max version of CAP the client supports.
  24. type Version uint
  25. const (
  26. // Cap301 refers to the base CAP spec.
  27. Cap301 Version = 301
  28. // Cap302 refers to the IRCv3.2 CAP spec.
  29. Cap302 Version = 302
  30. )
  31. // State shows whether we're negotiating caps, finished, etc for connection registration.
  32. type State uint
  33. const (
  34. // NoneState means CAP hasn't been negotiated at all.
  35. NoneState State = iota
  36. // NegotiatingState means CAP is being negotiated and registration should be paused.
  37. NegotiatingState State = iota
  38. // NegotiatedState means CAP negotiation has been successfully ended and reg should complete.
  39. NegotiatedState State = iota
  40. )
  41. const (
  42. // LabelTagName is the tag name used for the labeled-response spec.
  43. // https://ircv3.net/specs/extensions/labeled-response.html
  44. LabelTagName = "label"
  45. // More draft names associated with draft/multiline:
  46. MultilineBatchType = "draft/multiline"
  47. MultilineConcatTag = "draft/multiline-concat"
  48. // draft/relaymsg:
  49. RelaymsgTagName = "draft/relaymsg"
  50. // BOT mode: https://ircv3.net/specs/extensions/bot-mode
  51. BotTagName = "bot"
  52. // https://ircv3.net/specs/extensions/chathistory
  53. ChathistoryTargetsBatchType = "draft/chathistory-targets"
  54. // draft/bearer defines this prefix namespace for authcids, enabling tunneling bearer tokens
  55. // in SASL PLAIN:
  56. BearerTokenPrefix = "*bearer*"
  57. )
  58. func init() {
  59. nameToCapability = make(map[string]Capability)
  60. for capab, name := range capabilityNames {
  61. nameToCapability[name] = Capability(capab)
  62. }
  63. }