Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ProcessMessage.java 23KB

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