mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
set the time of a multiline message at BATCH -
This commit is contained in:
parent
5d662742b9
commit
6e2b2a44b8
@ -352,8 +352,6 @@ func batchHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
|
|||||||
} else {
|
} else {
|
||||||
rb.session.batch.target = msg.Params[2]
|
rb.session.batch.target = msg.Params[2]
|
||||||
// save the response label for later
|
// save the response label for later
|
||||||
// XXX changing the label inside a handler is a bit dodgy, but it works here
|
|
||||||
// because there's no way we could have triggered a flush up to this point
|
|
||||||
rb.session.batch.responseLabel = rb.Label
|
rb.session.batch.responseLabel = rb.Label
|
||||||
rb.Label = ""
|
rb.Label = ""
|
||||||
}
|
}
|
||||||
@ -366,12 +364,15 @@ func batchHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
|
|||||||
} else {
|
} else {
|
||||||
batch := rb.session.batch
|
batch := rb.session.batch
|
||||||
rb.session.batch = MultilineBatch{}
|
rb.session.batch = MultilineBatch{}
|
||||||
|
// time tag should correspond to the time when the message was completed
|
||||||
|
batch.message.SetTime()
|
||||||
histType, err := msgCommandToHistType(batch.command)
|
histType, err := msgCommandToHistType(batch.command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
histType = history.Privmsg
|
histType = history.Privmsg
|
||||||
batch.command = "PRIVMSG"
|
batch.command = "PRIVMSG"
|
||||||
}
|
}
|
||||||
// see previous caution about modifying ResponseBuffer.Label
|
// XXX changing the label inside a handler is a bit dodgy, but it works here
|
||||||
|
// because there's no way we could have triggered a flush up to this point
|
||||||
rb.Label = batch.responseLabel
|
rb.Label = batch.responseLabel
|
||||||
dispatchMessageToTarget(client, batch.tags, histType, batch.command, batch.target, batch.message, rb)
|
dispatchMessageToTarget(client, batch.tags, histType, batch.command, batch.target, batch.message, rb)
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,6 @@ func MakeMessage(original string) (result SplitMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sm *SplitMessage) Append(message string, concat bool) {
|
func (sm *SplitMessage) Append(message string, concat bool) {
|
||||||
if sm.Time.IsZero() {
|
|
||||||
sm.Time = time.Now().UTC()
|
|
||||||
}
|
|
||||||
if sm.Msgid == "" {
|
if sm.Msgid == "" {
|
||||||
sm.Msgid = GenerateSecretToken()
|
sm.Msgid = GenerateSecretToken()
|
||||||
}
|
}
|
||||||
@ -54,6 +51,10 @@ func (sm *SplitMessage) Append(message string, concat bool) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sm *SplitMessage) SetTime() {
|
||||||
|
sm.Time = time.Now().UTC()
|
||||||
|
}
|
||||||
|
|
||||||
func (sm *SplitMessage) LenLines() int {
|
func (sm *SplitMessage) LenLines() int {
|
||||||
if sm.Split == nil {
|
if sm.Split == nil {
|
||||||
if sm.Message == "" {
|
if sm.Message == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user