Guest User

Untitled

a guest
Dec 10th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.09 KB | None | 0 0
  1. package in.znc.java;
  2.  
  3. import java.util.Collection;
  4.  
  5. public abstract class JavaModule {
  6.  
  7. private final String name;
  8.  
  9. public JavaModule(String name) {
  10. this.name = name;
  11. }
  12.  
  13. /**
  14. * Called just before znc.conf is rehashed
  15. */
  16. void OnPreRehash() {
  17. }
  18.  
  19. /**
  20. * This module hook is called after a <em>successful</em> rehash.
  21. */
  22. void OnPostRehash() {
  23. }
  24.  
  25. /**
  26. * This module hook is called when a user gets disconnected from IRC.
  27. */
  28. void OnIRCDisconnected() {
  29. }
  30.  
  31. /**
  32. * This module hook is called after a successful login to IRC.
  33. */
  34. void OnIRCConnected() {
  35. }
  36.  
  37. /**
  38. * This module hook is called before logging in to the IRC server. The
  39. * low-level connection is established at this point, but SSL handshakes
  40. * didn't necessarily finish yet.
  41. *
  42. * @param sPass The server password that will be used.
  43. * @param sNick The nick that will be used.
  44. * @param sIdent The protocol identity that will be used. This is not the
  45. * ident string that is transfered via e.g. oidentd!
  46. * @param sRealName The real name that will be used.
  47. * @return See CModule::EModRet.
  48. */
  49. EModRet OnIRCRegistration(String sPass, String sNick, String sIdent, String sRealName) {
  50. return EModRet.CONTINUE;
  51. }
  52.  
  53. /**
  54. * This module hook is called when a message is broadcasted to all users.
  55. *
  56. * @param sMessage The message that is broadcasted.
  57. * @return see CModule::EModRet
  58. */
  59. EModRet OnBroadcast(String sMessage) {
  60. return EModRet.CONTINUE;
  61. }
  62.  
  63. /**
  64. * This module hook is called when a user mode on a channel changes.
  65. *
  66. * @param OpNick The nick who sent the mode change.
  67. * @param Nick The nick whose channel mode changes.
  68. * @param Channel The channel on which the user mode is changed.
  69. * @param uMode The mode character that is changed, e.g. '
  70. * @' for op.
  71. * @param bAdded True if the mode is added, else false.
  72. * @param bNoChange true if this mode change doesn't change anything because
  73. * the nick already had this permission.
  74. * @see CIRCSock::GetModeType() for converting uMode into a mode (e.g. 'o'
  75. * for op).
  76. */
  77. void OnChanPermission(final CNick OpNick, final CNick Nick, CChan Channel, char uMode, boolean bAdded, boolean bNoChange) {
  78. }
  79.  
  80. /**
  81. * Called when a nick is opped on a channel
  82. */
  83. void OnOp(final CNick OpNick, final CNick Nick, CChan Channel, boolean bNoChange) {
  84. }
  85.  
  86. /**
  87. * Called when a nick is deopped on a channel
  88. */
  89. void OnDeop(final CNick OpNick, final CNick Nick, CChan Channel, boolean bNoChange) {
  90. }
  91.  
  92. /**
  93. * Called when a nick is voiced on a channel
  94. */
  95. void OnVoice(final CNick OpNick, final CNick Nick, CChan Channel, boolean bNoChange) {
  96. }
  97.  
  98. /**
  99. * Called when a nick is devoiced on a channel
  100. */
  101. void OnDevoice(final CNick OpNick, final CNick Nick, CChan Channel, boolean bNoChange) {
  102. }
  103.  
  104. /**
  105. * Called on an individual channel mode change.
  106. *
  107. * @param OpNick The nick who changes the channel mode.
  108. * @param Channel The channel whose mode is changed.
  109. * @param uMode The mode character that is changed.
  110. * @param sArg The argument to the mode character, if any.
  111. * @param bAdded True if this mode is added ("+"), else false.
  112. * @param bNoChange True if this mode was already effective before.
  113. */
  114. void OnMode(final CNick OpNick, CChan Channel, char uMode, final String sArg, boolean bAdded, boolean bNoChange) {
  115. }
  116.  
  117. /**
  118. * Called on any channel mode change. This is called before the more
  119. * detailed mode hooks like e.g. OnOp() and OnMode().
  120. *
  121. * @param OpNick The nick who changes the channel mode.
  122. * @param Channel The channel whose mode is changed.
  123. * @param sModes The raw mode change, e.g. "+s-io".
  124. * @param sArgs All arguments to the mode change from sModes.
  125. */
  126. void OnRawMode(final CNick OpNick, CChan Channel, final String sModes, final String sArgs) {
  127. }
  128.  
  129. /**
  130. * Called on any raw IRC line received from the <em>IRC server</em>.
  131. *
  132. * @param sLine The line read from the server.
  133. * @return See CModule::EModRet.
  134. */
  135. EModRet OnRaw(String sLine) {
  136. return EModRet.CONTINUE;
  137. }
  138.  
  139. /**
  140. * Called when a command to *status is sent.
  141. *
  142. * @param sCommand The command sent.
  143. * @return See CModule::EModRet.
  144. */
  145. EModRet OnStatusCommand(String sCommand) {
  146. return EModRet.CONTINUE;
  147. }
  148.  
  149. /**
  150. * Called when a command to your module is sent, e.g. query to *modname.
  151. *
  152. * @param sCommand The command that was sent.
  153. */
  154. void OnModCommand(final String sCommand) {
  155. }
  156.  
  157. /**
  158. * This is similar to OnModCommand(), but it is only called if HandleCommand
  159. * didn't find any that wants to handle this. This is only called if
  160. * HandleCommand() is called, which practically means that this is only
  161. * called if you don't overload OnModCommand().
  162. *
  163. * @param sCommand The command that was sent.
  164. */
  165. void OnUnknownModCommand(final String sCommand) {
  166. }
  167.  
  168. /**
  169. * Called when a your module nick was sent a notice.
  170. *
  171. * @param sMessage The message which was sent.
  172. */
  173. void OnModNotice(final String sMessage) {
  174. }
  175.  
  176. /**
  177. * Called when your module nick was sent a CTCP message. OnModCommand()
  178. * won't be called for this message.
  179. *
  180. * @param sMessage The message which was sent.
  181. */
  182. void OnModCTCP(final String sMessage) {
  183. }
  184.  
  185. /**
  186. * Called when a nick quit from IRC.
  187. *
  188. * @param Nick The nick which quit.
  189. * @param sMessage The quit message.
  190. * @param vChans List of channels which you and nick share.
  191. */
  192. void OnQuit(final CNick Nick, final String sMessage, Collection<CChan> vChans) {
  193. }
  194.  
  195. /**
  196. * Called when a nickname change occurs. If we are changing our nick,
  197. * sNewNick will equal m_pIRCSock->GetNick().
  198. *
  199. * @param Nick The nick which changed its nickname
  200. * @param sNewNick The new nickname.
  201. * @param vChans Channels which we and nick share.
  202. */
  203. void OnNick(final CNick Nick, final String sNewNick, Collection<CChan> vChans) {
  204. }
  205.  
  206. /**
  207. * Called when a nick is kicked from a channel.
  208. *
  209. * @param OpNick The nick which generated the kick.
  210. * @param sKickedNick The nick which was kicked.
  211. * @param Channel The channel on which this kick occurs.
  212. * @param sMessage The kick message.
  213. */
  214. void OnKick(final CNick OpNick, final String sKickedNick, CChan Channel, final String sMessage) {
  215. }
  216.  
  217. /**
  218. * Called when a nick joins a channel.
  219. *
  220. * @param Nick The nick who joined.
  221. * @param Channel The channel which was joined.
  222. */
  223. void OnJoin(final CNick Nick, CChan Channel) {
  224. }
  225.  
  226. /**
  227. * Called when a nick parts a channel.
  228. *
  229. * @param Nick The nick who parted.
  230. * @param Channel The channel which was parted.
  231. * @param sMessage The part message.
  232. */
  233. void OnPart(final CNick Nick, CChan Channel, final String sMessage) {
  234. }
  235.  
  236. /**
  237. * Called when user is invited into a channel
  238. *
  239. * @param Nick The nick who invited you.
  240. * @param sChan The channel the user got invited into
  241. * @return See CModule::EModRet.
  242. */
  243. EModRet OnInvite(final CNick Nick, final String sChan) {
  244. return EModRet.CONTINUE;
  245. }
  246.  
  247. /**
  248. * Called before a channel buffer is played back to a client.
  249. *
  250. * @param Chan The channel which will be played back.
  251. * @param Client The client the buffer will be played back to.
  252. * @return See CModule::EModRet.
  253. */
  254. EModRet OnChanBufferStarting(CChan Chan, CClient Client) {
  255. return EModRet.CONTINUE;
  256. }
  257.  
  258. /**
  259. * Called after a channel buffer was played back to a client.
  260. *
  261. * @param Chan The channel which was played back.
  262. * @param Client The client the buffer was played back to.
  263. * @return See CModule::EModRet.
  264. */
  265. EModRet OnChanBufferEnding(CChan Chan, CClient Client) {
  266. return EModRet.CONTINUE;
  267. }
  268.  
  269. /**
  270. * Called when for each line during a channel's buffer play back.
  271. *
  272. * @param Chan The channel this playback is from.
  273. * @param Client The client the buffer is played back to.
  274. * @param sLine The current line of buffer playback. This is a raw IRC
  275. * traffic line!
  276. * @return See CModule::EModRet.
  277. */
  278. EModRet OnChanBufferPlayLine(CChan Chan, CClient Client, String sLine) {
  279. return EModRet.CONTINUE;
  280. }
  281.  
  282. /**
  283. * Called when a line from the query buffer is played back.
  284. *
  285. * @param Client The client this line will go to.
  286. * @param sLine The raw IRC traffic line from the buffer.
  287. * @return See CModule::EModRet.
  288. */
  289. EModRet OnPrivBufferPlayLine(CClient Client, String sLine) {
  290. return EModRet.CONTINUE;
  291. }
  292.  
  293. /**
  294. * Called when a client successfully logged in to ZNC.
  295. */
  296. void OnClientLogin() {
  297. }
  298.  
  299. /**
  300. * Called when a client disconnected from ZNC.
  301. */
  302. void OnClientDisconnect() {
  303. }
  304.  
  305. /**
  306. * This module hook is called when a client sends a raw traffic line to ZNC.
  307. *
  308. * @param sLine The raw traffic line sent.
  309. * @return See CModule::EModRet.
  310. */
  311. EModRet OnUserRaw(String sLine) {
  312. return EModRet.CONTINUE;
  313. }
  314.  
  315. /**
  316. * This module hook is called when a client sends a CTCP reply.
  317. *
  318. * @param sTarget The target for the CTCP reply. Could be a channel name or
  319. * a nick name.
  320. * @param sMessage The CTCP reply message.
  321. * @return See CModule::EModRet.
  322. */
  323. EModRet OnUserCTCPReply(String sTarget, String sMessage) {
  324. return EModRet.CONTINUE;
  325. }
  326.  
  327. /**
  328. * This module hook is called when a client sends a CTCP request.
  329. *
  330. * @param sTarget The target for the CTCP request. Could be a channel name
  331. * or a nick name.
  332. * @param sMessage The CTCP request message.
  333. * @return See CModule::EModRet.
  334. * @note This is not called for CTCP ACTION messages, use
  335. * CModule::OnUserAction() instead.
  336. */
  337. EModRet OnUserCTCP(String sTarget, String sMessage) {
  338. return EModRet.CONTINUE;
  339. }
  340.  
  341. /**
  342. * Called when a client sends a CTCP ACTION request ("/me").
  343. *
  344. * @param sTarget The target for the CTCP ACTION. Could be a channel name or
  345. * a nick name.
  346. * @param sMessage The action message.
  347. * @return See CModule::EModRet.
  348. * @note CModule::OnUserCTCP() will not be called for this message.
  349. */
  350. EModRet OnUserAction(String sTarget, String sMessage) {
  351. return EModRet.CONTINUE;
  352. }
  353.  
  354. /**
  355. * This module hook is called when a user sends a normal IRC message.
  356. *
  357. * @param sTarget The target of the message. Could be a channel name or a
  358. * nick name.
  359. * @param sMessage The message which was sent.
  360. * @return See CModule::EModRet.
  361. */
  362. EModRet OnUserMsg(String sTarget, String sMessage) {
  363. return EModRet.CONTINUE;
  364. }
  365.  
  366. /**
  367. * This module hook is called when a user sends a notice message.
  368. *
  369. * @param sTarget The target of the message. Could be a channel name or a
  370. * nick name.
  371. * @param sMessage The message which was sent.
  372. * @return See CModule::EModRet.
  373. */
  374. EModRet OnUserNotice(String sTarget, String sMessage) {
  375. return EModRet.CONTINUE;
  376. }
  377.  
  378. /**
  379. * This hooks is called when a user sends a JOIN message.
  380. *
  381. * @param sChannel The channel name the join is for.
  382. * @param sKey The key for the channel.
  383. * @return See CModule::EModRet.
  384. */
  385. EModRet OnUserJoin(String sChannel, String sKey) {
  386. return EModRet.CONTINUE;
  387. }
  388.  
  389. /**
  390. * This hooks is called when a user sends a PART message.
  391. *
  392. * @param sChannel The channel name the part is for.
  393. * @param sMessage The part message the client sent.
  394. * @return See CModule::EModRet.
  395. */
  396. EModRet OnUserPart(String sChannel, String sMessage) {
  397. return EModRet.CONTINUE;
  398. }
  399.  
  400. /**
  401. * This module hook is called when a user wants to change a channel topic.
  402. *
  403. * @param sChannel The channel.
  404. * @param sTopic The new topic which the user sent.
  405. * @return See CModule::EModRet.
  406. */
  407. EModRet OnUserTopic(String sChannel, String sTopic) {
  408. return EModRet.CONTINUE;
  409. }
  410.  
  411. /**
  412. * This hook is called when a user requests a channel's topic.
  413. *
  414. * @param sChannel The channel for which the request is.
  415. * @return See CModule::EModRet.
  416. */
  417. EModRet OnUserTopicRequest(String sChannel) {
  418. return EModRet.CONTINUE;
  419. }
  420.  
  421. /**
  422. * Called when we receive a CTCP reply <em>from IRC</em>.
  423. *
  424. * @param Nick The nick the CTCP reply is from.
  425. * @param sMessage The CTCP reply message.
  426. * @return See CModule::EModRet.
  427. */
  428. EModRet OnCTCPReply(CNick Nick, String sMessage) {
  429. return EModRet.CONTINUE;
  430. }
  431.  
  432. /**
  433. * Called when we receive a private CTCP request <em>from IRC</em>.
  434. *
  435. * @param Nick The nick the CTCP request is from.
  436. * @param sMessage The CTCP request message.
  437. * @return See CModule::EModRet.
  438. */
  439. EModRet OnPrivCTCP(CNick Nick, String sMessage) {
  440. return EModRet.CONTINUE;
  441. }
  442.  
  443. /**
  444. * Called when we receive a channel CTCP request <em>from IRC</em>.
  445. *
  446. * @param Nick The nick the CTCP request is from.
  447. * @param Channel The channel to which the request was sent.
  448. * @param sMessage The CTCP request message.
  449. * @return See CModule::EModRet.
  450. */
  451. EModRet OnChanCTCP(CNick Nick, CChan Channel, String sMessage) {
  452. return EModRet.CONTINUE;
  453. }
  454.  
  455. /**
  456. * Called when we receive a private CTCP ACTION ("/me" in query) <em>from
  457. * IRC</em>. This is called after CModule::OnPrivCTCP().
  458. *
  459. * @param Nick The nick the action came from.
  460. * @param sMessage The action message
  461. * @return See CModule::EModRet.
  462. */
  463. EModRet OnPrivAction(CNick Nick, String sMessage) {
  464. return EModRet.CONTINUE;
  465. }
  466.  
  467. /**
  468. * Called when we receive a channel CTCP ACTION ("/me" in a channel)
  469. * <em>from IRC</em>. This is called after CModule::OnChanCTCP().
  470. *
  471. * @param Nick The nick the action came from.
  472. * @param Channel The channel the action was sent to.
  473. * @param sMessage The action message
  474. * @return See CModule::EModRet.
  475. */
  476. EModRet OnChanAction(CNick Nick, CChan Channel, String sMessage) {
  477. return EModRet.CONTINUE;
  478. }
  479.  
  480. /**
  481. * Called when we receive a private message <em>from IRC</em>.
  482. *
  483. * @param Nick The nick which sent the message.
  484. * @param sMessage The message.
  485. * @return See CModule::EModRet.
  486. */
  487. EModRet OnPrivMsg(CNick Nick, String sMessage) {
  488. return EModRet.CONTINUE;
  489. }
  490.  
  491. /**
  492. * Called when we receive a channel message <em>from IRC</em>.
  493. *
  494. * @param Nick The nick which sent the message.
  495. * @param Channel The channel to which the message was sent.
  496. * @param sMessage The message.
  497. * @return See CModule::EModRet.
  498. */
  499. EModRet OnChanMsg(CNick Nick, CChan Channel, String sMessage) {
  500. return EModRet.CONTINUE;
  501. }
  502.  
  503. /**
  504. * Called when we receive a private notice.
  505. *
  506. * @param Nick The nick which sent the notice.
  507. * @param sMessage The notice message.
  508. * @return See CModule::EModRet.
  509. */
  510. EModRet OnPrivNotice(CNick Nick, String sMessage) {
  511. return EModRet.CONTINUE;
  512. }
  513.  
  514. /**
  515. * Called when we receive a channel notice.
  516. *
  517. * @param Nick The nick which sent the notice.
  518. * @param Channel The channel to which the notice was sent.
  519. * @param sMessage The notice message.
  520. * @return See CModule::EModRet.
  521. */
  522. EModRet OnChanNotice(CNick Nick, CChan Channel, String sMessage) {
  523. return EModRet.CONTINUE;
  524. }
  525.  
  526. /**
  527. * Called when we receive a channel topic change <em>from IRC</em>.
  528. *
  529. * @param Nick The nick which changed the topic.
  530. * @param Channel The channel whose topic was changed.
  531. * @param sTopic The new topic.
  532. * @return See CModule::EModRet.
  533. */
  534. EModRet OnTopic(CNick Nick, CChan Channel, String sTopic) {
  535. return EModRet.CONTINUE;
  536. }
  537.  
  538. /**
  539. * Called for every CAP received via CAP LS from server.
  540. *
  541. * @param sCap capability supported by server.
  542. * @return true if your module supports this CAP and needs to turn it on
  543. * with CAP REQ.
  544. */
  545. boolean OnServerCapAvailable(final String sCap) {
  546. return false;
  547. }
  548.  
  549. /**
  550. * Called for every CAP accepted or rejected by server (with CAP ACK or CAP
  551. * NAK after our CAP REQ).
  552. *
  553. * @param sCap capability accepted/rejected by server.
  554. * @param bSuccess true if capability was accepted, false if rejected.
  555. */
  556. void OnServerCapResult(final String sCap, boolean bSuccess) {
  557. }
  558.  
  559. /**
  560. * This module hook is called just before ZNC tries to join a channel by
  561. * itself because it's in the config but wasn't joined yet.
  562. *
  563. * @param Channel The channel which will be joined.
  564. * @return See CModule::EModRet.
  565. */
  566. EModRet OnTimerAutoJoin(CChan Channel) {
  567. return EModRet.CONTINUE;
  568. }
  569. }
Add Comment
Please, Sign In to add comment