mirror of
https://github.com/ergochat/ergo.git
synced 2025-01-03 08:32:43 +01:00
commit
7b28fc73e6
@ -289,6 +289,14 @@ func (cm *ChannelManager) Rename(name string, newName string) (err error) {
|
|||||||
cm.Lock()
|
cm.Lock()
|
||||||
defer cm.Unlock()
|
defer cm.Unlock()
|
||||||
|
|
||||||
|
if newCfname == cfname {
|
||||||
|
entry := cm.chans[cfname]
|
||||||
|
if entry == nil || !entry.channel.IsLoaded() {
|
||||||
|
return errNoSuchChannel
|
||||||
|
}
|
||||||
|
entry.channel.Rename(newName, cfname)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if cm.chans[newCfname] != nil || cm.registeredChannels.Has(newCfname) {
|
if cm.chans[newCfname] != nil || cm.registeredChannels.Has(newCfname) {
|
||||||
return errChannelNameInUse
|
return errChannelNameInUse
|
||||||
}
|
}
|
||||||
|
@ -453,9 +453,11 @@ func (channel *Channel) NameCasefolded() string {
|
|||||||
func (channel *Channel) Rename(name, nameCasefolded string) {
|
func (channel *Channel) Rename(name, nameCasefolded string) {
|
||||||
channel.stateMutex.Lock()
|
channel.stateMutex.Lock()
|
||||||
channel.name = name
|
channel.name = name
|
||||||
channel.nameCasefolded = nameCasefolded
|
if channel.nameCasefolded != nameCasefolded {
|
||||||
if channel.registeredFounder != "" {
|
channel.nameCasefolded = nameCasefolded
|
||||||
channel.registeredTime = time.Now().UTC()
|
if channel.registeredFounder != "" {
|
||||||
|
channel.registeredTime = time.Now().UTC()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
channel.stateMutex.Unlock()
|
channel.stateMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
@ -2421,8 +2421,7 @@ func rehashHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RENAME <oldchan> <newchan> [<reason>]
|
// RENAME <oldchan> <newchan> [<reason>]
|
||||||
func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) (result bool) {
|
func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
||||||
result = false
|
|
||||||
oldName, newName := msg.Params[0], msg.Params[1]
|
oldName, newName := msg.Params[0], msg.Params[1]
|
||||||
var reason string
|
var reason string
|
||||||
if 2 < len(msg.Params) {
|
if 2 < len(msg.Params) {
|
||||||
@ -2434,6 +2433,8 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), utils.SafeErrorParam(oldName), client.t("No such channel"))
|
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), utils.SafeErrorParam(oldName), client.t("No such channel"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
oldName = channel.Name()
|
||||||
|
|
||||||
if !(channel.ClientIsAtLeast(client, modes.ChannelOperator) || client.HasRoleCapabs("chanreg")) {
|
if !(channel.ClientIsAtLeast(client, modes.ChannelOperator) || client.HasRoleCapabs("chanreg")) {
|
||||||
rb.Add(nil, server.name, ERR_CHANOPRIVSNEEDED, client.Nick(), oldName, client.t("You're not a channel operator"))
|
rb.Add(nil, server.name, ERR_CHANOPRIVSNEEDED, client.Nick(), oldName, client.t("You're not a channel operator"))
|
||||||
return false
|
return false
|
||||||
@ -2441,14 +2442,14 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
|
|
||||||
founder := channel.Founder()
|
founder := channel.Founder()
|
||||||
if founder != "" && founder != client.Account() {
|
if founder != "" && founder != client.Account() {
|
||||||
rb.Add(nil, server.name, ERR_CANNOTRENAME, client.Nick(), oldName, newName, client.t("Only channel founders can change registered channels"))
|
rb.Add(nil, server.name, "FAIL", "RENAME", "CANNOT_RENAME", oldName, utils.SafeErrorParam(newName), client.t("Only channel founders can change registered channels"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
config := server.Config()
|
config := server.Config()
|
||||||
status, _ := channel.historyStatus(config)
|
status, _ := channel.historyStatus(config)
|
||||||
if status == HistoryPersistent {
|
if status == HistoryPersistent {
|
||||||
rb.Add(nil, server.name, ERR_CANNOTRENAME, client.Nick(), oldName, newName, client.t("Channels with persistent history cannot be renamed"))
|
rb.Add(nil, server.name, "FAIL", "RENAME", "CANNOT_RENAME", oldName, utils.SafeErrorParam(newName), client.t("Channels with persistent history cannot be renamed"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2457,9 +2458,9 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
if err == errInvalidChannelName {
|
if err == errInvalidChannelName {
|
||||||
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), utils.SafeErrorParam(newName), client.t(err.Error()))
|
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), utils.SafeErrorParam(newName), client.t(err.Error()))
|
||||||
} else if err == errChannelNameInUse {
|
} else if err == errChannelNameInUse {
|
||||||
rb.Add(nil, server.name, ERR_CHANNAMEINUSE, client.Nick(), utils.SafeErrorParam(newName), client.t(err.Error()))
|
rb.Add(nil, server.name, "FAIL", "RENAME", "CHANNEL_NAME_IN_USE", oldName, utils.SafeErrorParam(newName), client.t(err.Error()))
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
rb.Add(nil, server.name, ERR_CANNOTRENAME, client.Nick(), oldName, utils.SafeErrorParam(newName), client.t("Cannot rename channel"))
|
rb.Add(nil, server.name, "FAIL", "RENAME", "CANNOT_RENAME", oldName, utils.SafeErrorParam(newName), client.t("Cannot rename channel"))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
|
@ -168,8 +168,6 @@ const (
|
|||||||
ERR_CANNOTSENDRP = "573"
|
ERR_CANNOTSENDRP = "573"
|
||||||
RPL_WHOISSECURE = "671"
|
RPL_WHOISSECURE = "671"
|
||||||
RPL_YOURLANGUAGESARE = "687"
|
RPL_YOURLANGUAGESARE = "687"
|
||||||
ERR_CHANNAMEINUSE = "692"
|
|
||||||
ERR_CANNOTRENAME = "693"
|
|
||||||
ERR_INVALIDMODEPARAM = "696"
|
ERR_INVALIDMODEPARAM = "696"
|
||||||
ERR_LISTMODEALREADYSET = "697"
|
ERR_LISTMODEALREADYSET = "697"
|
||||||
ERR_LISTMODENOTSET = "698"
|
ERR_LISTMODENOTSET = "698"
|
||||||
|
Loading…
Reference in New Issue
Block a user