3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 18:52:41 +01:00

channel 'no outside messages' flag

This commit is contained in:
Jeremy Latt 2014-02-08 23:33:56 -08:00
parent a3b7441939
commit 04f881a617
4 changed files with 39 additions and 14 deletions

View File

@ -113,8 +113,11 @@ func (channel *Channel) String() string {
}
// <mode> <mode params>
func (channel *Channel) ModeString() string {
return ""
func (channel *Channel) ModeString() (str string) {
if channel.noOutside {
str += NoOutside.String()
}
return
}
func (channel *Channel) Join(client *Client) {
@ -181,7 +184,12 @@ func (m *TopicCommand) HandleChannel(channel *Channel) {
}
func (m *PrivMsgCommand) HandleChannel(channel *Channel) {
channel.replies <- RplPrivMsg(m.Client(), channel, m.message)
client := m.Client()
if channel.noOutside && !channel.members.Has(client) {
client.replies <- ErrCannotSendToChan(channel)
return
}
channel.replies <- RplPrivMsg(client, channel, m.message)
}
func (msg *ChannelModeCommand) HandleChannel(channel *Channel) {
@ -195,6 +203,14 @@ func (msg *ChannelModeCommand) HandleChannel(channel *Channel) {
client.replies <- RplBanList(channel, banMask)
}
client.replies <- RplEndOfBanList(channel)
case NoOutside:
// TODO perms
switch modeOp.op {
case Add:
channel.noOutside = true
case Remove:
channel.noOutside = false
}
}
}

View File

@ -171,20 +171,20 @@ const (
ServerNotice UserMode = 's'
WallOps UserMode = 'w'
Anonymous ChannelMode = 'a'
Anonymous ChannelMode = 'a' // flag
BanMask ChannelMode = 'b' // arg
ExceptionMask ChannelMode = 'e' // arg
InviteMask ChannelMode = 'I' // arg
InviteOnly ChannelMode = 'i'
Key ChannelMode = 'k' // arg
Moderated ChannelMode = 'm'
NoOutside ChannelMode = 'n'
OpOnlyTopic ChannelMode = 't'
Private ChannelMode = 'p'
Quiet ChannelMode = 'q'
ReOp ChannelMode = 'r'
Secret ChannelMode = 's'
UserLimit ChannelMode = 'l' // arg
InviteOnly ChannelMode = 'i' // flag
Key ChannelMode = 'k' // flag arg
Moderated ChannelMode = 'm' // flag
NoOutside ChannelMode = 'n' // flag
OpOnlyTopic ChannelMode = 't' // flag
Private ChannelMode = 'p' // flag
Quiet ChannelMode = 'q' // flag
ReOp ChannelMode = 'r' // flag
Secret ChannelMode = 's' // flag
UserLimit ChannelMode = 'l' // flag arg
ChannelCreator UserChannelMode = 'O'
ChannelOperator UserChannelMode = 'o'

View File

@ -343,3 +343,8 @@ func ErrUserNotInChannel(server *Server, nick string, channel *Channel) Reply {
return NewNumericReply(server, ERR_USERNOTINCHANNEL,
"%s %s :They aren't on that channel", nick, channel.name)
}
func ErrCannotSendToChan(channel *Channel) Reply {
return NewNumericReply(channel.server, ERR_CANNOTSENDTOCHAN,
"%s :Cannot send to channel", channel.name)
}

View File

@ -20,6 +20,10 @@ type UserMode rune
// channel mode flags
type ChannelMode rune
func (mode ChannelMode) String() string {
return fmt.Sprintf("%c", mode)
}
// user-channel mode flags
type UserChannelMode rune