|
@@ -1188,22 +1188,25 @@ func (channel *Channel) SetTopic(client *Client, topic string, rb *ResponseBuffe
|
1188
|
1188
|
channel.MarkDirty(IncludeTopic)
|
1189
|
1189
|
}
|
1190
|
1190
|
|
1191
|
|
-// CanSpeak returns true if the client can speak on this channel.
|
1192
|
|
-func (channel *Channel) CanSpeak(client *Client) bool {
|
|
1191
|
+// CanSpeak returns true if the client can speak on this channel, otherwise it returns false along with the channel mode preventing the client from speaking.
|
|
1192
|
+func (channel *Channel) CanSpeak(client *Client) (bool, modes.Mode) {
|
1193
|
1193
|
channel.stateMutex.RLock()
|
1194
|
1194
|
defer channel.stateMutex.RUnlock()
|
1195
|
1195
|
|
1196
|
1196
|
_, hasClient := channel.members[client]
|
1197
|
1197
|
if channel.flags.HasMode(modes.NoOutside) && !hasClient {
|
1198
|
|
- return false
|
|
1198
|
+ return false, modes.NoOutside
|
1199
|
1199
|
}
|
1200
|
1200
|
if channel.flags.HasMode(modes.Moderated) && !channel.ClientIsAtLeast(client, modes.Voice) {
|
1201
|
|
- return false
|
|
1201
|
+ return false, modes.Moderated
|
1202
|
1202
|
}
|
1203
|
1203
|
if channel.flags.HasMode(modes.RegisteredOnly) && client.Account() == "" {
|
1204
|
|
- return false
|
|
1204
|
+ return false, modes.RegisteredOnly
|
|
1205
|
+ }
|
|
1206
|
+ if channel.flags.HasMode(modes.RegisteredOnlySpeak) && client.Account() == "" && !channel.ClientIsAtLeast(client, modes.Voice) {
|
|
1207
|
+ return false, modes.RegisteredOnlySpeak
|
1205
|
1208
|
}
|
1206
|
|
- return true
|
|
1209
|
+ return true, modes.Mode('?')
|
1207
|
1210
|
}
|
1208
|
1211
|
|
1209
|
1212
|
func msgCommandToHistType(command string) (history.ItemType, error) {
|
|
@@ -1225,9 +1228,9 @@ func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mod
|
1225
|
1228
|
return
|
1226
|
1229
|
}
|
1227
|
1230
|
|
1228
|
|
- if !channel.CanSpeak(client) {
|
|
1231
|
+ if canSpeak, mode := channel.CanSpeak(client); !canSpeak {
|
1229
|
1232
|
if histType != history.Notice {
|
1230
|
|
- rb.Add(nil, client.server.name, ERR_CANNOTSENDTOCHAN, client.Nick(), channel.Name(), client.t("Cannot send to channel"))
|
|
1233
|
+ rb.Add(nil, client.server.name, ERR_CANNOTSENDTOCHAN, client.Nick(), channel.Name(), fmt.Sprintf(client.t("Cannot send to channel (+%s)"), mode))
|
1231
|
1234
|
}
|
1232
|
1235
|
return
|
1233
|
1236
|
}
|