mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
fix #307
This commit is contained in:
parent
50dc265e4d
commit
bd40b46639
5 changed files with 223 additions and 138 deletions
|
|
@ -1227,24 +1227,38 @@ func (channel *Channel) SetTopic(client *Client, topic string, rb *ResponseBuffe
|
|||
// 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.
|
||||
func (channel *Channel) CanSpeak(client *Client) (bool, modes.Mode) {
|
||||
channel.stateMutex.RLock()
|
||||
defer channel.stateMutex.RUnlock()
|
||||
clientModes, hasClient := channel.members[client]
|
||||
channel.stateMutex.RUnlock()
|
||||
|
||||
_, hasClient := channel.members[client]
|
||||
if channel.flags.HasMode(modes.NoOutside) && !hasClient {
|
||||
if !hasClient && channel.flags.HasMode(modes.NoOutside) {
|
||||
// TODO: enforce regular +b bans on -n channels?
|
||||
return false, modes.NoOutside
|
||||
}
|
||||
if channel.flags.HasMode(modes.Moderated) && !channel.ClientIsAtLeast(client, modes.Voice) {
|
||||
if channel.isMuted(client) && clientModes.HighestChannelUserMode() == modes.Mode(0) {
|
||||
return false, modes.BanMask
|
||||
}
|
||||
if channel.flags.HasMode(modes.Moderated) && clientModes.HighestChannelUserMode() == modes.Mode(0) {
|
||||
return false, modes.Moderated
|
||||
}
|
||||
if channel.flags.HasMode(modes.RegisteredOnly) && client.Account() == "" {
|
||||
return false, modes.RegisteredOnly
|
||||
}
|
||||
if channel.flags.HasMode(modes.RegisteredOnlySpeak) && client.Account() == "" && !channel.ClientIsAtLeast(client, modes.Voice) {
|
||||
if channel.flags.HasMode(modes.RegisteredOnlySpeak) && client.Account() == "" &&
|
||||
clientModes.HighestChannelUserMode() != modes.Mode(0) {
|
||||
return false, modes.RegisteredOnlySpeak
|
||||
}
|
||||
return true, modes.Mode('?')
|
||||
}
|
||||
|
||||
func (channel *Channel) isMuted(client *Client) bool {
|
||||
muteRe := channel.lists[modes.BanMask].MuteRegexp()
|
||||
if muteRe == nil {
|
||||
return false
|
||||
}
|
||||
nuh := client.NickMaskString()
|
||||
return muteRe.MatchString(nuh) && !channel.lists[modes.ExceptMask].MatchMute(nuh)
|
||||
}
|
||||
|
||||
func msgCommandToHistType(command string) (history.ItemType, error) {
|
||||
switch command {
|
||||
case "PRIVMSG":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue