mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
fix #532
This commit is contained in:
parent
bd088ea197
commit
eebe681538
@ -1070,6 +1070,25 @@ func (channel *Channel) replayHistoryItems(rb *ResponseBuffer, items []history.I
|
||||
message := fmt.Sprintf(client.t("%[1]s changed nick to %[2]s"), nick, item.Params[0])
|
||||
rb.AddFromClient(item.Message.Time, utils.MungeSecretToken(item.Message.Msgid), histServMask, "*", nil, "PRIVMSG", chname, message)
|
||||
}
|
||||
case history.Topic:
|
||||
if eventPlayback {
|
||||
rb.AddFromClient(item.Message.Time, item.Message.Msgid, item.Nick, item.AccountName, nil, "TOPIC", chname, item.Message.Message)
|
||||
} else {
|
||||
message := fmt.Sprintf(client.t("%[1]s set the channel topic to: %[2]s"), nick, item.Message.Message)
|
||||
rb.AddFromClient(item.Message.Time, utils.MungeSecretToken(item.Message.Msgid), histServMask, "*", nil, "PRIVMSG", chname, message)
|
||||
}
|
||||
case history.Mode:
|
||||
params := make([]string, len(item.Message.Split)+1)
|
||||
params[0] = chname
|
||||
for i, pair := range item.Message.Split {
|
||||
params[i+1] = pair.Message
|
||||
}
|
||||
if eventPlayback {
|
||||
rb.AddFromClient(item.Message.Time, item.Message.Msgid, item.Nick, item.AccountName, nil, "MODE", params...)
|
||||
} else {
|
||||
message := fmt.Sprintf(client.t("%[1]s set channel modes: %[2]s"), nick, strings.Join(params[1:], " "))
|
||||
rb.AddFromClient(item.Message.Time, utils.MungeSecretToken(item.Message.Msgid), histServMask, "*", nil, "PRIVMSG", chname, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1119,22 +1138,30 @@ func (channel *Channel) SetTopic(client *Client, topic string, rb *ResponseBuffe
|
||||
}
|
||||
|
||||
channel.stateMutex.Lock()
|
||||
chname := channel.name
|
||||
channel.topic = topic
|
||||
channel.topicSetBy = client.nickMaskString
|
||||
channel.topicSetTime = time.Now().UTC()
|
||||
channel.stateMutex.Unlock()
|
||||
|
||||
prefix := client.NickMaskString()
|
||||
details := client.Details()
|
||||
message := utils.MakeMessage(topic)
|
||||
rb.AddFromClient(message.Time, message.Msgid, details.nickMask, details.accountName, nil, "TOPIC", chname, topic)
|
||||
for _, member := range channel.Members() {
|
||||
for _, session := range member.Sessions() {
|
||||
if session == rb.session {
|
||||
rb.Add(nil, prefix, "TOPIC", channel.name, topic)
|
||||
} else {
|
||||
session.Send(nil, prefix, "TOPIC", channel.name, topic)
|
||||
if session != rb.session {
|
||||
session.sendFromClientInternal(false, message.Time, message.Msgid, details.nickMask, details.accountName, nil, "TOPIC", chname, topic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
channel.AddHistoryItem(history.Item{
|
||||
Type: history.Topic,
|
||||
Nick: details.nickMask,
|
||||
AccountName: details.accountName,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
channel.MarkDirty(IncludeTopic)
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ func csAmodeHandler(server *Server, client *Client, command string, params []str
|
||||
if member.Account() == change.Arg {
|
||||
applied, change := channel.applyModeToMember(client, change, rb)
|
||||
if applied {
|
||||
announceCmodeChanges(channel, modes.ModeChanges{change}, chanservMask, rb)
|
||||
announceCmodeChanges(channel, modes.ModeChanges{change}, chanservMask, "*", rb)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,7 +291,7 @@ func csOpHandler(server *Server, client *Client, command string, params []string
|
||||
},
|
||||
rb)
|
||||
if applied {
|
||||
announceCmodeChanges(channelInfo, modes.ModeChanges{change}, chanservMask, rb)
|
||||
announceCmodeChanges(channelInfo, modes.ModeChanges{change}, chanservMask, "*", rb)
|
||||
}
|
||||
|
||||
csNotice(rb, fmt.Sprintf(client.t("Successfully op'd in channel %s"), channelName))
|
||||
@ -343,7 +343,7 @@ func csRegisterHandler(server *Server, client *Client, command string, params []
|
||||
},
|
||||
rb)
|
||||
if applied {
|
||||
announceCmodeChanges(channelInfo, modes.ModeChanges{change}, chanservMask, rb)
|
||||
announceCmodeChanges(channelInfo, modes.ModeChanges{change}, chanservMask, "*", rb)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1520,24 +1520,35 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
|
||||
}
|
||||
// process mode changes, include list operations (an empty set of changes does a list)
|
||||
applied := channel.ApplyChannelModeChanges(client, msg.Command == "SAMODE", changes, rb)
|
||||
announceCmodeChanges(channel, applied, client.NickMaskString(), rb)
|
||||
details := client.Details()
|
||||
announceCmodeChanges(channel, applied, details.nickMask, details.accountName, rb)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func announceCmodeChanges(channel *Channel, applied modes.ModeChanges, source string, rb *ResponseBuffer) {
|
||||
func announceCmodeChanges(channel *Channel, applied modes.ModeChanges, source, accountName string, rb *ResponseBuffer) {
|
||||
// send out changes
|
||||
if len(applied) > 0 {
|
||||
//TODO(dan): we should change the name of String and make it return a slice here
|
||||
args := append([]string{channel.name}, applied.Strings()...)
|
||||
rb.Add(nil, source, "MODE", args...)
|
||||
message := utils.MakeMessage("")
|
||||
changeStrings := applied.Strings()
|
||||
for _, changeString := range changeStrings {
|
||||
message.Split = append(message.Split, utils.MessagePair{Message: changeString})
|
||||
}
|
||||
args := append([]string{channel.name}, changeStrings...)
|
||||
rb.AddFromClient(message.Time, message.Msgid, source, accountName, nil, "MODE", args...)
|
||||
for _, member := range channel.Members() {
|
||||
for _, session := range member.Sessions() {
|
||||
if session != rb.session {
|
||||
session.Send(nil, source, "MODE", args...)
|
||||
session.sendFromClientInternal(false, message.Time, message.Msgid, source, accountName, nil, "MODE", args...)
|
||||
}
|
||||
}
|
||||
}
|
||||
channel.AddHistoryItem(history.Item{
|
||||
Type: history.Mode,
|
||||
Nick: source,
|
||||
AccountName: accountName,
|
||||
Message: message,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ const (
|
||||
Mode
|
||||
Tagmsg
|
||||
Nick
|
||||
Topic
|
||||
)
|
||||
|
||||
const (
|
||||
|
Loading…
Reference in New Issue
Block a user