From db41b2bc34cd7b68dd206ca3b0a0eff82a5b1eb3 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 7 Apr 2021 23:23:09 -0400 Subject: [PATCH] fix #765 CS INFO with no arguments should list your registered channels --- irc/chanserv.go | 7 ++++++- irc/nickserv.go | 13 ++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/irc/chanserv.go b/irc/chanserv.go index 13d9e9bf..b885a707 100644 --- a/irc/chanserv.go +++ b/irc/chanserv.go @@ -144,7 +144,6 @@ If no regex is provided, all registered channels are returned.`, INFO displays info about a registered channel.`, helpShort: `$bINFO$b displays info about a registered channel.`, enabled: chanregEnabled, - minParams: 1, }, "get": { handler: csGetHandler, @@ -743,6 +742,12 @@ func csListHandler(service *ircService, server *Server, client *Client, command } func csInfoHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) { + if len(params) == 0 { + // #765 + listRegisteredChannels(service, client.Account(), rb) + return + } + chname, err := CasefoldChannel(params[0]) if err != nil { service.Notice(rb, client.t("Invalid channel name")) diff --git a/irc/nickserv.go b/irc/nickserv.go index 5bf45c4b..3d5c10de 100644 --- a/irc/nickserv.go +++ b/irc/nickserv.go @@ -817,14 +817,21 @@ func nsInfoHandler(service *ircService, server *Server, client *Client, command for _, nick := range account.AdditionalNicks { service.Notice(rb, fmt.Sprintf(client.t("Additional grouped nick: %s"), nick)) } - for _, channel := range server.accounts.ChannelsForAccount(accountName) { - service.Notice(rb, fmt.Sprintf(client.t("Registered channel: %s"), channel)) - } + listRegisteredChannels(service, accountName, rb) if account.Suspended != nil { service.Notice(rb, suspensionToString(client, *account.Suspended)) } } +func listRegisteredChannels(service *ircService, accountName string, rb *ResponseBuffer) { + client := rb.session.client + channels := client.server.accounts.ChannelsForAccount(accountName) + service.Notice(rb, fmt.Sprintf(client.t("You have %d registered channel(s)."), len(channels))) + for _, channel := range rb.session.client.server.accounts.ChannelsForAccount(accountName) { + service.Notice(rb, fmt.Sprintf(client.t("Registered channel: %s"), channel)) + } +} + func nsRegisterHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) { details := client.Details() passphrase := params[0]