Просмотр исходного кода

set the time of a multiline message at BATCH -

tags/v2.0.0-rc1
Shivaram Lingamneni 4 лет назад
Родитель
Сommit
6e2b2a44b8
2 измененных файлов: 8 добавлений и 6 удалений
  1. 4
    3
      irc/handlers.go
  2. 4
    3
      irc/utils/text.go

+ 4
- 3
irc/handlers.go Просмотреть файл

@@ -352,8 +352,6 @@ func batchHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
352 352
 			} else {
353 353
 				rb.session.batch.target = msg.Params[2]
354 354
 				// save the response label for later
355
-				// XXX changing the label inside a handler is a bit dodgy, but it works here
356
-				// because there's no way we could have triggered a flush up to this point
357 355
 				rb.session.batch.responseLabel = rb.Label
358 356
 				rb.Label = ""
359 357
 			}
@@ -366,12 +364,15 @@ func batchHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
366 364
 		} else {
367 365
 			batch := rb.session.batch
368 366
 			rb.session.batch = MultilineBatch{}
367
+			// time tag should correspond to the time when the message was completed
368
+			batch.message.SetTime()
369 369
 			histType, err := msgCommandToHistType(batch.command)
370 370
 			if err != nil {
371 371
 				histType = history.Privmsg
372 372
 				batch.command = "PRIVMSG"
373 373
 			}
374
-			// see previous caution about modifying ResponseBuffer.Label
374
+			// XXX changing the label inside a handler is a bit dodgy, but it works here
375
+			// because there's no way we could have triggered a flush up to this point
375 376
 			rb.Label = batch.responseLabel
376 377
 			dispatchMessageToTarget(client, batch.tags, histType, batch.command, batch.target, batch.message, rb)
377 378
 		}

+ 4
- 3
irc/utils/text.go Просмотреть файл

@@ -42,9 +42,6 @@ func MakeMessage(original string) (result SplitMessage) {
42 42
 }
43 43
 
44 44
 func (sm *SplitMessage) Append(message string, concat bool) {
45
-	if sm.Time.IsZero() {
46
-		sm.Time = time.Now().UTC()
47
-	}
48 45
 	if sm.Msgid == "" {
49 46
 		sm.Msgid = GenerateSecretToken()
50 47
 	}
@@ -54,6 +51,10 @@ func (sm *SplitMessage) Append(message string, concat bool) {
54 51
 	})
55 52
 }
56 53
 
54
+func (sm *SplitMessage) SetTime() {
55
+	sm.Time = time.Now().UTC()
56
+}
57
+
57 58
 func (sm *SplitMessage) LenLines() int {
58 59
 	if sm.Split == nil {
59 60
 		if sm.Message == "" {

Загрузка…
Отмена
Сохранить