mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
Merge remote-tracking branch 'origin/master' into user-mask
Conflicts: irc/types.go
This commit is contained in:
commit
465313c9ac
@ -23,7 +23,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SEM_VER = "ergonomadic-1.2.14"
|
SEM_VER = "ergonomadic-1.2.15"
|
||||||
CRLF = "\r\n"
|
CRLF = "\r\n"
|
||||||
MAX_REPLY_LEN = 512 - len(CRLF)
|
MAX_REPLY_LEN = 512 - len(CRLF)
|
||||||
|
|
||||||
|
@ -142,6 +142,10 @@ func RplKill(client *Client, target *Client, comment string) string {
|
|||||||
"%s :%s", target.Nick(), comment)
|
"%s :%s", target.Nick(), comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RplCap(client *Client, subCommand CapSubCommand, arg interface{}) string {
|
||||||
|
return NewStringReply(nil, CAP, "%s %s :%s", client.Nick(), subCommand, arg)
|
||||||
|
}
|
||||||
|
|
||||||
// numeric replies
|
// numeric replies
|
||||||
|
|
||||||
func (target *Client) RplWelcome() {
|
func (target *Client) RplWelcome() {
|
||||||
|
@ -285,36 +285,28 @@ func (msg *CapCommand) HandleRegServer(server *Server) {
|
|||||||
switch msg.subCommand {
|
switch msg.subCommand {
|
||||||
case CAP_LS:
|
case CAP_LS:
|
||||||
client.capState = CapNegotiating
|
client.capState = CapNegotiating
|
||||||
client.Reply("CAP LS * :%s", SupportedCapabilities)
|
client.Reply(RplCap(client, CAP_LS, SupportedCapabilities))
|
||||||
|
|
||||||
case CAP_LIST:
|
case CAP_LIST:
|
||||||
client.Reply("CAP LIST * :%s", client.capabilities)
|
client.Reply(RplCap(client, CAP_LIST, client.capabilities))
|
||||||
|
|
||||||
case CAP_REQ:
|
case CAP_REQ:
|
||||||
client.capState = CapNegotiating
|
client.capState = CapNegotiating
|
||||||
for capability := range msg.capabilities {
|
for capability := range msg.capabilities {
|
||||||
if !SupportedCapabilities[capability] {
|
if !SupportedCapabilities[capability] {
|
||||||
client.Reply("CAP NAK * :%s", msg.capabilities)
|
client.Reply(RplCap(client, CAP_NAK, msg.capabilities))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for capability := range msg.capabilities {
|
for capability := range msg.capabilities {
|
||||||
client.capabilities[capability] = true
|
client.capabilities[capability] = true
|
||||||
}
|
}
|
||||||
client.Reply("CAP ACK * :%s", msg.capabilities)
|
client.Reply(RplCap(client, CAP_ACK, msg.capabilities))
|
||||||
|
|
||||||
case CAP_CLEAR:
|
case CAP_CLEAR:
|
||||||
format := strings.TrimRight(
|
reply := RplCap(client, CAP_ACK, client.capabilities.DisableString())
|
||||||
strings.Repeat("%s%s ", len(client.capabilities)), " ")
|
client.capabilities = make(CapabilitySet)
|
||||||
args := make([]interface{}, len(client.capabilities))
|
client.Reply(reply)
|
||||||
index := 0
|
|
||||||
for capability := range client.capabilities {
|
|
||||||
args[index] = Disable
|
|
||||||
args[index+1] = capability
|
|
||||||
index += 2
|
|
||||||
delete(client.capabilities, capability)
|
|
||||||
}
|
|
||||||
client.Reply("CAP ACK * :"+format, args...)
|
|
||||||
|
|
||||||
case CAP_END:
|
case CAP_END:
|
||||||
client.capState = CapNegotiated
|
client.capState = CapNegotiated
|
||||||
|
14
irc/types.go
14
irc/types.go
@ -13,6 +13,10 @@ type CapSubCommand string
|
|||||||
|
|
||||||
type Capability string
|
type Capability string
|
||||||
|
|
||||||
|
func (capability Capability) String() string {
|
||||||
|
return string(capability)
|
||||||
|
}
|
||||||
|
|
||||||
type CapModifier rune
|
type CapModifier rune
|
||||||
|
|
||||||
func (mod CapModifier) String() string {
|
func (mod CapModifier) String() string {
|
||||||
@ -33,6 +37,16 @@ func (set CapabilitySet) String() string {
|
|||||||
return strings.Join(strs, " ")
|
return strings.Join(strs, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (set CapabilitySet) DisableString() string {
|
||||||
|
parts := make([]string, len(set))
|
||||||
|
index := 0
|
||||||
|
for capability := range set {
|
||||||
|
parts[index] = Disable.String() + capability.String()
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
|
return strings.Join(parts, " ")
|
||||||
|
}
|
||||||
|
|
||||||
// add, remove, list modes
|
// add, remove, list modes
|
||||||
type ModeOp rune
|
type ModeOp rune
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user