File Source: ProcessMessage.java
/*
P/P * Method: com.dmdirc.parser.irc.ProcessMessage__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
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 java.util.regex.PatternSyntaxException;
26
27 /**
28 * Process PRIVMSGs and NOTICEs.
29 * This horrible handles PRIVMSGs and NOTICES<br>
30 * This inclues CTCPs and CTCPReplies<br>
31 * It handles all 3 targets (Channel, Private, Unknown)<br>
32 * Actions are handled here aswell separately from CTCPs.<br>
33 * Each type has 5 Calls, making 15 callbacks handled here.
34 */
35 public class ProcessMessage extends IRCProcessor {
36 /**
37 * Process PRIVMSGs and NOTICEs.
38 * This horrible thing handles PRIVMSGs and NOTICES<br>
39 * This inclues CTCPs and CTCPReplies<br>
40 * It handles all 3 targets (Channel, Private, Unknown)<br>
41 * Actions are handled here aswell separately from CTCPs.<br>
42 * Each type has 5 Calls, making 15 callbacks handled here.
43 *
44 * @param sParam Type of line to process ("NOTICE", "PRIVMSG")
45 * @param token IRCTokenised line to process
46 */
47 @Override
48 public void process(final String sParam, String[] token) {
49 // Ignore people!
/*
P/P * Method: void process(String, String[])
*
* Preconditions:
* token[0] != null
* this.myParser != null
* token != null
* (soft) init'ed(this.myParser.stringConverter)
* (soft) sParam != null
* (soft) init'ed(this.myParser...lastLine)
* (soft) this.myParser...myCallbackManager != null
* (soft) this.myParser...myCallbackManager.callbackHash != null
* (soft) this.myParser.cMyself != null
* (soft) init'ed(this.myParser.cMyself.bIsFake)
* ...
*
* Presumptions:
* getIRCStringConverter(...).lowercase.length@159 >= 1
* getIRCStringConverter(...).lowercase@159 != null
* iChannel.hChannelUserList != null
* iClient.sHost != null
* java.lang.Character:valueOf(...)@104 != null
* ...
*
* Postconditions:
* possibly_updated(java.lang.String:substring(...)._tainted)
* init'ed(this.myParser.stringConverter)
* token[0] == One-of{old token[0], &java.lang.String:substring(...)}
* token[0] != null
* new IRCStringConverter(getIRCStringConverter#1) num objects <= 1
* new IRCStringConverter(getIRCStringConverter#1) num objects == 0
* init'ed(new IRCStringConverter(getIRCStringConverter#1).limit)
* init'ed(new IRCStringConverter(getIRCStringConverter#1).lowercase)
* init'ed(new IRCStringConverter(getIRCStringConverter#1).uppercase)
* new char[](IRCStringConverter#1) num objects <= 1
* ...
*
* Test Vectors:
* token.length: {4..232}, {1,2}, {3}
* java.lang.Character:equals(...)@104: {0}, {1}
* java.lang.Character:equals(...)@93: {0}, {1}
* java.lang.String:charAt(...)@121: {0..57, 59..216-1}, {58}
* java.lang.String:charAt(...)@51: {0..57, 59..216-1}, {58}
* java.lang.String:equalsIgnoreCase(...)@142: {0}, {1}
* java.lang.String:equalsIgnoreCase(...)@152: {0}, {1}
* java.lang.String:equalsIgnoreCase(...)@160: {0}, {1}
* java.lang.String:equalsIgnoreCase(...)@170: {0}, {1}
* java.lang.String:equalsIgnoreCase(...)@179: {0}, {1}
* ...
*/
50 String sMessage = "";
51 if (token[0].charAt(0) == ':') { sMessage = token[0].substring(1); } else { sMessage = token[0]; }
52 // We use sMessage to be the users host (first token in the line)
53 try {
54 if (myParser.getIgnoreList().matches(sMessage) > -1) { return; }
55 } catch (PatternSyntaxException pse) {
56 final ParserError pe = new ParserError(ParserError.ERROR_WARNING, "Error with ignore list regex: "+pse, myParser.getLastLine());
57 pe.setException(pse);
58 callErrorInfo(pe);
59 }
60
61 // Lines such as:
62 // "nick!user@host PRIVMSG"
63 // are invalid, stop processing.
64 if (token.length < 3) { return; }
65
66 // Is this actually a notice auth?
67 if (token[0].indexOf('!') == -1 && token[1].equalsIgnoreCase("NOTICE") && token[2].equalsIgnoreCase("AUTH")) {
68 try {
69 myParser.getProcessingManager().process("Notice Auth", token);
70 } catch (ProcessorNotFoundException e) { }
71 return;
72 }
73
74 ChannelClientInfo iChannelClient = null;
75 ChannelInfo iChannel = null;
76 ClientInfo iClient = null;
77 // "nick!user@host PRIVMSG #Channel" should be processed as "nick!user@host PRIVMSG #Channel :"
78 if (token.length < 4) {
79 sMessage = "";
80 } else {
81 sMessage = token[token.length-1];
82 }
83 String bits[] = sMessage.split(" ", 2);
84 final Character Char1 = Character.valueOf((char)1);
85 String sCTCP = "";
86 boolean isAction = false;
87 boolean isCTCP = false;
88
89 if (sMessage.length() > 1) {
90 if (sParam.equalsIgnoreCase("PRIVMSG")) {
91 // Actions are special CTCPs
92 // Bits is the message been split into 2 parts, the first word and the rest
93 if (bits[0].equalsIgnoreCase(Char1+"ACTION") && Character.valueOf(sMessage.charAt(sMessage.length()-1)).equals(Char1)) {
94 isAction = true;
95 if (bits.length > 1) {
96 sMessage = bits[1];
97 sMessage = sMessage.substring(0, sMessage.length()-1);
98 } else { sMessage = ""; }
99 }
100 }
101 // If the message is not an action, check if it is another type of CTCP
102 if (!isAction) {
103 // CTCPs have Character(1) at the start/end of the line
104 if (Character.valueOf(sMessage.charAt(0)).equals(Char1) && Character.valueOf(sMessage.charAt(sMessage.length()-1)).equals(Char1)) {
105 isCTCP = true;
106 // Bits is the message been split into 2 parts, the first word and the rest
107 // Some CTCPs have messages and some do not
108 if (bits.length > 1) { sMessage = bits[1]; } else { sMessage = ""; }
109 // Remove the leading char1
110 bits = bits[0].split(Char1.toString(),2);
111 sCTCP = bits[1];
112 // remove the trailing char1
113 if (!sMessage.isEmpty()) { sMessage = sMessage.split(Char1.toString(),2)[0]; }
114 else { sCTCP = sCTCP.split(Char1.toString(),2)[0]; }
115 callDebugInfo(IRCParser.DEBUG_INFO, "CTCP: \"%s\" \"%s\"",sCTCP,sMessage);
116 }
117 }
118 }
119
120 // Remove the leading : from the host.
121 if (token[0].charAt(0) == ':' && token[0].length() > 1) { token[0] = token[0].substring(1); }
122
123 iClient = getClientInfo(token[0]);
124 if (IRCParser.ALWAYS_UPDATECLIENT && iClient != null) {
125 // Facilitate DMDIRC Formatter
126 if (iClient.getHost().isEmpty()) {iClient.setUserBits(token[0],false); }
127 }
128
129 // Fire the appropriate callbacks.
130 // OnChannel* Callbacks are fired if the target was a channel
131 // OnPrivate* Callbacks are fired if the target was us
132 // OnUnknown* Callbacks are fired if the target was neither of the above
133 // Actions and CTCPs are send as PRIVMSGS
134 // CTCPReplies are sent as Notices
135 if (isValidChannelName(token[2])) {
136 iChannel = getChannelInfo(token[2]);
137 if (iChannel == null) {
138 // callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got message for channel ("+token[2]+") that I am not on.", myParser.getLastLine()));
139 return;
140 }
141 if (iClient != null) { iChannelClient = iChannel.getUser(iClient); }
142 if (sParam.equalsIgnoreCase("PRIVMSG")) {
143 if (!isAction) {
144 if (isCTCP) {
145 callChannelCTCP(iChannel, iChannelClient, sCTCP, sMessage, token[0]);
146 } else {
147 callChannelMessage(iChannel, iChannelClient, sMessage, token[0]);
148 }
149 } else {
150 callChannelAction(iChannel, iChannelClient, sMessage, token[0]);
151 }
152 } else if (sParam.equalsIgnoreCase("NOTICE")) {
153 if (isCTCP) {
154 callChannelCTCPReply(iChannel, iChannelClient, sCTCP, sMessage, token[0]);
155 } else {
156 callChannelNotice(iChannel, iChannelClient, sMessage, token[0]);
157 }
158 }
159 } else if (myParser.getIRCStringConverter().equalsIgnoreCase(token[2], myParser.getMyNickname())) {
160 if (sParam.equalsIgnoreCase("PRIVMSG")) {
161 if (!isAction) {
162 if (isCTCP) {
163 callPrivateCTCP(sCTCP, sMessage, token[0]);
164 } else {
165 callPrivateMessage(sMessage, token[0]);
166 }
167 } else {
168 callPrivateAction(sMessage, token[0]);
169 }
170 } else if (sParam.equalsIgnoreCase("NOTICE")) {
171 if (isCTCP) {
172 callPrivateCTCPReply(sCTCP, sMessage, token[0]);
173 } else {
174 callPrivateNotice(sMessage, token[0]);
175 }
176 }
177 } else {
178 callDebugInfo(IRCParser.DEBUG_INFO, "Message for Other ("+token[2]+")");
179 if (sParam.equalsIgnoreCase("PRIVMSG")) {
180 if (!isAction) {
181 if (isCTCP) {
182 callUnknownCTCP(sCTCP, sMessage, token[2], token[0]);
183 } else {
184 callUnknownMessage(sMessage, token[2], token[0]);
185 }
186 } else {
187 callUnknownAction(sMessage, token[2], token[0]);
188 }
189 } else if (sParam.equalsIgnoreCase("NOTICE")) {
190 if (isCTCP) {
191 callUnknownCTCPReply(sCTCP, sMessage, token[2], token[0]);
192 } else {
193 callUnknownNotice(sMessage, token[2], token[0]);
194 }
195 }
196 }
197 }
198
199 /**
200 * Callback to all objects implementing the ChannelAction Callback.
201 *
202 * @see com.dmdirc.parser.irc.callbacks.interfaces.IChannelAction
203 * @param cChannel Channel where the action was sent to
204 * @param cChannelClient ChannelClient who sent the action (may be null if server)
205 * @param sMessage action contents
206 * @param sHost Hostname of sender (or servername)
207 * @return true if a method was called, false otherwise
208 */
209 protected boolean callChannelAction(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
/*
P/P * Method: bool callChannelAction(ChannelInfo, ChannelClientInfo, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@210 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
210 return getCallbackManager().getCallbackType("OnChannelAction").call(cChannel, cChannelClient, sMessage, sHost);
211 }
212
213 /**
214 * Callback to all objects implementing the ChannelCTCP Callback.
215 *
216 * @see com.dmdirc.parser.irc.callbacks.interfaces.IChannelCTCP
217 * @param cChannel Channel where CTCP was sent
218 * @param cChannelClient ChannelClient who sent the message (may be null if server)
219 * @param sType Type of CTCP (VERSION, TIME etc)
220 * @param sMessage Additional contents
221 * @param sHost Hostname of sender (or servername)
222 * @return true if a method was called, false otherwise
223 */
224 protected boolean callChannelCTCP(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sType, final String sMessage, final String sHost) {
/*
P/P * Method: bool callChannelCTCP(ChannelInfo, ChannelClientInfo, String, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@225 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
225 return getCallbackManager().getCallbackType("OnChannelCTCP").call(cChannel, cChannelClient, sType, sMessage, sHost);
226 }
227
228 /**
229 * Callback to all objects implementing the ChannelCTCPReply Callback.
230 *
231 * @see com.dmdirc.parser.irc.callbacks.interfaces.IChannelCTCPReply
232 * @param cChannel Channel where CTCPReply was sent
233 * @param cChannelClient ChannelClient who sent the message (may be null if server)
234 * @param sType Type of CTCPRReply (VERSION, TIME etc)
235 * @param sMessage Reply Contents
236 * @param sHost Hostname of sender (or servername)
237 * @return true if a method was called, false otherwise
238 */
239 protected boolean callChannelCTCPReply(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sType, final String sMessage, final String sHost) {
/*
P/P * Method: bool callChannelCTCPReply(ChannelInfo, ChannelClientInfo, String, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@240 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
240 return getCallbackManager().getCallbackType("OnChannelCTCPReply").call(cChannel, cChannelClient, sType, sMessage, sHost);
241 }
242
243 /**
244 * Callback to all objects implementing the ChannelMessage Callback.
245 *
246 * @see com.dmdirc.parser.irc.callbacks.interfaces.IChannelMessage
247 * @param cChannel Channel where the message was sent to
248 * @param cChannelClient ChannelClient who sent the message (may be null if server)
249 * @param sMessage Message contents
250 * @param sHost Hostname of sender (or servername)
251 * @return true if a method was called, false otherwise
252 */
253 protected boolean callChannelMessage(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
/*
P/P * Method: bool callChannelMessage(ChannelInfo, ChannelClientInfo, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@254 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
254 return getCallbackManager().getCallbackType("OnChannelMessage").call(cChannel, cChannelClient, sMessage, sHost);
255 }
256
257 /**
258 * Callback to all objects implementing the ChannelNotice Callback.
259 *
260 * @see com.dmdirc.parser.irc.callbacks.interfaces.IChannelNotice
261 * @param cChannel Channel where the notice was sent to
262 * @param cChannelClient ChannelClient who sent the notice (may be null if server)
263 * @param sMessage notice contents
264 * @param sHost Hostname of sender (or servername)
265 * @return true if a method was called, false otherwise
266 */
267 protected boolean callChannelNotice(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
/*
P/P * Method: bool callChannelNotice(ChannelInfo, ChannelClientInfo, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@268 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
268 return getCallbackManager().getCallbackType("OnChannelNotice").call(cChannel, cChannelClient, sMessage, sHost);
269 }
270
271 /**
272 * Callback to all objects implementing the PrivateAction Callback.
273 *
274 * @see com.dmdirc.parser.irc.callbacks.interfaces.IPrivateAction
275 * @param sMessage action contents
276 * @param sHost Hostname of sender (or servername)
277 * @return true if a method was called, false otherwise
278 */
279 protected boolean callPrivateAction(final String sMessage, final String sHost) {
/*
P/P * Method: bool callPrivateAction(String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@280 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
280 return getCallbackManager().getCallbackType("OnPrivateAction").call(sMessage, sHost);
281 }
282
283 /**
284 * Callback to all objects implementing the PrivateCTCP Callback.
285 *
286 * @see com.dmdirc.parser.irc.callbacks.interfaces.IPrivateCTCP
287 * @param sType Type of CTCP (VERSION, TIME etc)
288 * @param sMessage Additional contents
289 * @param sHost Hostname of sender (or servername)
290 * @return true if a method was called, false otherwise
291 */
292 protected boolean callPrivateCTCP(final String sType, final String sMessage, final String sHost) {
/*
P/P * Method: bool callPrivateCTCP(String, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@293 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
293 return getCallbackManager().getCallbackType("OnPrivateCTCP").call(sType, sMessage, sHost);
294 }
295
296 /**
297 * Callback to all objects implementing the PrivateCTCPReply Callback.
298 *
299 * @see com.dmdirc.parser.irc.callbacks.interfaces.IPrivateCTCPReply
300 * @param sType Type of CTCPRReply (VERSION, TIME etc)
301 * @param sMessage Reply Contents
302 * @param sHost Hostname of sender (or servername)
303 * @return true if a method was called, false otherwise
304 */
305 protected boolean callPrivateCTCPReply(final String sType, final String sMessage, final String sHost) {
/*
P/P * Method: bool callPrivateCTCPReply(String, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@306 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
306 return getCallbackManager().getCallbackType("OnPrivateCTCPReply").call(sType, sMessage, sHost);
307 }
308
309 /**
310 * Callback to all objects implementing the PrivateMessage Callback.
311 *
312 * @see com.dmdirc.parser.irc.callbacks.interfaces.IPrivateMessage
313 * @param sMessage Message contents
314 * @param sHost Hostname of sender (or servername)
315 * @return true if a method was called, false otherwise
316 */
317 protected boolean callPrivateMessage(final String sMessage, final String sHost) {
/*
P/P * Method: bool callPrivateMessage(String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@318 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
318 return getCallbackManager().getCallbackType("OnPrivateMessage").call(sMessage, sHost);
319 }
320
321 /**
322 * Callback to all objects implementing the PrivateNotice Callback.
323 *
324 * @see com.dmdirc.parser.irc.callbacks.interfaces.IPrivateNotice
325 * @param sMessage Notice contents
326 * @param sHost Hostname of sender (or servername)
327 * @return true if a method was called, false otherwise
328 */
329 protected boolean callPrivateNotice(final String sMessage, final String sHost) {
/*
P/P * Method: bool callPrivateNotice(String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@330 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
330 return getCallbackManager().getCallbackType("OnPrivateNotice").call(sMessage, sHost);
331 }
332
333 /**
334 * Callback to all objects implementing the UnknownAction Callback.
335 *
336 * @see com.dmdirc.parser.irc.callbacks.interfaces.IUnknownAction
337 * @param sMessage Action contents
338 * @param sTarget Actual target of action
339 * @param sHost Hostname of sender (or servername)
340 * @return true if a method was called, false otherwise
341 */
342 protected boolean callUnknownAction(final String sMessage, final String sTarget, final String sHost) {
/*
P/P * Method: bool callUnknownAction(String, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@343 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
343 return getCallbackManager().getCallbackType("OnUnknownAction").call(sMessage, sTarget, sHost);
344 }
345
346 /**
347 * Callback to all objects implementing the UnknownCTCP Callback.
348 *
349 * @see com.dmdirc.parser.irc.callbacks.interfaces.IUnknownCTCP
350 * @param sType Type of CTCP (VERSION, TIME etc)
351 * @param sMessage Additional contents
352 * @param sTarget Actual Target of CTCP
353 * @param sHost Hostname of sender (or servername)
354 * @return true if a method was called, false otherwise
355 */
356 protected boolean callUnknownCTCP(final String sType, final String sMessage, final String sTarget, final String sHost) {
/*
P/P * Method: bool callUnknownCTCP(String, String, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@357 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
357 return getCallbackManager().getCallbackType("OnUnknownCTCP").call(sType, sMessage, sTarget, sHost);
358 }
359
360 /**
361 * Callback to all objects implementing the UnknownCTCPReply Callback.
362 *
363 * @see com.dmdirc.parser.irc.callbacks.interfaces.IUnknownCTCPReply
364 * @param sType Type of CTCPRReply (VERSION, TIME etc)
365 * @param sMessage Reply Contents
366 * @param sTarget Actual Target of CTCPReply
367 * @param sHost Hostname of sender (or servername)
368 * @return true if a method was called, false otherwise
369 */
370 protected boolean callUnknownCTCPReply(final String sType, final String sMessage, final String sTarget, final String sHost) {
/*
P/P * Method: bool callUnknownCTCPReply(String, String, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@371 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
371 return getCallbackManager().getCallbackType("OnUnknownCTCPReply").call(sType, sMessage, sTarget, sHost);
372 }
373
374 /**
375 * Callback to all objects implementing the UnknownMessage Callback.
376 *
377 * @see com.dmdirc.parser.irc.callbacks.interfaces.IUnknownMessage
378 * @param sMessage Message contents
379 * @param sTarget Actual target of message
380 * @param sHost Hostname of sender (or servername)
381 * @return true if a method was called, false otherwise
382 */
383 protected boolean callUnknownMessage(final String sMessage, final String sTarget, final String sHost) {
/*
P/P * Method: bool callUnknownMessage(String, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@384 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
384 return getCallbackManager().getCallbackType("OnUnknownMessage").call(sMessage, sTarget, sHost);
385 }
386
387 /**
388 * Callback to all objects implementing the UnknownNotice Callback.
389 *
390 * @see com.dmdirc.parser.irc.callbacks.interfaces.IUnknownNotice
391 * @param sMessage Notice contents
392 * @param sTarget Actual target of notice
393 * @param sHost Hostname of sender (or servername)
394 * @return true if a method was called, false otherwise
395 */
396 protected boolean callUnknownNotice(final String sMessage, final String sTarget, final String sHost) {
/*
P/P * Method: bool callUnknownNotice(String, String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@397 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
397 return getCallbackManager().getCallbackType("OnUnknownNotice").call(sMessage, sTarget, sHost);
398 }
399
400
401 /**
402 * What does this IRCProcessor handle.
403 *
404 * @return String[] with the names of the tokens we handle.
405 */
406 @Override
407 public String[] handles() {
/*
P/P * Method: String[] handles()
*
* Postconditions:
* return_value == &new String[](handles#1)
* new String[](handles#1) num objects == 1
* return_value.length == 2
* return_value[0] == &"PRIVMSG"
* return_value[1] == &"NOTICE"
*/
408 return new String[]{"PRIVMSG", "NOTICE"};
409 }
410
411 /**
412 * Create a new instance of the IRCProcessor Object.
413 *
414 * @param parser IRCParser That owns this IRCProcessor
415 * @param manager ProcessingManager that is in charge of this IRCProcessor
416 */
/*
P/P * Method: void com.dmdirc.parser.irc.ProcessMessage(IRCParser, ProcessingManager)
*
* Postconditions:
* this.myManager == manager
* init'ed(this.myManager)
* this.myParser == parser
* init'ed(this.myParser)
*/
417 protected ProcessMessage (IRCParser parser, ProcessingManager manager) { super(parser, manager); }
418
419 }
SofCheck Inspector Build Version : 2.17854
| ProcessMessage.java |
2009-Jun-25 01:54:24 |
| ProcessMessage.class |
2009-Sep-02 17:04:16 |