Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ProcessMessage.java 26KB

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