mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 11:59:40 +01:00
* fix #2002 `CS AMODE #channel +f nickname` is invalid, but was being accepted incorrectly. * simplify logic
This commit is contained in:
parent
c3b3bf9941
commit
e20c983b57
@ -213,8 +213,17 @@ func csAmodeHandler(service *ircService, server *Server, client *Client, command
|
|||||||
}
|
}
|
||||||
|
|
||||||
modeChanges, unknown := modes.ParseChannelModeChanges(params[1:]...)
|
modeChanges, unknown := modes.ParseChannelModeChanges(params[1:]...)
|
||||||
|
invalid := len(unknown) != 0
|
||||||
|
// #2002: +f takes an argument but is not a channel-user mode,
|
||||||
|
// check for anything valid as a channel mode change that is not valid
|
||||||
|
// as an AMODE change
|
||||||
|
for _, modeChange := range modeChanges {
|
||||||
|
if !utils.SliceContains(modes.ChannelUserModes, modeChange.Mode) {
|
||||||
|
invalid = true
|
||||||
|
}
|
||||||
|
}
|
||||||
var change modes.ModeChange
|
var change modes.ModeChange
|
||||||
if len(modeChanges) > 1 || len(unknown) > 0 {
|
if len(modeChanges) > 1 || invalid {
|
||||||
service.Notice(rb, client.t("Invalid mode change"))
|
service.Notice(rb, client.t("Invalid mode change"))
|
||||||
return
|
return
|
||||||
} else if len(modeChanges) == 1 {
|
} else if len(modeChanges) == 1 {
|
||||||
|
@ -34,3 +34,12 @@ func ReverseSlice[T any](results []T) {
|
|||||||
results[i], results[j] = results[j], results[i]
|
results[i], results[j] = results[j], results[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SliceContains[T comparable](slice []T, elem T) (result bool) {
|
||||||
|
for _, t := range slice {
|
||||||
|
if elem == t {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user