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

Enable chanmode +r, fix bug with registering channels

This commit is contained in:
Daniel Oaks 2017-03-28 17:32:03 +10:00
parent 317a804644
commit 0046025d60
5 changed files with 27 additions and 15 deletions

View File

@ -425,6 +425,9 @@ func (channel *Channel) CanSpeak(client *Client) bool {
if channel.flags[Moderated] && !channel.clientIsAtLeastNoMutex(client, Voice) {
return false
}
if channel.flags[RegisteredOnly] && client.account == &NoAccount {
return false
}
return true
}

View File

@ -83,7 +83,7 @@ func (server *Server) chanservReceivePrivmsg(client *Client, message string) {
}
account := client.account
if account == nil {
if account == &NoAccount {
client.ChanServNotice("You must be logged in to register a channel")
return nil
}

View File

@ -21,25 +21,18 @@ var (
Oragono supports the following channel modes:
= Type A - list modes =
+b | Client masks that are banned from the channel.
+b | Client masks that are banned from the channel (e.g. *!*@127.0.0.1)
+e | Client masks that are exempted from bans.
+I | Client masks that are exempted from the invite-only flag.
= Type C - setting modes with a parameter =
+l | Client join limit for the channel.
+k | Key required when joining the channel.
= Type D - flag modes =
+i | Invite-only mode, only invited clients can join the channel.
+k | Key required when joining the channel.
+l | Client join limit for the channel.
+m | Moderated mode, only privileged clients can talk on the channel.
+n | No-outside-messages mode, only users that are on the channel can send
| messages to it.
+t | Only channel opers can modify the topic.
+r | Only registered users can talk in the channel.
+s | Secret mode, channel won't show up in /LIST or whois replies.
+t | Only channel opers can modify the topic.
= Prefixes =
@ -210,7 +203,7 @@ command is processed by that server.`,
text: `MODE <target> [<modestring> [<mode arguments>...]]
Sets and removes modes from the given target. For more specific information on
mode characters, see the help for "cmode" and "umode".`,
mode characters, see the help for "modes".`,
},
"monitor": {
text: `MONITOR <subcmd>
@ -417,6 +410,9 @@ Returns historical information on the last user with the given nickname.`,
},
// Informational
"modes": {
text: cmodeHelpText + "\n\n" + umodeHelpText,
},
"cmode": {
text: cmodeHelpText,
},

View File

@ -122,6 +122,7 @@ const (
Moderated Mode = 'm' // flag
NoOutside Mode = 'n' // flag
OpOnlyTopic Mode = 't' // flag
RegisteredOnly Mode = 'r' // flag
Secret Mode = 's' // flag
UserLimit Mode = 'l' // flag arg
)
@ -455,7 +456,7 @@ func ApplyChannelModeChanges(channel *Channel, client *Client, isSamode bool, ch
}
applied = append(applied, change)
case InviteOnly, Moderated, NoOutside, OpOnlyTopic, Secret, ChanRoleplaying:
case InviteOnly, Moderated, NoOutside, OpOnlyTopic, RegisteredOnly, Secret, ChanRoleplaying:
switch change.op {
case Add:
if channel.flags[change.mode] {

View File

@ -952,6 +952,10 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel")
continue
}
if !channel.CanSpeak(client) {
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel")
continue
}
msgid := server.generateMessageID()
channel.SplitPrivMsg(msgid, lowestPrefix, clientOnlyTags, client, splitMsg)
} else {
@ -1017,6 +1021,10 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel")
continue
}
if !channel.CanSpeak(client) {
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel")
continue
}
msgid := server.generateMessageID()
channel.TagMsg(msgid, lowestPrefix, clientOnlyTags, client)
@ -1610,6 +1618,10 @@ func noticeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// errors silently ignored with NOTICE as per RFC
continue
}
if !channel.CanSpeak(client) {
// errors silently ignored with NOTICE as per RFC
continue
}
msgid := server.generateMessageID()
channel.SplitNotice(msgid, lowestPrefix, clientOnlyTags, client, splitMsg)
} else {