mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
modes: Restrict changing modes correctly
This commit is contained in:
parent
d32ccdc572
commit
9fea9cf658
@ -26,6 +26,7 @@ New release of Oragono!
|
|||||||
* Fixed bug where `HELP` wouldn't correctly display for operators, and added more help topics.
|
* Fixed bug where `HELP` wouldn't correctly display for operators, and added more help topics.
|
||||||
* Fixed display of large `MONITOR` lists.
|
* Fixed display of large `MONITOR` lists.
|
||||||
* Fixed bug where you would always have certain capabilities enabled.
|
* Fixed bug where you would always have certain capabilities enabled.
|
||||||
|
* Fixed being able to change modes when not an operator.
|
||||||
|
|
||||||
|
|
||||||
## [0.3.0] - 2016-10-23
|
## [0.3.0] - 2016-10-23
|
||||||
|
18
irc/modes.go
18
irc/modes.go
@ -409,7 +409,20 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
// so we only output one warning for each list type when full
|
// so we only output one warning for each list type when full
|
||||||
listFullWarned := make(map[ChannelMode]bool)
|
listFullWarned := make(map[ChannelMode]bool)
|
||||||
|
|
||||||
|
clientIsOp := channel.ClientIsAtLeast(client, ChannelOperator)
|
||||||
|
var alreadySentPrivError bool
|
||||||
|
|
||||||
for _, change := range changes {
|
for _, change := range changes {
|
||||||
|
// chan priv modes are checked specially so ignore them
|
||||||
|
// means regular users can't view ban/except lists... but I'm not worried about that
|
||||||
|
if ChannelModePrefixes[change.mode] == "" && !clientIsOp {
|
||||||
|
if !alreadySentPrivError {
|
||||||
|
alreadySentPrivError = true
|
||||||
|
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, "You're not a channel operator")
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
switch change.mode {
|
switch change.mode {
|
||||||
case BanMask, ExceptMask, InviteMask:
|
case BanMask, ExceptMask, InviteMask:
|
||||||
mask := change.arg
|
mask := change.arg
|
||||||
@ -519,7 +532,10 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
if change.op == Remove && casefoldedName == client.nickCasefolded {
|
if change.op == Remove && casefoldedName == client.nickCasefolded {
|
||||||
// success!
|
// success!
|
||||||
} else {
|
} else {
|
||||||
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, "You're not a channel operator")
|
if !alreadySentPrivError {
|
||||||
|
alreadySentPrivError = true
|
||||||
|
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, "You're not a channel operator")
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user