3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 03:49:27 +01:00

Merge pull request #1418 from slingamn/issue1417_joinzero

fix #1417
This commit is contained in:
Shivaram Lingamneni 2020-12-01 14:05:26 -08:00 committed by GitHub
commit 3aeac42978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1161,9 +1161,16 @@ func isonHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
// JOIN <channel>{,<channel>} [<key>{,<key>}]
func joinHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
// kill JOIN 0 requests
// #1417: allow `JOIN 0` with a confirmation code
if msg.Params[0] == "0" {
rb.Notice(client.t("JOIN 0 is not allowed"))
expectedCode := utils.ConfirmationCode("", rb.session.ctime)
if len(msg.Params) == 1 || msg.Params[1] != expectedCode {
rb.Notice(fmt.Sprintf(client.t("Warning: /JOIN 0 will remove you from all channels. To confirm, type: /JOIN 0 %s"), expectedCode))
} else {
for _, channel := range client.Channels() {
channel.Part(client, "", rb)
}
}
return false
}