mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-23 11:12:44 +01:00
Add support for KICK #chan user1,user2
This is one of the two cases of [RFC 2812 kicks](https://datatracker.ietf.org/doc/html/rfc2812#section-3.2.8): even when there are multiple user targets, the RFC (and Unreal and Inspircd and probably others) allows a single channel name.
This commit is contained in:
parent
907f82a27e
commit
54c5d35193
@ -1273,11 +1273,12 @@ func sajoinHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
|
||||
}
|
||||
|
||||
// KICK <channel>{,<channel>} <user>{,<user>} [<comment>]
|
||||
// The number of channels must be either 1 or equal to the number of users
|
||||
func kickHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||
hasPrivs := client.HasRoleCapabs("samode")
|
||||
channels := strings.Split(msg.Params[0], ",")
|
||||
users := strings.Split(msg.Params[1], ",")
|
||||
if (len(channels) != len(users)) && (len(users) != 1) {
|
||||
if (len(channels) != len(users)) && (len(users) != 1) && (len(channels) != 1) {
|
||||
rb.Add(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, "KICK", client.t("Not enough parameters"))
|
||||
return false
|
||||
}
|
||||
@ -1286,16 +1287,16 @@ func kickHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respons
|
||||
channel string
|
||||
nick string
|
||||
}
|
||||
kicks := make([]kickCmd, 0, len(channels))
|
||||
for index, channel := range channels {
|
||||
kicks := make([]kickCmd, 0, len(users))
|
||||
channel := channels[0]
|
||||
for index, user := range users {
|
||||
if len(channels) > 1 {
|
||||
channel = channels[index]
|
||||
}
|
||||
if channel == "" {
|
||||
continue // #679
|
||||
}
|
||||
if len(users) == 1 {
|
||||
kicks = append(kicks, kickCmd{channel, users[0]})
|
||||
} else {
|
||||
kicks = append(kicks, kickCmd{channel, users[index]})
|
||||
}
|
||||
kicks = append(kicks, kickCmd{channel, user})
|
||||
}
|
||||
|
||||
var comment string
|
||||
|
Loading…
Reference in New Issue
Block a user