3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 20:09:41 +01:00

remove some redundant casefolds

This commit is contained in:
Shivaram Lingamneni 2019-12-05 07:41:09 -05:00
parent 08f351060e
commit bcc58be8af

View File

@ -1234,9 +1234,8 @@ func inviteHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
return false return false
} }
casefoldedChannelName, err := CasefoldChannel(channelName) channel := server.channels.Get(channelName)
channel := server.channels.Get(casefoldedChannelName) if channel == nil {
if err != nil || channel == nil {
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, utils.SafeErrorParam(channelName), client.t("No such channel")) rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, utils.SafeErrorParam(channelName), client.t("No such channel"))
return false return false
} }
@ -1675,9 +1674,7 @@ func lusersHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
// MODE <target> [<modestring> [<mode arguments>...]] // MODE <target> [<modestring> [<mode arguments>...]]
func modeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { func modeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
_, errChan := CasefoldChannel(msg.Params[0]) if 0 < len(msg.Params[0]) && msg.Params[0][0] == '#' {
if errChan == nil {
return cmodeHandler(server, client, msg, rb) return cmodeHandler(server, client, msg, rb)
} }
return umodeHandler(server, client, msg, rb) return umodeHandler(server, client, msg, rb)
@ -1685,10 +1682,9 @@ func modeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
// MODE <channel> [<modestring> [<mode arguments>...]] // MODE <channel> [<modestring> [<mode arguments>...]]
func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
channelName, err := CasefoldChannel(msg.Params[0]) channel := server.channels.Get(msg.Params[0])
channel := server.channels.Get(channelName)
if err != nil || channel == nil { if channel == nil {
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, utils.SafeErrorParam(msg.Params[0]), client.t("No such channel")) rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, utils.SafeErrorParam(msg.Params[0]), client.t("No such channel"))
return false return false
} }
@ -1748,12 +1744,9 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
// MODE <client> [<modestring> [<mode arguments>...]] // MODE <client> [<modestring> [<mode arguments>...]]
func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
cDetails := client.Details() cDetails := client.Details()
nickname, err := CasefoldName(msg.Params[0]) target := server.clients.Get(msg.Params[0])
target := server.clients.Get(nickname) if target == nil {
if err != nil || target == nil { rb.Add(nil, server.name, ERR_NOSUCHNICK, cDetails.nick, utils.SafeErrorParam(msg.Params[0]), client.t("No such nick"))
if len(msg.Params[0]) > 0 {
rb.Add(nil, server.name, ERR_NOSUCHNICK, cDetails.nick, msg.Params[0], client.t("No such nick"))
}
return false return false
} }
@ -2459,12 +2452,9 @@ func timeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
// TOPIC <channel> [<topic>] // TOPIC <channel> [<topic>]
func topicHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { func topicHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
name, err := CasefoldChannel(msg.Params[0]) channel := server.channels.Get(msg.Params[0])
channel := server.channels.Get(name) if channel == nil {
if err != nil || channel == nil {
if len(msg.Params[0]) > 0 {
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, utils.SafeErrorParam(msg.Params[0]), client.t("No such channel")) rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, utils.SafeErrorParam(msg.Params[0]), client.t("No such channel"))
}
return false return false
} }