3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

check permissions before doing channel modes

This commit is contained in:
Jeremy Latt 2014-02-09 19:59:59 -08:00
parent 56cb8512dc
commit 9b89f1a0fb
2 changed files with 20 additions and 6 deletions

View File

@ -102,6 +102,11 @@ func (channel *Channel) GetUsers(replier Replier) {
replier.Reply(NewNamesReply(channel))
}
func (channel *Channel) ClientIsOperator(client *Client) bool {
// TODO client-channel relations
return false
}
func (channel *Channel) Nicks() []string {
nicks := make([]string, len(channel.members))
i := 0
@ -219,13 +224,16 @@ func (msg *ChannelModeCommand) HandleChannel(channel *Channel) {
}
client.Reply(RplEndOfBanList(channel))
case NoOutside:
// TODO perms
if channel.ClientIsOperator(client) {
switch modeOp.op {
case Add:
channel.noOutside = true
case Remove:
channel.noOutside = false
}
} else {
client.Reply(ErrChanOPrivIsNeeded(channel))
}
}
}

View File

@ -334,3 +334,9 @@ func ErrCannotSendToChan(channel *Channel) Reply {
return NewNumericReply(channel.server, ERR_CANNOTSENDTOCHAN,
"%s :Cannot send to channel", channel.name)
}
// <channel> :You're not channel operator
func ErrChanOPrivIsNeeded(channel *Channel) Reply {
return NewNumericReply(channel.server, ERR_CHANOPRIVSNEEDED,
"%s :You're not channel operator", channel.name)
}