Browse Source

Merge pull request #148 from ShaneMcC/TimestampProcessors

Make all IRCProcessors handle timestamps.
pull/152/head
Shane Mc Cormack 7 years ago
parent
commit
291351d0c8
29 changed files with 184 additions and 228 deletions
  1. 1
    1
      irc/src/main/java/com/dmdirc/parser/irc/IRCParser.java
  2. 5
    20
      irc/src/main/java/com/dmdirc/parser/irc/ProcessingManager.java
  3. 0
    62
      irc/src/main/java/com/dmdirc/parser/irc/TimestampedIRCProcessor.java
  4. 4
    1
      irc/src/main/java/com/dmdirc/parser/irc/processors/IRCProcessor.java
  5. 2
    1
      irc/src/main/java/com/dmdirc/parser/irc/processors/Process001.java
  6. 1
    1
      irc/src/main/java/com/dmdirc/parser/irc/processors/Process004005.java
  7. 4
    4
      irc/src/main/java/com/dmdirc/parser/irc/processors/Process464.java
  8. 3
    1
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessAccount.java
  9. 5
    5
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessAway.java
  10. 1
    2
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessCap.java
  11. 4
    4
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessInvite.java
  12. 11
    8
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessJoin.java
  13. 7
    5
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessKick.java
  14. 4
    4
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessList.java
  15. 7
    5
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessListModes.java
  16. 10
    10
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMOTD.java
  17. 2
    2
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMessage.java
  18. 30
    23
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMode.java
  19. 7
    7
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessNames.java
  20. 10
    7
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessNick.java
  21. 4
    4
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessNickInUse.java
  22. 4
    4
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessNoticeAuth.java
  23. 7
    5
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessPart.java
  24. 12
    9
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessQuit.java
  25. 7
    5
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessTopic.java
  26. 10
    10
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessWallops.java
  27. 10
    10
      irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessWho.java
  28. 9
    7
      irc/src/test/java/com/dmdirc/parser/irc/processors/Process001Test.java
  29. 3
    1
      irc/src/test/java/com/dmdirc/parser/irc/processors/Process464Test.java

+ 1
- 1
irc/src/main/java/com/dmdirc/parser/irc/IRCParser.java View File

@@ -1214,7 +1214,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
1214 1214
                         case IrcConstants.NUMERIC_ERROR_PASSWORD_MISMATCH:
1215 1215
                         case IrcConstants.NUMERIC_ERROR_NICKNAME_IN_USE:
1216 1216
                             try {
1217
-                                myProcessingManager.process(sParam, token);
1217
+                                myProcessingManager.process(lineTS, sParam, token);
1218 1218
                             } catch (ProcessorNotFoundException e) {
1219 1219
                             }
1220 1220
                             break;

+ 5
- 20
irc/src/main/java/com/dmdirc/parser/irc/ProcessingManager.java View File

@@ -125,17 +125,6 @@ public class ProcessingManager {
125 125
         }
126 126
     }
127 127
 
128
-    /**
129
-     * Process a Line.
130
-     *
131
-     * @param sParam Type of line to process ("005", "PRIVMSG" etc)
132
-     * @param token IRCTokenised line to process
133
-     * @throws ProcessorNotFoundException exception if no processors exists to handle the line
134
-     */
135
-    public void process(final String sParam, final String... token) throws ProcessorNotFoundException {
136
-        process(LocalDateTime.now(), sParam, token);
137
-    }
138
-
139 128
     /**
140 129
      * Process a Line.
141 130
      *
@@ -149,11 +138,7 @@ public class ProcessingManager {
149 138
         IRCProcessor messageProcessor = null;
150 139
         try {
151 140
             messageProcessor = getProcessor(sParam);
152
-            if (messageProcessor instanceof TimestampedIRCProcessor) {
153
-                ((TimestampedIRCProcessor)messageProcessor).process(date, sParam, token);
154
-            } else {
155
-                messageProcessor.process(sParam, token);
156
-            }
141
+            messageProcessor.process(date, sParam, token);
157 142
         } catch (ProcessorNotFoundException p) {
158 143
             throw p;
159 144
         } catch (Exception e) {
@@ -164,9 +149,9 @@ public class ProcessingManager {
164 149
             parser.callErrorInfo(ei);
165 150
         } finally {
166 151
             // Try to call callNumeric. We don't want this to work if sParam is a non
167
-            // integer param, hense the empty catch
152
+            // integer param, hence the empty catch
168 153
             try {
169
-                callNumeric(Integer.parseInt(sParam), token);
154
+                callNumeric(date, Integer.parseInt(sParam), token);
170 155
             } catch (NumberFormatException e) {
171 156
             }
172 157
         }
@@ -178,8 +163,8 @@ public class ProcessingManager {
178 163
      * @param numeric What numeric is this for
179 164
      * @param token IRC Tokenised line
180 165
      */
181
-    protected void callNumeric(final int numeric, final String... token) {
182
-        parser.getCallbackManager().publish(new NumericEvent(parser, LocalDateTime.now(), numeric,
166
+    protected void callNumeric(final LocalDateTime time, final int numeric, final String... token) {
167
+        parser.getCallbackManager().publish(new NumericEvent(parser, time, numeric,
183 168
                 token));
184 169
     }
185 170
 }

+ 0
- 62
irc/src/main/java/com/dmdirc/parser/irc/TimestampedIRCProcessor.java View File

@@ -1,62 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2017 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.parser.irc;
24
-
25
-import com.dmdirc.parser.irc.processors.IRCProcessor;
26
-
27
-import java.time.LocalDateTime;
28
-
29
-/**
30
- * TimestampedIRCProcessor.
31
- *
32
- * Superclass for all IRCProcessor types that accept timestamps for process.
33
- */
34
-public abstract class TimestampedIRCProcessor extends IRCProcessor {
35
-
36
-    /**
37
-     * Create a new instance of the IRCTimestampedProcessor Object.
38
-     *
39
-     * @param parser IRCParser That owns this IRCProcessor
40
-     * @param handledTokens Tokens that this processor handles
41
-     */
42
-    protected TimestampedIRCProcessor(final IRCParser parser, final String... handledTokens) {
43
-        super(parser, handledTokens);
44
-    }
45
-
46
-    @Override
47
-    public final void process(final String sParam, final String... token) {
48
-        process(LocalDateTime.now(), sParam, token);
49
-    }
50
-
51
-    /**
52
-     * Process a Line.
53
-     *
54
-     * @param date Date of this line
55
-     * @param sParam Type of line to process ("005", "PRIVMSG" etc)
56
-     * @param token IRCTokenised line to process
57
-     */
58
-    public abstract void process(final LocalDateTime date, final String sParam,
59
-            final String... token);
60
-
61
-
62
-}

+ 4
- 1
irc/src/main/java/com/dmdirc/parser/irc/processors/IRCProcessor.java View File

@@ -29,6 +29,8 @@ import com.dmdirc.parser.irc.IRCChannelInfo;
29 29
 import com.dmdirc.parser.irc.IRCClientInfo;
30 30
 import com.dmdirc.parser.irc.IRCParser;
31 31
 
32
+import java.time.LocalDateTime;
33
+
32 34
 /**
33 35
  * IRCProcessor.
34 36
  * Superclass for all IRCProcessor types.
@@ -130,10 +132,11 @@ public abstract class IRCProcessor {
130 132
     /**
131 133
      * Process a Line.
132 134
      *
135
+     * @param date Date of this line
133 136
      * @param sParam Type of line to process ("005", "PRIVMSG" etc)
134 137
      * @param token IRCTokenised line to process
135 138
      */
136
-    public abstract void process(final String sParam, final String... token);
139
+    public abstract void process(final LocalDateTime date, final String sParam, final String... token);
137 140
 
138 141
     /**
139 142
      * What does this IRCProcessor handle.

+ 2
- 1
irc/src/main/java/com/dmdirc/parser/irc/processors/Process001.java View File

@@ -26,6 +26,7 @@ import com.dmdirc.parser.common.ChannelJoinRequest;
26 26
 import com.dmdirc.parser.common.ParserError;
27 27
 import com.dmdirc.parser.irc.IRCParser;
28 28
 
29
+import java.time.LocalDateTime;
29 30
 import java.util.Collection;
30 31
 
31 32
 import javax.inject.Inject;
@@ -52,7 +53,7 @@ public class Process001 extends IRCProcessor {
52 53
      * @param token IRCTokenised line to process
53 54
      */
54 55
     @Override
55
-    public void process(final String sParam, final String... token) {
56
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
56 57
         parser.got001 = true;
57 58
         // << :demon1.uk.quakenet.org 001 Java-Test :Welcome to the QuakeNet IRC Network, Java-Test
58 59
         parser.updateServerName(token[0].substring(1, token[0].length()));

+ 1
- 1
irc/src/main/java/com/dmdirc/parser/irc/processors/Process004005.java View File

@@ -58,7 +58,7 @@ public class Process004005 extends IRCProcessor {
58 58
      * @param token IRCTokenised line to process
59 59
      */
60 60
     @Override
61
-    public void process(final String sParam, final String... token) {
61
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
62 62
         switch (sParam) {
63 63
             case "002":
64 64
                 process002();

+ 4
- 4
irc/src/main/java/com/dmdirc/parser/irc/processors/Process464.java View File

@@ -51,14 +51,14 @@ public class Process464 extends IRCProcessor {
51 51
      * @param token IRCTokenised line to process
52 52
      */
53 53
     @Override
54
-    public void process(final String sParam, final String... token) {
55
-        callPasswordRequired();
54
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
55
+        callPasswordRequired(time);
56 56
     }
57 57
 
58 58
     /**
59 59
      * Callback to all objects implementing the PasswordRequired Callback.
60 60
      */
61
-    protected void callPasswordRequired() {
62
-        getCallbackManager().publish(new PasswordRequiredEvent(parser, LocalDateTime.now()));
61
+    protected void callPasswordRequired(final LocalDateTime time) {
62
+        getCallbackManager().publish(new PasswordRequiredEvent(parser, time));
63 63
     }
64 64
 }

+ 3
- 1
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessAccount.java View File

@@ -25,6 +25,8 @@ package com.dmdirc.parser.irc.processors;
25 25
 import com.dmdirc.parser.irc.IRCClientInfo;
26 26
 import com.dmdirc.parser.irc.IRCParser;
27 27
 
28
+import java.time.LocalDateTime;
29
+
28 30
 import javax.inject.Inject;
29 31
 
30 32
 /**
@@ -49,7 +51,7 @@ public class ProcessAccount extends IRCProcessor {
49 51
      * @param token IRCTokenised line to process
50 52
      */
51 53
     @Override
52
-    public void process(final String sParam, final String... token) {
54
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
53 55
         // :nick!user@host ACCOUNT accountname
54 56
         final IRCClientInfo iClient = getClientInfo(token[0]);
55 57
         if (iClient != null) {

+ 5
- 5
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessAway.java View File

@@ -52,7 +52,7 @@ public class ProcessAway extends IRCProcessor {
52 52
      * @param token IRCTokenised line to process
53 53
      */
54 54
     @Override
55
-    public void process(final String sParam, final String... token) {
55
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
56 56
         final IRCClientInfo iClient = getClientInfo(token[0]);
57 57
         switch (sParam) {
58 58
             case "AWAY":
@@ -64,7 +64,7 @@ public class ProcessAway extends IRCProcessor {
64 64
                     iClient.setAwayState(reason.isEmpty() ? AwayState.HERE : AwayState.AWAY);
65 65
 
66 66
                     if (iClient == parser.getLocalClient()) {
67
-                        callAwayState(oldState, iClient.getAwayState(), iClient.getAwayReason());
67
+                        callAwayState(time, oldState, iClient.getAwayState(), iClient.getAwayReason());
68 68
                     }
69 69
                 }
70 70
                 break;
@@ -78,7 +78,7 @@ public class ProcessAway extends IRCProcessor {
78 78
                 // IRC HERE/BACK response
79 79
                 final AwayState oldState = parser.getLocalClient().getAwayState();
80 80
                 parser.getLocalClient().setAwayState("306".equals(sParam) ? AwayState.AWAY : AwayState.HERE);
81
-                callAwayState(oldState, parser.getLocalClient().getAwayState(), parser.getLocalClient().getAwayReason());
81
+                callAwayState(time, oldState, parser.getLocalClient().getAwayState(), parser.getLocalClient().getAwayReason());
82 82
                 break;
83 83
         }
84 84
     }
@@ -90,10 +90,10 @@ public class ProcessAway extends IRCProcessor {
90 90
      * @param currentState Current Away State
91 91
      * @param reason Best guess at away reason
92 92
      */
93
-    protected void callAwayState(final AwayState oldState, final AwayState currentState,
93
+    protected void callAwayState(final LocalDateTime time, final AwayState oldState, final AwayState currentState,
94 94
             final String reason) {
95 95
         getCallbackManager().publish(
96
-                new AwayStateEvent(parser, LocalDateTime.now(), oldState, currentState, reason));
96
+                new AwayStateEvent(parser, time, oldState, currentState, reason));
97 97
     }
98 98
 
99 99
 }

+ 1
- 2
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessCap.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.parser.irc.processors;
24 24
 
25 25
 import com.dmdirc.parser.irc.CapabilityState;
26 26
 import com.dmdirc.parser.irc.IRCParser;
27
-import com.dmdirc.parser.irc.TimestampedIRCProcessor;
28 27
 
29 28
 import java.time.LocalDateTime;
30 29
 import java.util.ArrayList;
@@ -44,7 +43,7 @@ import javax.inject.Inject;
44 43
  * See: http://www.leeh.co.uk/draft-mitchell-irc-capabilities-02.html
45 44
  * See: http://ircv3.atheme.org/specification/capability-negotiation-3.1
46 45
  */
47
-public class ProcessCap extends TimestampedIRCProcessor {
46
+public class ProcessCap extends IRCProcessor {
48 47
     /** Have we handled the pre-connect cap request? */
49 48
     private boolean hasCapped;
50 49
     /** List of supported capabilities. */

+ 4
- 4
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessInvite.java View File

@@ -51,10 +51,10 @@ public class ProcessInvite extends IRCProcessor {
51 51
      * @param token IRCTokenised line to process
52 52
      */
53 53
     @Override
54
-    public void process(final String sParam, final String... token) {
54
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
55 55
         // :Tobavaj!shane@Tobavaj.users.quakenet.org INVITE Dataforce #dataforceisgod 1188846462
56 56
         if (token.length > 2) {
57
-            callInvite(token[0].substring(1), token[3]);
57
+            callInvite(time, token[0].substring(1), token[3]);
58 58
         }
59 59
     }
60 60
 
@@ -64,9 +64,9 @@ public class ProcessInvite extends IRCProcessor {
64 64
      * @param userHost The hostname of the person who invited us
65 65
      * @param channel The name of the channel we were invited to
66 66
      */
67
-    protected void callInvite(final String userHost, final String channel) {
67
+    protected void callInvite(final LocalDateTime time, final String userHost, final String channel) {
68 68
         getCallbackManager().publish(new InviteEvent(
69
-                parser, LocalDateTime.now(), userHost, channel));
69
+                parser, time, userHost, channel));
70 70
     }
71 71
 
72 72
 }

+ 11
- 8
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessJoin.java View File

@@ -84,11 +84,12 @@ public class ProcessJoin extends IRCProcessor {
84 84
     /**
85 85
      * Process a channel join.
86 86
      *
87
+     * @param date The LocalDateTime that this event occurred at.
87 88
      * @param sParam Type of line to process ("JOIN")
88 89
      * @param token IRCTokenised line to process
89 90
      */
90 91
     @Override
91
-    public void process(final String sParam, final String... token) {
92
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
92 93
         callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: %s | %s", sParam, Arrays.toString(token));
93 94
 
94 95
         if ("329".equals(sParam)) {
@@ -153,7 +154,7 @@ public class ProcessJoin extends IRCProcessor {
153 154
                         } else {
154 155
                             // If we are joining a channel we are already on, fake a part from
155 156
                             // the channel internally, and rejoin.
156
-                            parser.getProcessingManager().process("PART", token);
157
+                            parser.getProcessingManager().process(date, "PART", token);
157 158
                         }
158 159
                     } catch (ProcessorNotFoundException e) {
159 160
                     }
@@ -162,7 +163,7 @@ public class ProcessJoin extends IRCProcessor {
162 163
                     // joined.
163 164
                     callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Adding client to channel.");
164 165
                     final IRCChannelClientInfo iChannelClient = iChannel.addClient(iClient);
165
-                    callChannelJoin(iChannel, iChannelClient);
166
+                    callChannelJoin(date, iChannel, iChannelClient);
166 167
                     callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Added client to channel.");
167 168
                     return;
168 169
                 } else {
@@ -189,7 +190,7 @@ public class ProcessJoin extends IRCProcessor {
189 190
                 pendingJoins.clear();
190 191
             }
191 192
 
192
-            callChannelSelfJoin(iChannel);
193
+            callChannelSelfJoin(date, iChannel);
193 194
         } else {
194 195
             // Some kind of failed to join, pop the pending join queues.
195 196
             final PendingJoin pendingJoin = pendingJoins.poll();
@@ -239,23 +240,25 @@ public class ProcessJoin extends IRCProcessor {
239 240
     /**
240 241
      * Callback to all objects implementing the ChannelJoin Callback.
241 242
      *
243
+     * @param date The LocalDateTime that this event occurred at.
242 244
      * @param cChannel Channel Object
243 245
      * @param cChannelClient ChannelClient object for new person
244 246
      */
245
-    protected void callChannelJoin(final ChannelInfo cChannel,
247
+    protected void callChannelJoin(final LocalDateTime date, final ChannelInfo cChannel,
246 248
             final ChannelClientInfo cChannelClient) {
247 249
         getCallbackManager().publish(
248
-                new ChannelJoinEvent(parser, LocalDateTime.now(), cChannel, cChannelClient));
250
+                new ChannelJoinEvent(parser, date, cChannel, cChannelClient));
249 251
     }
250 252
 
251 253
     /**
252 254
      * Callback to all objects implementing the ChannelSelfJoin Callback.
253 255
      *
256
+     * @param date The LocalDateTime that this event occurred at.
254 257
      * @param cChannel Channel Object
255 258
      */
256
-    protected void callChannelSelfJoin(final ChannelInfo cChannel) {
259
+    protected void callChannelSelfJoin(final LocalDateTime date, final ChannelInfo cChannel) {
257 260
         getCallbackManager().publish(new ChannelSelfJoinEvent(
258
-                parser, LocalDateTime.now(), cChannel));
261
+                parser, date, cChannel));
259 262
     }
260 263
 
261 264
 

+ 7
- 5
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessKick.java View File

@@ -54,11 +54,12 @@ public class ProcessKick extends IRCProcessor {
54 54
     /**
55 55
      * Process a channel kick.
56 56
      *
57
+     * @param date The LocalDateTime that this event occurred at.
57 58
      * @param sParam Type of line to process ("KICK")
58 59
      * @param token IRCTokenised line to process
59 60
      */
60 61
     @Override
61
-    public void process(final String sParam, final String... token) {
62
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
62 63
         callDebugInfo(IRCParser.DEBUG_INFO, "processKick: %s | %s", sParam, Arrays.toString(token));
63 64
 
64 65
         final IRCClientInfo iClient = getClientInfo(token[3]);
@@ -93,14 +94,14 @@ public class ProcessKick extends IRCProcessor {
93 94
             final IRCChannelClientInfo iChannelKicker = iChannel.getChannelClient(token[0], true);
94 95
             if (parser.getRemoveAfterCallback()) {
95 96
                 callDebugInfo(IRCParser.DEBUG_INFO, "processKick: calling kick before. {%s | %s | %s | %s | %s}", iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
96
-                callChannelKick(iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
97
+                callChannelKick(date, iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
97 98
             }
98 99
             callDebugInfo(IRCParser.DEBUG_INFO, "processKick: removing client from channel { %s | %s }", iChannel, iClient);
99 100
             iChannel.delClient(iClient);
100 101
             callDebugInfo(IRCParser.DEBUG_INFO, "processKick: removed client from channel { %s | %s }", iChannel, iClient);
101 102
             if (!parser.getRemoveAfterCallback()) {
102 103
                 callDebugInfo(IRCParser.DEBUG_INFO, "processKick: calling kick after. {%s | %s | %s | %s | %s}", iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
103
-                callChannelKick(iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
104
+                callChannelKick(date, iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
104 105
             }
105 106
             if (iClient == parser.getLocalClient()) {
106 107
                 iChannel.emptyChannel();
@@ -112,17 +113,18 @@ public class ProcessKick extends IRCProcessor {
112 113
     /**
113 114
      * Callback to all objects implementing the ChannelKick Callback.
114 115
      *
116
+     * @param date The LocalDateTime that this event occurred at.
115 117
      * @param cChannel Channel where the kick took place
116 118
      * @param cKickedClient ChannelClient that got kicked
117 119
      * @param cKickedByClient ChannelClient that did the kicking
118 120
      * @param sReason Reason for kick (may be "")
119 121
      * @param sKickedByHost Hostname of Kicker (or servername)
120 122
      */
121
-    protected void callChannelKick(final ChannelInfo cChannel,
123
+    protected void callChannelKick(final LocalDateTime date, final ChannelInfo cChannel,
122 124
             final ChannelClientInfo cKickedClient, final ChannelClientInfo cKickedByClient,
123 125
             final String sReason, final String sKickedByHost) {
124 126
         getCallbackManager().publish(
125
-                new ChannelKickEvent(parser, LocalDateTime.now(), cChannel, cKickedClient,
127
+                new ChannelKickEvent(parser, date, cChannel, cKickedClient,
126 128
                         cKickedByClient, sReason, sKickedByHost));
127 129
     }
128 130
 

+ 4
- 4
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessList.java View File

@@ -53,20 +53,20 @@ public class ProcessList extends IRCProcessor {
53 53
      * @param token IRCTokenised line to process
54 54
      */
55 55
     @Override
56
-    public void process(final String sParam, final String... token) {
56
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
57 57
         // :port80b.se.quakenet.org 321 MD87 Channel :Users  Name
58 58
         // :port80b.se.quakenet.org 322 MD87 #DMDirc 10 :
59 59
         // :port80b.se.quakenet.org 323 MD87 :End of /LIST
60 60
         switch (sParam) {
61 61
             case "321":
62
-                getCallbackManager().publish(new GroupListStartEvent(parser, LocalDateTime.now()));
62
+                getCallbackManager().publish(new GroupListStartEvent(parser, time));
63 63
                 break;
64 64
             case "322":
65
-                getCallbackManager().publish(new GroupListEntryEvent(parser, LocalDateTime.now(),
65
+                getCallbackManager().publish(new GroupListEntryEvent(parser, time,
66 66
                         token[3], Integer.parseInt(token[4]), token[5]));
67 67
                 break;
68 68
             case "323":
69
-                getCallbackManager().publish(new GroupListEndEvent(parser, LocalDateTime.now()));
69
+                getCallbackManager().publish(new GroupListEndEvent(parser, time));
70 70
                 break;
71 71
         }
72 72
     }

+ 7
- 5
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessListModes.java View File

@@ -66,11 +66,12 @@ public class ProcessListModes extends IRCProcessor {
66 66
     /**
67 67
      * Process a ListModes.
68 68
      *
69
+     * @param date The LocalDateTime that this event occurred at.
69 70
      * @param sParam Type of line to process
70 71
      * @param token IRCTokenised line to process
71 72
      */
72 73
     @Override
73
-    public void process(final String sParam, final String... token) {
74
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
74 75
         final IRCChannelInfo channel = getChannel(token[3]);
75 76
         final ServerType serverType = parser.getServerType();
76 77
         if (channel == null) {
@@ -271,9 +272,9 @@ public class ProcessListModes extends IRCProcessor {
271 272
                             .stream()
272 273
                             .filter(thisMode -> parser.chanModesOther
273 274
                                     .get(thisMode) == IRCParser.MODE_LIST)
274
-                            .forEach(thisMode -> callChannelGotListModes(channel, thisMode));
275
+                            .forEach(thisMode -> callChannelGotListModes(date, channel, thisMode));
275 276
                 } else {
276
-                    callChannelGotListModes(channel, mode);
277
+                    callChannelGotListModes(date, channel, mode);
277 278
                 }
278 279
             }
279 280
         }
@@ -282,11 +283,12 @@ public class ProcessListModes extends IRCProcessor {
282 283
     /**
283 284
      * Callback to all objects implementing the ChannelGotListModes Callback.
284 285
      *
286
+     * @param date The LocalDateTime that this event occurred at.
285 287
      * @param cChannel Channel which the ListModes reply is for
286 288
      * @param mode the mode that we got list modes for.
287 289
      */
288
-    protected void callChannelGotListModes(final ChannelInfo cChannel, final char mode) {
289
-        getCallbackManager().publish(new ChannelListModeEvent(parser, LocalDateTime.now(), cChannel,
290
+    protected void callChannelGotListModes(final LocalDateTime date, final ChannelInfo cChannel, final char mode) {
291
+        getCallbackManager().publish(new ChannelListModeEvent(parser, date, cChannel,
290 292
                 mode));
291 293
     }
292 294
 }

+ 10
- 10
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMOTD.java View File

@@ -53,16 +53,16 @@ public class ProcessMOTD extends IRCProcessor {
53 53
      * @param token IRCTokenised line to process
54 54
      */
55 55
     @Override
56
-    public void process(final String sParam, final String... token) {
56
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
57 57
         switch (sParam) {
58 58
             case "375":
59
-                callMOTDStart(token[token.length - 1]);
59
+                callMOTDStart(time, token[token.length - 1]);
60 60
                 break;
61 61
             case "372":
62
-                callMOTDLine(token[token.length - 1]);
62
+                callMOTDLine(time, token[token.length - 1]);
63 63
                 break;
64 64
             default:
65
-                callMOTDEnd("422".equals(sParam), token[token.length - 1]);
65
+                callMOTDEnd(time, "422".equals(sParam), token[token.length - 1]);
66 66
                 break;
67 67
         }
68 68
     }
@@ -73,8 +73,8 @@ public class ProcessMOTD extends IRCProcessor {
73 73
      * @param noMOTD Was this an MOTDEnd or NoMOTD
74 74
      * @param data The contents of the line (incase of language changes or so)
75 75
      */
76
-    protected void callMOTDEnd(final boolean noMOTD, final String data) {
77
-        getCallbackManager().publish(new MOTDEndEvent(parser, LocalDateTime.now(), noMOTD, data));
76
+    protected void callMOTDEnd(final LocalDateTime time, final boolean noMOTD, final String data) {
77
+        getCallbackManager().publish(new MOTDEndEvent(parser, time, noMOTD, data));
78 78
     }
79 79
 
80 80
     /**
@@ -82,8 +82,8 @@ public class ProcessMOTD extends IRCProcessor {
82 82
      *
83 83
      * @param data Incomming Line.
84 84
      */
85
-    protected void callMOTDLine(final String data) {
86
-        getCallbackManager().publish(new MOTDLineEvent(parser, LocalDateTime.now(), data));
85
+    protected void callMOTDLine(final LocalDateTime time, final String data) {
86
+        getCallbackManager().publish(new MOTDLineEvent(parser, time, data));
87 87
     }
88 88
 
89 89
     /**
@@ -91,8 +91,8 @@ public class ProcessMOTD extends IRCProcessor {
91 91
      *
92 92
      * @param data Incomming Line.
93 93
      */
94
-    protected void callMOTDStart(final String data) {
95
-        getCallbackManager().publish(new MOTDStartEvent(parser, LocalDateTime.now(), data));
94
+    protected void callMOTDStart(final LocalDateTime time, final String data) {
95
+        getCallbackManager().publish(new MOTDStartEvent(parser, time, data));
96 96
     }
97 97
 
98 98
 }

+ 2
- 2
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMessage.java View File

@@ -50,7 +50,6 @@ import com.dmdirc.parser.irc.IRCClientInfo;
50 50
 import com.dmdirc.parser.irc.IRCParser;
51 51
 import com.dmdirc.parser.irc.PrefixModeManager;
52 52
 import com.dmdirc.parser.irc.ProcessorNotFoundException;
53
-import com.dmdirc.parser.irc.TimestampedIRCProcessor;
54 53
 
55 54
 import java.time.LocalDateTime;
56 55
 import java.util.regex.PatternSyntaxException;
@@ -65,7 +64,7 @@ import javax.inject.Inject;
65 64
  * Actions are handled here aswell separately from CTCPs.<br>
66 65
  * Each type has 5 Calls, making 15 callbacks handled here.
67 66
  */
68
-public class ProcessMessage extends TimestampedIRCProcessor {
67
+public class ProcessMessage extends IRCProcessor {
69 68
 
70 69
     /** The manager to use to access prefix modes. */
71 70
     private final PrefixModeManager prefixModeManager;
@@ -90,6 +89,7 @@ public class ProcessMessage extends TimestampedIRCProcessor {
90 89
      * Actions are handled here aswell separately from CTCPs.<br>
91 90
      * Each type has 5 Calls, making 15 callbacks handled here.
92 91
      *
92
+     * @param date The LocalDateTime that this event occurred at.
93 93
      * @param sParam Type of line to process ("NOTICE", "PRIVMSG")
94 94
      * @param token IRCTokenised line to process
95 95
      */

+ 30
- 23
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMode.java View File

@@ -79,11 +79,12 @@ public class ProcessMode extends IRCProcessor {
79 79
     /**
80 80
      * Process a Mode Line.
81 81
      *
82
+     * @param date The LocalDateTime that this event occurred at.
82 83
      * @param sParam Type of line to process ("MODE", "324")
83 84
      * @param token IRCTokenised line to process
84 85
      */
85 86
     @Override
86
-    public void process(final String sParam, final String... token) {
87
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
87 88
         final String[] sModestr;
88 89
         final String sChannelName;
89 90
         switch (sParam) {
@@ -93,7 +94,7 @@ public class ProcessMode extends IRCProcessor {
93 94
                 System.arraycopy(token, 4, sModestr, 0, token.length - 4);
94 95
                 break;
95 96
             case "221":
96
-                processUserMode(sParam, token, new String[]{token[token.length - 1]}, true);
97
+                processUserMode(date, sParam, token, new String[]{token[token.length - 1]}, true);
97 98
                 return;
98 99
             default:
99 100
                 sChannelName = token[2];
@@ -103,9 +104,9 @@ public class ProcessMode extends IRCProcessor {
103 104
         }
104 105
 
105 106
         if (isValidChannelName(sChannelName)) {
106
-            processChanMode(sParam, token, sModestr, sChannelName);
107
+            processChanMode(date, sParam, token, sModestr, sChannelName);
107 108
         } else {
108
-            processUserMode(sParam, token, sModestr, false);
109
+            processUserMode(date, sParam, token, sModestr, false);
109 110
         }
110 111
     }
111 112
 
@@ -122,12 +123,13 @@ public class ProcessMode extends IRCProcessor {
122 123
     /**
123 124
      * Process Chan modes.
124 125
      *
126
+     * @param date The LocalDateTime that this event occurred at.
125 127
      * @param sParam String representation of parameter to parse
126 128
      * @param token IRCTokenised Array of the incomming line
127 129
      * @param sModestr The modes and params
128 130
      * @param sChannelName Channel these modes are for
129 131
      */
130
-    public void processChanMode(final String sParam, final String[] token, final String[] sModestr, final String sChannelName) {
132
+    public void processChanMode(final LocalDateTime date, final String sParam, final String[] token, final String[] sModestr, final String sChannelName) {
131 133
         final StringBuilder sFullModeStr = new StringBuilder();
132 134
 
133 135
         final IRCChannelInfo iChannel = getChannel(sChannelName);
@@ -197,7 +199,7 @@ public class ProcessMode extends IRCProcessor {
197 199
                     } else {
198 200
                         iChannelClientInfo.removeMode(cMode);
199 201
                     }
200
-                    callChannelUserModeChanged(iChannel, iChannelClientInfo, setterCCI, token[0],
202
+                    callChannelUserModeChanged(date, iChannel, iChannelClientInfo, setterCCI, token[0],
201 203
                             (bPositive ? "+" : "-") + cMode);
202 204
                     continue;
203 205
                 } else {
@@ -233,7 +235,7 @@ public class ProcessMode extends IRCProcessor {
233 235
                         if (!"324".equals(sParam)) {
234 236
                             getCallbackManager().publish(
235 237
                                     new ChannelSingleModeChangeEvent(
236
-                                            parser, LocalDateTime.now(), iChannel,
238
+                                            parser, date, iChannel,
237 239
                                             setterCCI, token[0], cPositive + cMode + " " +
238 240
                                             sModeParam));
239 241
                         }
@@ -248,7 +250,7 @@ public class ProcessMode extends IRCProcessor {
248 250
                             if (!"324".equals(sParam)) {
249 251
                                 getCallbackManager().publish(
250 252
                                         new ChannelSingleModeChangeEvent(
251
-                                                parser, LocalDateTime.now(),
253
+                                                parser, date,
252 254
                                                 iChannel, setterCCI, token[0],
253 255
                                                 cPositive + cMode + " " +
254 256
                                                         sModeParam));
@@ -266,7 +268,7 @@ public class ProcessMode extends IRCProcessor {
266 268
                             if (!"324".equals(sParam)) {
267 269
                                 getCallbackManager().publish(
268 270
                                         new ChannelSingleModeChangeEvent(
269
-                                                parser, LocalDateTime.now(),
271
+                                                parser, date,
270 272
                                                 iChannel, setterCCI, token[0],
271 273
                                                 trim(cPositive + cMode + " " + sModeParam)));
272 274
                             }
@@ -283,11 +285,11 @@ public class ProcessMode extends IRCProcessor {
283 285
 
284 286
         iChannel.setMode(nCurrent);
285 287
         if ("324".equals(sParam)) {
286
-            callChannelModeChanged(iChannel, setterCCI, "", sFullModeStr.toString().trim());
288
+            callChannelModeChanged(date, iChannel, setterCCI, "", sFullModeStr.toString().trim());
287 289
         } else {
288
-            callChannelModeChanged(iChannel, setterCCI, token[0], sFullModeStr.toString().trim());
290
+            callChannelModeChanged(date, iChannel, setterCCI, token[0], sFullModeStr.toString().trim());
289 291
             getCallbackManager().publish(
290
-                    new ChannelNonUserModeChangeEvent(parser, LocalDateTime.now(), iChannel,
292
+                    new ChannelNonUserModeChangeEvent(parser, date, iChannel,
291 293
                             setterCCI, token[0],
292 294
                             trim(sNonUserModeStr.toString() + sNonUserModeStrParams)));
293 295
         }
@@ -296,11 +298,12 @@ public class ProcessMode extends IRCProcessor {
296 298
     /**
297 299
      * Process user modes.
298 300
      *
301
+     * @param date The LocalDateTime that this event occurred at.
299 302
      * @param sParam String representation of parameter to parse
300 303
      * @param token IRCTokenised Array of the incomming line
301 304
      * @param clearOldModes Clear old modes before applying these modes (used by 221)
302 305
      */
303
-    private void processUserMode(final String sParam, final String[] token, final String[] sModestr,
306
+    private void processUserMode(final LocalDateTime date, final String sParam, final String[] token, final String[] sModestr,
304 307
             final boolean clearOldModes) {
305 308
         final IRCClientInfo iClient = getClientInfo(token[2]);
306 309
 
@@ -340,66 +343,70 @@ public class ProcessMode extends IRCProcessor {
340 343
 
341 344
         iClient.setUserMode(nCurrent);
342 345
         if ("221".equals(sParam)) {
343
-            callUserModeDiscovered(iClient, sModestr[0]);
346
+            callUserModeDiscovered(date, iClient, sModestr[0]);
344 347
         } else {
345
-            callUserModeChanged(iClient, token[0], sModestr[0]);
348
+            callUserModeChanged(date, iClient, token[0], sModestr[0]);
346 349
         }
347 350
     }
348 351
 
349 352
     /**
350 353
      * Callback to all objects implementing the ChannelModeChanged Callback.
351 354
      *
355
+     * @param date The LocalDateTime that this event occurred at.
352 356
      * @param cChannel Channel where modes were changed
353 357
      * @param cChannelClient Client chaning the modes (null if server)
354 358
      * @param sHost Host doing the mode changing (User host or server name)
355 359
      * @param sModes Exact String parsed
356 360
      */
357
-    protected void callChannelModeChanged(final ChannelInfo cChannel,
361
+    protected void callChannelModeChanged(final LocalDateTime date, final ChannelInfo cChannel,
358 362
             final ChannelClientInfo cChannelClient, final String sHost, final String sModes) {
359 363
         getCallbackManager().publish(
360
-                new ChannelModeChangeEvent(parser, LocalDateTime.now(), cChannel, cChannelClient,
364
+                new ChannelModeChangeEvent(parser, date, cChannel, cChannelClient,
361 365
                         sHost, sModes));
362 366
     }
363 367
 
364 368
     /**
365 369
      * Callback to all objects implementing the ChannelUserModeChanged Callback.
366 370
      *
371
+     * @param date The LocalDateTime that this event occurred at.
367 372
      * @param cChannel Channel where modes were changed
368 373
      * @param cChangedClient Client being changed
369 374
      * @param cSetByClient Client chaning the modes (null if server)
370 375
      * @param sHost Host doing the mode changing (User host or server name)
371 376
      * @param sMode String representing mode change (ie +o)
372 377
      */
373
-    protected void callChannelUserModeChanged(final ChannelInfo cChannel,
378
+    protected void callChannelUserModeChanged(final LocalDateTime date, final ChannelInfo cChannel,
374 379
             final ChannelClientInfo cChangedClient, final ChannelClientInfo cSetByClient,
375 380
             final String sHost, final String sMode) {
376 381
         getCallbackManager().publish(
377
-                new ChannelUserModeChangeEvent(parser, LocalDateTime.now(), cChannel,
382
+                new ChannelUserModeChangeEvent(parser, date, cChannel,
378 383
                         cChangedClient, cSetByClient, sHost, sMode));
379 384
     }
380 385
 
381 386
     /**
382 387
      * Callback to all objects implementing the UserModeChanged Callback.
383 388
      *
389
+     * @param date The LocalDateTime that this event occurred at.
384 390
      * @param cClient Client that had the mode changed (almost always us)
385 391
      * @param sSetby Host that set the mode (us or servername)
386 392
      * @param sModes The modes set.
387 393
      */
388
-    protected void callUserModeChanged(final ClientInfo cClient, final String sSetby,
394
+    protected void callUserModeChanged(final LocalDateTime date, final ClientInfo cClient, final String sSetby,
389 395
             final String sModes) {
390 396
         getCallbackManager().publish(
391
-                new UserModeChangeEvent(parser, LocalDateTime.now(), cClient, sSetby, sModes));
397
+                new UserModeChangeEvent(parser, date, cClient, sSetby, sModes));
392 398
     }
393 399
 
394 400
     /**
395 401
      * Callback to all objects implementing the UserModeDiscovered Callback.
396 402
      *
403
+     * @param date The LocalDateTime that this event occurred at.
397 404
      * @param cClient Client that had the mode changed (almost always us)
398 405
      * @param sModes The modes set.
399 406
      */
400
-    protected void callUserModeDiscovered(final ClientInfo cClient, final String sModes) {
407
+    protected void callUserModeDiscovered(final LocalDateTime date, final ClientInfo cClient, final String sModes) {
401 408
         getCallbackManager().publish(
402
-                new UserModeDiscoveryEvent(parser, LocalDateTime.now(), cClient, sModes));
409
+                new UserModeDiscoveryEvent(parser, date, cClient, sModes));
403 410
     }
404 411
 
405 412
 }

+ 7
- 7
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessNames.java View File

@@ -69,7 +69,7 @@ public class ProcessNames extends IRCProcessor {
69 69
      * @param token IRCTokenised line to process
70 70
      */
71 71
     @Override
72
-    public void process(final String sParam, final String... token) {
72
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
73 73
         final IRCChannelInfo iChannel;
74 74
         if ("366".equals(sParam)) {
75 75
             // End of names
@@ -79,11 +79,11 @@ public class ProcessNames extends IRCProcessor {
79 79
             }
80 80
 
81 81
             if (!iChannel.hadTopic()) {
82
-                callChannelTopic(iChannel, true);
82
+                callChannelTopic(time, iChannel, true);
83 83
             }
84 84
 
85 85
             iChannel.setAddingNames(false);
86
-            callChannelGotNames(iChannel);
86
+            callChannelGotNames(time, iChannel);
87 87
 
88 88
             if (!iChannel.hasAskedForListModes()
89 89
                     && parser.getAutoListMode()) {
@@ -146,10 +146,10 @@ public class ProcessNames extends IRCProcessor {
146 146
      * @param cChannel Channel that topic was set on
147 147
      * @param bIsJoinTopic True when getting topic on join, false if set by user/server
148 148
      */
149
-    protected void callChannelTopic(final ChannelInfo cChannel, final boolean bIsJoinTopic) {
149
+    protected void callChannelTopic(final LocalDateTime time, final ChannelInfo cChannel, final boolean bIsJoinTopic) {
150 150
         ((IRCChannelInfo) cChannel).setHadTopic();
151 151
         getCallbackManager().publish(
152
-                new ChannelTopicEvent(parser, LocalDateTime.now(), cChannel, bIsJoinTopic));
152
+                new ChannelTopicEvent(parser, time, cChannel, bIsJoinTopic));
153 153
     }
154 154
 
155 155
     /**
@@ -157,8 +157,8 @@ public class ProcessNames extends IRCProcessor {
157 157
      *
158 158
      * @param cChannel Channel which the names reply is for
159 159
      */
160
-    protected void callChannelGotNames(final ChannelInfo cChannel) {
161
-        getCallbackManager().publish(new ChannelNamesEvent(parser, LocalDateTime.now(), cChannel));
160
+    protected void callChannelGotNames(final LocalDateTime time, final ChannelInfo cChannel) {
161
+        getCallbackManager().publish(new ChannelNamesEvent(parser, time, cChannel));
162 162
     }
163 163
 
164 164
 }

+ 10
- 7
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessNick.java View File

@@ -55,11 +55,12 @@ public class ProcessNick extends IRCProcessor {
55 55
     /**
56 56
      * Process a Nick change.
57 57
      *
58
+     * @param date The LocalDateTime that this event occurred at.
58 59
      * @param sParam Type of line to process ("NICK")
59 60
      * @param token IRCTokenised line to process
60 61
      */
61 62
     @Override
62
-    public void process(final String sParam, final String... token) {
63
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
63 64
 
64 65
         final IRCClientInfo iClient = getClientInfo(token[0]);
65 66
         if (iClient == null) {
@@ -92,36 +93,38 @@ public class ProcessNick extends IRCProcessor {
92 93
                     if (!isSameNick) {
93 94
                         iChannel.renameClient(oldNickname, iChannelClient);
94 95
                     }
95
-                    callChannelNickChanged(iChannel, iChannelClient, IRCClientInfo.parseHost(token[0]));
96
+                    callChannelNickChanged(date, iChannel, iChannelClient, IRCClientInfo.parseHost(token[0]));
96 97
                 }
97 98
             }
98 99
 
99
-            callNickChanged(iClient, IRCClientInfo.parseHost(token[0]));
100
+            callNickChanged(date, iClient, IRCClientInfo.parseHost(token[0]));
100 101
         }
101 102
     }
102 103
 
103 104
     /**
104 105
      * Callback to all objects implementing the ChannelNickChanged Callback.
105 106
      *
107
+     * @param date The LocalDateTime that this event occurred at.
106 108
      * @param cChannel One of the channels that the user is on
107 109
      * @param cChannelClient Client changing nickname
108 110
      * @param sOldNick Nickname before change
109 111
      */
110
-    protected void callChannelNickChanged(final ChannelInfo cChannel,
112
+    protected void callChannelNickChanged(final LocalDateTime date, final ChannelInfo cChannel,
111 113
             final ChannelClientInfo cChannelClient, final String sOldNick) {
112 114
         getCallbackManager().publish(
113
-                new ChannelNickChangeEvent(parser, LocalDateTime.now(), cChannel, cChannelClient,
115
+                new ChannelNickChangeEvent(parser, date, cChannel, cChannelClient,
114 116
                         sOldNick));
115 117
     }
116 118
 
117 119
     /**
118 120
      * Callback to all objects implementing the NickChanged Callback.
119 121
      *
122
+     * @param date The LocalDateTime that this event occurred at.
120 123
      * @param cClient Client changing nickname
121 124
      * @param sOldNick Nickname before change
122 125
      */
123
-    protected void callNickChanged(final ClientInfo cClient, final String sOldNick) {
124
-        getCallbackManager().publish(new NickChangeEvent(parser, LocalDateTime.now(), cClient,
126
+    protected void callNickChanged(final LocalDateTime date, final ClientInfo cClient, final String sOldNick) {
127
+        getCallbackManager().publish(new NickChangeEvent(parser, date, cClient,
125 128
                 sOldNick));
126 129
     }
127 130
 

+ 4
- 4
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessNickInUse.java View File

@@ -63,8 +63,8 @@ public class ProcessNickInUse extends IRCProcessor {
63 63
      * @param token IRCTokenised line to process
64 64
      */
65 65
     @Override
66
-    public void process(final String sParam, final String... token) {
67
-        callNickInUse(token[3]);
66
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
67
+        callNickInUse(time, token[3]);
68 68
     }
69 69
 
70 70
     /**
@@ -72,8 +72,8 @@ public class ProcessNickInUse extends IRCProcessor {
72 72
      *
73 73
      * @param nickname Nickname that was wanted.
74 74
      */
75
-    protected void callNickInUse(final String nickname) {
76
-        getCallbackManager().publish(new NickInUseEvent(parser, LocalDateTime.now(), nickname));
75
+    protected void callNickInUse(final LocalDateTime time, final String nickname) {
76
+        getCallbackManager().publish(new NickInUseEvent(parser, time, nickname));
77 77
     }
78 78
 
79 79
 }

+ 4
- 4
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessNoticeAuth.java View File

@@ -51,8 +51,8 @@ public class ProcessNoticeAuth extends IRCProcessor {
51 51
      * @param token IRCTokenised line to process
52 52
      */
53 53
     @Override
54
-    public void process(final String sParam, final String... token) {
55
-        callNoticeAuth(token[token.length - 1]);
54
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
55
+        callNoticeAuth(time, token[token.length - 1]);
56 56
     }
57 57
 
58 58
     /**
@@ -60,8 +60,8 @@ public class ProcessNoticeAuth extends IRCProcessor {
60 60
      *
61 61
      * @param data Incomming Line.
62 62
      */
63
-    protected void callNoticeAuth(final String data) {
64
-        getCallbackManager().publish(new AuthNoticeEvent(parser, LocalDateTime.now(), data));
63
+    protected void callNoticeAuth(final LocalDateTime time, final String data) {
64
+        getCallbackManager().publish(new AuthNoticeEvent(parser, time, data));
65 65
     }
66 66
 
67 67
 }

+ 7
- 5
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessPart.java View File

@@ -53,11 +53,12 @@ public class ProcessPart extends IRCProcessor {
53 53
     /**
54 54
      * Process a channel part.
55 55
      *
56
+     * @param date The LocalDateTime that this event occurred at.
56 57
      * @param sParam Type of line to process ("PART")
57 58
      * @param token IRCTokenised line to process
58 59
      */
59 60
     @Override
60
-    public void process(final String sParam, final String... token) {
61
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
61 62
         // :nick!ident@host PART #Channel
62 63
         // :nick!ident@host PART #Channel :reason
63 64
         if (token.length < 3) {
@@ -91,12 +92,12 @@ public class ProcessPart extends IRCProcessor {
91 92
                 return;
92 93
             }
93 94
             if (parser.getRemoveAfterCallback()) {
94
-                callChannelPart(iChannel, iChannelClient, sReason);
95
+                callChannelPart(date, iChannel, iChannelClient, sReason);
95 96
             }
96 97
             callDebugInfo(IRCParser.DEBUG_INFO, "Removing %s from %s", iClient.getNickname(), iChannel.getName());
97 98
             iChannel.delClient(iClient);
98 99
             if (!parser.getRemoveAfterCallback()) {
99
-                callChannelPart(iChannel, iChannelClient, sReason);
100
+                callChannelPart(date, iChannel, iChannelClient, sReason);
100 101
             }
101 102
             if (iClient == parser.getLocalClient()) {
102 103
                 iChannel.emptyChannel();
@@ -108,14 +109,15 @@ public class ProcessPart extends IRCProcessor {
108 109
     /**
109 110
      * Callback to all objects implementing the ChannelPart Callback.
110 111
      *
112
+     * @param date The LocalDateTime that this event occurred at.
111 113
      * @param cChannel Channel that the user parted
112 114
      * @param cChannelClient Client that parted
113 115
      * @param sReason Reason given for parting (May be "")
114 116
      */
115
-    protected void callChannelPart(final ChannelInfo cChannel,
117
+    protected void callChannelPart(final LocalDateTime date, final ChannelInfo cChannel,
116 118
             final ChannelClientInfo cChannelClient, final String sReason) {
117 119
         getCallbackManager().publish(
118
-                new ChannelPartEvent(parser, LocalDateTime.now(), cChannel, cChannelClient,
120
+                new ChannelPartEvent(parser, date, cChannel, cChannelClient,
119 121
                         sReason));
120 122
     }
121 123
 

+ 12
- 9
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessQuit.java View File

@@ -55,11 +55,12 @@ public class ProcessQuit extends IRCProcessor {
55 55
     /**
56 56
      * Process a Quit message.
57 57
      *
58
+     * @param date The LocalDateTime that this event occurred at.
58 59
      * @param sParam Type of line to process ("QUIT")
59 60
      * @param token IRCTokenised line to process
60 61
      */
61 62
     @Override
62
-    public void process(final String sParam, final String... token) {
63
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
63 64
         // :nick!ident@host QUIT
64 65
         // :nick!ident@host QUIT :reason
65 66
         if (token.length < 2) {
@@ -85,7 +86,7 @@ public class ProcessQuit extends IRCProcessor {
85 86
             final IRCChannelClientInfo iChannelClient = iChannel.getChannelClient(iClient);
86 87
             if (iChannelClient != null) {
87 88
                 if (parser.getRemoveAfterCallback()) {
88
-                    callChannelQuit(iChannel, iChannelClient, sReason);
89
+                    callChannelQuit(date, iChannel, iChannelClient, sReason);
89 90
                 }
90 91
                 if (iClient == parser.getLocalClient()) {
91 92
                     iChannel.emptyChannel();
@@ -94,13 +95,13 @@ public class ProcessQuit extends IRCProcessor {
94 95
                     iChannel.delClient(iClient);
95 96
                 }
96 97
                 if (!parser.getRemoveAfterCallback()) {
97
-                    callChannelQuit(iChannel, iChannelClient, sReason);
98
+                    callChannelQuit(date, iChannel, iChannelClient, sReason);
98 99
                 }
99 100
             }
100 101
         }
101 102
 
102 103
         if (parser.getRemoveAfterCallback()) {
103
-            callQuit(iClient, sReason);
104
+            callQuit(date, iClient, sReason);
104 105
         }
105 106
         if (iClient == parser.getLocalClient()) {
106 107
             parser.clearClients();
@@ -108,32 +109,34 @@ public class ProcessQuit extends IRCProcessor {
108 109
             parser.removeClient(iClient);
109 110
         }
110 111
         if (!parser.getRemoveAfterCallback()) {
111
-            callQuit(iClient, sReason);
112
+            callQuit(date, iClient, sReason);
112 113
         }
113 114
     }
114 115
 
115 116
     /**
116 117
      * Callback to all objects implementing the ChannelQuit Callback.
117 118
      *
119
+     * @param date The LocalDateTime that this event occurred at.
118 120
      * @param cChannel Channel that user was on
119 121
      * @param cChannelClient User thats quitting
120 122
      * @param sReason Quit reason
121 123
      */
122
-    protected void callChannelQuit(final ChannelInfo cChannel,
124
+    protected void callChannelQuit(final LocalDateTime date, final ChannelInfo cChannel,
123 125
             final ChannelClientInfo cChannelClient, final String sReason) {
124 126
         getCallbackManager().publish(
125
-                new ChannelQuitEvent(parser, LocalDateTime.now(), cChannel, cChannelClient,
127
+                new ChannelQuitEvent(parser, date, cChannel, cChannelClient,
126 128
                         sReason));
127 129
     }
128 130
 
129 131
     /**
130 132
      * Callback to all objects implementing the Quit Callback.
131 133
      *
134
+     * @param date The LocalDateTime that this event occurred at.
132 135
      * @param cClient Client Quitting
133 136
      * @param sReason Reason for quitting (may be "")
134 137
      */
135
-    protected void callQuit(final ClientInfo cClient, final String sReason) {
136
-        getCallbackManager().publish(new QuitEvent(parser, LocalDateTime.now(), cClient, sReason));
138
+    protected void callQuit(final LocalDateTime date, final ClientInfo cClient, final String sReason) {
139
+        getCallbackManager().publish(new QuitEvent(parser, date, cClient, sReason));
137 140
     }
138 141
 
139 142
 }

+ 7
- 5
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessTopic.java View File

@@ -50,11 +50,12 @@ public class ProcessTopic extends IRCProcessor {
50 50
     /**
51 51
      * Process a topic change.
52 52
      *
53
+     * @param date The LocalDateTime that this event occurred at.
53 54
      * @param sParam Type of line to process ("TOPIC", "332", "333")
54 55
      * @param token IRCTokenised line to process
55 56
      */
56 57
     @Override
57
-    public void process(final String sParam, final String... token) {
58
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
58 59
         final IRCChannelInfo iChannel;
59 60
         switch (sParam) {
60 61
             case "332":
@@ -75,7 +76,7 @@ public class ProcessTopic extends IRCProcessor {
75 76
                             iChannel.setTopicTime(Long.parseLong(token[5]));
76 77
                         }
77 78
                     }
78
-                    callChannelTopic(iChannel, true);
79
+                    callChannelTopic(date, iChannel, true);
79 80
                 }   break;
80 81
             default:
81 82
                 if (IRCParser.ALWAYS_UPDATECLIENT) {
@@ -91,7 +92,7 @@ public class ProcessTopic extends IRCProcessor {
91 92
                 iChannel.setTopicTime(System.currentTimeMillis() / 1000);
92 93
                 iChannel.setTopicUser(token[0].charAt(0) == ':' ? token[0].substring(1) : token[0]);
93 94
                 iChannel.setInternalTopic(token[token.length - 1]);
94
-                callChannelTopic(iChannel, false);
95
+                callChannelTopic(date, iChannel, false);
95 96
                 break;
96 97
         }
97 98
     }
@@ -99,13 +100,14 @@ public class ProcessTopic extends IRCProcessor {
99 100
     /**
100 101
      * Callback to all objects implementing the ChannelTopic Callback.
101 102
      *
103
+     * @param date The LocalDateTime that this event occurred at.
102 104
      * @param cChannel Channel that topic was set on
103 105
      * @param bIsJoinTopic True when getting topic on join, false if set by user/server
104 106
      */
105
-    protected void callChannelTopic(final ChannelInfo cChannel, final boolean bIsJoinTopic) {
107
+    protected void callChannelTopic(final LocalDateTime date, final ChannelInfo cChannel, final boolean bIsJoinTopic) {
106 108
         ((IRCChannelInfo) cChannel).setHadTopic();
107 109
         getCallbackManager().publish(
108
-                new ChannelTopicEvent(parser, LocalDateTime.now(), cChannel, bIsJoinTopic));
110
+                new ChannelTopicEvent(parser, date, cChannel, bIsJoinTopic));
109 111
     }
110 112
 
111 113
 }

+ 10
- 10
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessWallops.java View File

@@ -53,7 +53,7 @@ public class ProcessWallops extends IRCProcessor {
53 53
      * @param token IRCTokenised line to process
54 54
      */
55 55
     @Override
56
-    public void process(final String sParam, final String... token) {
56
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
57 57
         if (token.length < 3) {
58 58
             return;
59 59
         }
@@ -67,14 +67,14 @@ public class ProcessWallops extends IRCProcessor {
67 67
 
68 68
         if (bits.length > 1) {
69 69
             if (message.charAt(0) == '*') {
70
-                callWallop(bits[1], user);
70
+                callWallop(time, bits[1], user);
71 71
                 return;
72 72
             } else if (message.charAt(0) == '$') {
73
-                callWalluser(bits[1], user);
73
+                callWalluser(time, bits[1], user);
74 74
                 return;
75 75
             }
76 76
         }
77
-        callWallDesync(message, user);
77
+        callWallDesync(time, message, user);
78 78
     }
79 79
 
80 80
     /**
@@ -83,8 +83,8 @@ public class ProcessWallops extends IRCProcessor {
83 83
      * @param message The message
84 84
      * @param host Host of the user who sent the wallop
85 85
      */
86
-    protected void callWallop(final String message, final String host) {
87
-        getCallbackManager().publish(new WallopEvent(parser, LocalDateTime.now(), message, host));
86
+    protected void callWallop(final LocalDateTime time, final String message, final String host) {
87
+        getCallbackManager().publish(new WallopEvent(parser, time, message, host));
88 88
     }
89 89
 
90 90
     /**
@@ -93,8 +93,8 @@ public class ProcessWallops extends IRCProcessor {
93 93
      * @param message The message
94 94
      * @param host Host of the user who sent the walluser
95 95
      */
96
-    protected void callWalluser(final String message, final String host) {
97
-        getCallbackManager().publish(new WalluserEvent(parser, LocalDateTime.now(), message, host));
96
+    protected void callWalluser(final LocalDateTime time, final String message, final String host) {
97
+        getCallbackManager().publish(new WalluserEvent(parser, time, message, host));
98 98
     }
99 99
 
100 100
     /**
@@ -103,9 +103,9 @@ public class ProcessWallops extends IRCProcessor {
103 103
      * @param message The message
104 104
      * @param host Host of the user who sent the WallDesync
105 105
      */
106
-    protected void callWallDesync(final String message, final String host) {
106
+    protected void callWallDesync(final LocalDateTime time, final String message, final String host) {
107 107
         getCallbackManager().publish(new WallDesyncEvent(
108
-                parser, LocalDateTime.now(), message, host));
108
+                parser, time, message, host));
109 109
     }
110 110
 
111 111
 }

+ 10
- 10
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessWho.java View File

@@ -58,7 +58,7 @@ public class ProcessWho extends IRCProcessor {
58 58
      * @param token IRCTokenised line to process
59 59
      */
60 60
     @Override
61
-    public void process(final String sParam, final String... token) {
61
+    public void process(final LocalDateTime time, final String sParam, final String... token) {
62 62
         // :blueyonder2.uk.quakenet.org 352 Dataforce #mdbot shane Tobavaj.users.quakenet.org *.quakenet.org Tobavaj G+x :3 Tobavaj - http://shane.dmdirc.com/scriptbot.php
63 63
         //              0               1      2        3     4              5                      6           7     8        9
64 64
         // :blueyonder2.uk.quakenet.org 352 Dataforce #mdbot ~Dataforce ResNetUser-BrynDinas-147.143.246.102.bangor.ac.uk *.quakenet.org Dataforce H@ :0 Dataforce
@@ -84,14 +84,14 @@ public class ProcessWho extends IRCProcessor {
84 84
                 final AwayState oldState = client.getAwayState();
85 85
                 client.setAwayState(isAway);
86 86
                 if (client == parser.getLocalClient()) {
87
-                    callAwayState(oldState, client.getAwayState(), client.getAwayReason());
87
+                    callAwayState(time, oldState, client.getAwayState(), client.getAwayReason());
88 88
                 } else {
89
-                    callAwayStateOther(client, oldState, isAway);
89
+                    callAwayStateOther(time, client, oldState, isAway);
90 90
 
91 91
                     for (ChannelInfo iChannel : parser.getChannels()) {
92 92
                         final ChannelClientInfo iChannelClient = iChannel.getChannelClient(client);
93 93
                         if (iChannelClient != null) {
94
-                            callChannelAwayStateOther(iChannel, iChannelClient, oldState, isAway);
94
+                            callChannelAwayStateOther(time, iChannel, iChannelClient, oldState, isAway);
95 95
                         }
96 96
                     }
97 97
                 }
@@ -106,10 +106,10 @@ public class ProcessWho extends IRCProcessor {
106 106
      * @param currentState Current Away State
107 107
      * @param reason Best guess at away reason
108 108
      */
109
-    protected void callAwayState(final AwayState oldState, final AwayState currentState,
109
+    protected void callAwayState(final LocalDateTime time, final AwayState oldState, final AwayState currentState,
110 110
             final String reason) {
111 111
         getCallbackManager().publish(
112
-                new AwayStateEvent(parser, LocalDateTime.now(), oldState, currentState, reason));
112
+                new AwayStateEvent(parser, time, oldState, currentState, reason));
113 113
     }
114 114
 
115 115
     /**
@@ -119,10 +119,10 @@ public class ProcessWho extends IRCProcessor {
119 119
      * @param oldState Old Away State
120 120
      * @param state Current Away State
121 121
      */
122
-    protected void callAwayStateOther(final ClientInfo client, final AwayState oldState,
122
+    protected void callAwayStateOther(final LocalDateTime time, final ClientInfo client, final AwayState oldState,
123 123
             final AwayState state) {
124 124
         getCallbackManager().publish(
125
-                new OtherAwayStateEvent(parser, LocalDateTime.now(), client, oldState, state));
125
+                new OtherAwayStateEvent(parser, time, client, oldState, state));
126 126
     }
127 127
 
128 128
     /**
@@ -133,10 +133,10 @@ public class ProcessWho extends IRCProcessor {
133 133
      * @param oldState Old Away State
134 134
      * @param state Current Away State
135 135
      */
136
-    protected void callChannelAwayStateOther(final ChannelInfo channel,
136
+    protected void callChannelAwayStateOther(final LocalDateTime time, final ChannelInfo channel,
137 137
             final ChannelClientInfo channelClient, final AwayState oldState, final AwayState state) {
138 138
         getCallbackManager().publish(
139
-                new ChannelOtherAwayStateEvent(parser, LocalDateTime.now(), channel, channelClient,
139
+                new ChannelOtherAwayStateEvent(parser, time, channel, channelClient,
140 140
                         oldState, state));
141 141
     }
142 142
 

+ 9
- 7
irc/src/test/java/com/dmdirc/parser/irc/processors/Process001Test.java View File

@@ -33,6 +33,8 @@ import org.mockito.ArgumentCaptor;
33 33
 import org.mockito.Mock;
34 34
 import org.mockito.runners.MockitoJUnitRunner;
35 35
 
36
+import java.time.LocalDateTime;
37
+
36 38
 import static org.junit.Assert.assertEquals;
37 39
 import static org.junit.Assert.assertTrue;
38 40
 import static org.junit.Assume.assumeFalse;
@@ -64,28 +66,28 @@ public class Process001Test {
64 66
     public void testSets001Received() {
65 67
         when(localClient.isFake()).thenReturn(true);
66 68
         assumeFalse(parser.got001);
67
-        processor.process("001", ":test.server.com", "001", "userName", "Hello!");
69
+        processor.process(LocalDateTime.now(), "001", ":test.server.com", "001", "userName", "Hello!");
68 70
         assertTrue(parser.got001);
69 71
     }
70 72
 
71 73
     @Test
72 74
     public void testUpdatesServerName() {
73 75
         when(localClient.isFake()).thenReturn(true);
74
-        processor.process("001", ":test.server.com", "001", "userName", "Hello!");
76
+        processor.process(LocalDateTime.now(), "001", ":test.server.com", "001", "userName", "Hello!");
75 77
         verify(parser).updateServerName("test.server.com");
76 78
     }
77 79
 
78 80
     @Test
79 81
     public void testAddsLocalClientIfFake() {
80 82
         when(localClient.isFake()).thenReturn(true);
81
-        processor.process("001", ":test.server.com", "001", "userName", "Hello!");
83
+        processor.process(LocalDateTime.now(), "001", ":test.server.com", "001", "userName", "Hello!");
82 84
         verify(parser).addClient(localClient);
83 85
     }
84 86
 
85 87
     @Test
86 88
     public void testUpdatesLocalClientIfFake() {
87 89
         when(localClient.isFake()).thenReturn(true);
88
-        processor.process("001", ":test.server.com", "001", "userName", "Hello!");
90
+        processor.process(LocalDateTime.now(), "001", ":test.server.com", "001", "userName", "Hello!");
89 91
         verify(localClient).setUserBits(eq("userName"), eq(true), anyBoolean());
90 92
         verify(localClient).setFake(false);
91 93
     }
@@ -93,7 +95,7 @@ public class Process001Test {
93 95
     @Test
94 96
     public void testIgnoresDuplicate001WithSameNick() {
95 97
         when(localClient.getNickname()).thenReturn("UsernaME");
96
-        processor.process("001", ":test.server.com", "001", "userName", "Hello!");
98
+        processor.process(LocalDateTime.now(), "001", ":test.server.com", "001", "userName", "Hello!");
97 99
         verify(parser, never()).addClient(any());
98 100
         verify(parser, never()).forceRemoveClient(any());
99 101
     }
@@ -101,7 +103,7 @@ public class Process001Test {
101 103
     @Test
102 104
     public void testReplacesLocalUserOnDuplicate001() {
103 105
         when(localClient.getNickname()).thenReturn("UsernaME");
104
-        processor.process("001", ":test.server.com", "001", "newName", "Hello!");
106
+        processor.process(LocalDateTime.now(), "001", ":test.server.com", "001", "newName", "Hello!");
105 107
         verify(parser).forceRemoveClient(localClient);
106 108
         verify(localClient).setUserBits(eq("newName"), eq(true), anyBoolean());
107 109
         verify(parser).addClient(localClient);
@@ -114,7 +116,7 @@ public class Process001Test {
114 116
         when(parser.isKnownClient("newName")).thenReturn(true);
115 117
         when(parser.getClient("newName")).thenReturn(mock(IRCClientInfo.class));
116 118
 
117
-        processor.process("001", ":test.server.com", "001", "newName", "Hello!");
119
+        processor.process(LocalDateTime.now(), "001", ":test.server.com", "001", "newName", "Hello!");
118 120
 
119 121
         final ArgumentCaptor<ParserError> errorCaptor = ArgumentCaptor.forClass(ParserError.class);
120 122
         verify(parser).callErrorInfo(errorCaptor.capture());

+ 3
- 1
irc/src/test/java/com/dmdirc/parser/irc/processors/Process464Test.java View File

@@ -35,6 +35,8 @@ import org.mockito.Captor;
35 35
 import org.mockito.Mock;
36 36
 import org.mockito.runners.MockitoJUnitRunner;
37 37
 
38
+import java.time.LocalDateTime;
39
+
38 40
 import static org.junit.Assert.assertSame;
39 41
 import static org.mockito.Mockito.verify;
40 42
 import static org.mockito.Mockito.when;
@@ -56,7 +58,7 @@ public class Process464Test {
56 58
 
57 59
     @Test
58 60
     public void testFiresPasswordListenerOn464() {
59
-        processor.process("464", ":server.com", "464", ":Bad password!");
61
+        processor.process(LocalDateTime.now(), "464", ":server.com", "464", ":Bad password!");
60 62
         verify(callbackManager).publish(eventCaptor.capture());
61 63
         assertSame(parser, eventCaptor.getValue().getParser());
62 64
     }

Loading…
Cancel
Save