|
@@ -0,0 +1,79 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (c) 2006-2014 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.events;
|
|
24
|
+
|
|
25
|
+import com.dmdirc.parser.events.DataInEvent;
|
|
26
|
+import com.dmdirc.parser.interfaces.Parser;
|
|
27
|
+import com.dmdirc.parser.irc.IRCParser;
|
|
28
|
+import com.dmdirc.parser.irc.IRCReader.ReadLine;
|
|
29
|
+
|
|
30
|
+import java.time.LocalDateTime;
|
|
31
|
+
|
|
32
|
+import static com.google.common.base.Preconditions.checkNotNull;
|
|
33
|
+
|
|
34
|
+/**
|
|
35
|
+ * Called on every incoming line BEFORE parsing.
|
|
36
|
+ *
|
|
37
|
+ * This extends the standard DataInEvent to provide access to IRC-Specific bits.
|
|
38
|
+ */
|
|
39
|
+public class IRCDataInEvent extends DataInEvent {
|
|
40
|
+
|
|
41
|
+ private final ReadLine line;
|
|
42
|
+ private final String[] tokenisedData;
|
|
43
|
+ private final String action;
|
|
44
|
+
|
|
45
|
+ public IRCDataInEvent(final IRCParser parser, final LocalDateTime date, final ReadLine line) {
|
|
46
|
+ super(parser, date, checkNotNull(line).getLine());
|
|
47
|
+ this.line = line;
|
|
48
|
+ tokenisedData = line.getTokens();
|
|
49
|
+
|
|
50
|
+ // Action is slightly more complicated than for DataOut
|
|
51
|
+ if (tokenisedData.length > 1) {
|
|
52
|
+ if (tokenisedData[0].length() > 0 && tokenisedData[0].charAt(0) == ':') {
|
|
53
|
+ if (tokenisedData[1].equalsIgnoreCase("NOTICE") && !parser.got001) {
|
|
54
|
+ action = "NOTICE AUTH";
|
|
55
|
+ } else {
|
|
56
|
+ action = tokenisedData[1].toUpperCase();
|
|
57
|
+ }
|
|
58
|
+ } else if (tokenisedData[0].equalsIgnoreCase("NOTICE")) {
|
|
59
|
+ action = "NOTICE AUTH";
|
|
60
|
+ } else {
|
|
61
|
+ action = tokenisedData[0].toUpperCase();
|
|
62
|
+ }
|
|
63
|
+ } else {
|
|
64
|
+ action = "";
|
|
65
|
+ }
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ public String[] getTokenisedData() {
|
|
69
|
+ return tokenisedData;
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ public ReadLine getLine() {
|
|
73
|
+ return line;
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ public String getAction() {
|
|
77
|
+ return action;
|
|
78
|
+ }
|
|
79
|
+}
|