3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-11 06:29:29 +01:00
CS INFO with no arguments should list your registered channels
This commit is contained in:
Shivaram Lingamneni 2021-04-07 23:23:09 -04:00
parent 1fc513cef0
commit db41b2bc34
2 changed files with 16 additions and 4 deletions

View File

@ -144,7 +144,6 @@ If no regex is provided, all registered channels are returned.`,
INFO displays info about a registered channel.`, INFO displays info about a registered channel.`,
helpShort: `$bINFO$b displays info about a registered channel.`, helpShort: `$bINFO$b displays info about a registered channel.`,
enabled: chanregEnabled, enabled: chanregEnabled,
minParams: 1,
}, },
"get": { "get": {
handler: csGetHandler, 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) { 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]) chname, err := CasefoldChannel(params[0])
if err != nil { if err != nil {
service.Notice(rb, client.t("Invalid channel name")) service.Notice(rb, client.t("Invalid channel name"))

View File

@ -817,14 +817,21 @@ func nsInfoHandler(service *ircService, server *Server, client *Client, command
for _, nick := range account.AdditionalNicks { for _, nick := range account.AdditionalNicks {
service.Notice(rb, fmt.Sprintf(client.t("Additional grouped nick: %s"), nick)) service.Notice(rb, fmt.Sprintf(client.t("Additional grouped nick: %s"), nick))
} }
for _, channel := range server.accounts.ChannelsForAccount(accountName) { listRegisteredChannels(service, accountName, rb)
service.Notice(rb, fmt.Sprintf(client.t("Registered channel: %s"), channel))
}
if account.Suspended != nil { if account.Suspended != nil {
service.Notice(rb, suspensionToString(client, *account.Suspended)) 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) { func nsRegisterHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
details := client.Details() details := client.Details()
passphrase := params[0] passphrase := params[0]