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

channel: Alert of given modes (+o/+q) on join

This commit is contained in:
Daniel Oaks 2017-03-24 12:38:07 +10:00
parent 6842d2ead6
commit 580385392a

View File

@ -277,6 +277,7 @@ func (channel *Channel) Join(client *Client, key string) {
client.channels.Add(channel) client.channels.Add(channel)
channel.members.Add(client) channel.members.Add(client)
var givenMode *Mode
if len(channel.members) == 1 { if len(channel.members) == 1 {
client.server.registeredChannelsMutex.Lock() client.server.registeredChannelsMutex.Lock()
defer client.server.registeredChannelsMutex.Unlock() defer client.server.registeredChannelsMutex.Unlock()
@ -286,10 +287,12 @@ func (channel *Channel) Join(client *Client, key string) {
if chanReg == nil { if chanReg == nil {
channel.createdTime = time.Now() channel.createdTime = time.Now()
channel.members[client][ChannelOperator] = true channel.members[client][ChannelOperator] = true
givenMode = &ChannelOperator
} else { } else {
// we should only do this on registered channels // we should only do this on registered channels
if client.account != nil && client.account.Name == chanReg.Founder { if client.account != nil && client.account.Name == chanReg.Founder {
channel.members[client][ChannelFounder] = true channel.members[client][ChannelFounder] = true
givenMode = &ChannelFounder
} }
channel.topic = chanReg.Topic channel.topic = chanReg.Topic
channel.topicSetBy = chanReg.TopicSetBy channel.topicSetBy = chanReg.TopicSetBy
@ -308,6 +311,9 @@ func (channel *Channel) Join(client *Client, key string) {
} }
channel.getTopicNoMutex(client) // we already have Lock channel.getTopicNoMutex(client) // we already have Lock
channel.namesNoMutex(client) channel.namesNoMutex(client)
if givenMode != nil {
client.Send(nil, client.server.name, "MODE", channel.name, fmt.Sprintf("+%v", *givenMode), client.nick)
}
} }
func (channel *Channel) Part(client *Client, message string) { func (channel *Channel) Part(client *Client, message string) {