forked from External/ergo
add CHANSERV UNREGISTER
This commit is contained in:
parent
7bf18443a8
commit
31f386f5a9
5 changed files with 115 additions and 54 deletions
|
|
@ -22,6 +22,10 @@ To see in-depth help for a specific ChanServ command, try:
|
|||
Here are the commands you can use:
|
||||
%s`
|
||||
|
||||
func chanregEnabled(server *Server) bool {
|
||||
return server.ChannelRegistrationEnabled()
|
||||
}
|
||||
|
||||
var (
|
||||
chanservCommands = map[string]*serviceCommand{
|
||||
"op": {
|
||||
|
|
@ -32,6 +36,7 @@ OP makes the given nickname, or yourself, a channel admin. You can only use
|
|||
this command if you're the founder of the channel.`,
|
||||
helpShort: `$bOP$b makes the given user (or yourself) a channel admin.`,
|
||||
authRequired: true,
|
||||
enabled: chanregEnabled,
|
||||
},
|
||||
"register": {
|
||||
handler: csRegisterHandler,
|
||||
|
|
@ -42,6 +47,15 @@ given admin privs on it. Modes set on the channel and the topic will also be
|
|||
remembered.`,
|
||||
helpShort: `$bREGISTER$b lets you own a given channel.`,
|
||||
authRequired: true,
|
||||
enabled: chanregEnabled,
|
||||
},
|
||||
"unregister": {
|
||||
handler: csUnregisterHandler,
|
||||
help: `Syntax: $bUNREGISTER #channel$b
|
||||
|
||||
UNREGISTER deletes a channel registration, allowing someone else to claim it.`,
|
||||
helpShort: `$bUNREGISTER$b deletes a channel registration.`,
|
||||
enabled: chanregEnabled,
|
||||
},
|
||||
"amode": {
|
||||
handler: csAmodeHandler,
|
||||
|
|
@ -53,6 +67,7 @@ account the +o operator mode every time they join #channel. To list current
|
|||
accounts and modes, use $bAMODE #channel$b. Note that users are always
|
||||
referenced by their registered account names, not their nicknames.`,
|
||||
helpShort: `$bAMODE$b modifies persistent mode settings for channel members.`,
|
||||
enabled: chanregEnabled,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
|
@ -197,11 +212,6 @@ func csOpHandler(server *Server, client *Client, command, params string, rb *Res
|
|||
}
|
||||
|
||||
func csRegisterHandler(server *Server, client *Client, command, params string, rb *ResponseBuffer) {
|
||||
if !server.channelRegistrationEnabled {
|
||||
csNotice(rb, client.t("Channel registration is not enabled"))
|
||||
return
|
||||
}
|
||||
|
||||
channelName := strings.TrimSpace(params)
|
||||
if channelName == "" {
|
||||
csNotice(rb, ircfmt.Unescape(client.t("Syntax: $bREGISTER #channel$b")))
|
||||
|
|
@ -246,3 +256,33 @@ func csRegisterHandler(server *Server, client *Client, command, params string, r
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func csUnregisterHandler(server *Server, client *Client, command, params string, rb *ResponseBuffer) {
|
||||
channelName := strings.TrimSpace(params)
|
||||
channelKey, err := CasefoldChannel(channelName)
|
||||
if channelKey == "" || err != nil {
|
||||
csNotice(rb, client.t("Channel name is not valid"))
|
||||
return
|
||||
}
|
||||
|
||||
channel := server.channels.Get(channelKey)
|
||||
if channel == nil {
|
||||
csNotice(rb, client.t("No such channel"))
|
||||
return
|
||||
}
|
||||
|
||||
hasPrivs := client.HasRoleCapabs("chanreg")
|
||||
if !hasPrivs {
|
||||
founder := channel.Founder()
|
||||
hasPrivs = founder != "" && founder == client.Account()
|
||||
}
|
||||
if !hasPrivs {
|
||||
csNotice(rb, client.t("Insufficient privileges"))
|
||||
return
|
||||
}
|
||||
|
||||
info := channel.ExportRegistration(0)
|
||||
channel.SetUnregistered()
|
||||
go server.channelRegistry.Delete(channelKey, info)
|
||||
csNotice(rb, fmt.Sprintf(client.t("Channel %s is now unregistered"), channelKey))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue