Skip to content

Instantly share code, notes, and snippets.

@md-5
Created August 26, 2012 06:57
Show Gist options
  • Select an option

  • Save md-5/3475355 to your computer and use it in GitHub Desktop.

Select an option

Save md-5/3475355 to your computer and use it in GitHub Desktop.
ZNC Java
package in.znc.java;
import java.util.Collection;
public abstract class JavaModule {
private final String name;
public JavaModule(String name) {
this.name = name;
}
/**
* Called just before znc.conf is rehashed
*/
void OnPreRehash() {
}
/**
* This module hook is called after a <em>successful</em> rehash.
*/
void OnPostRehash() {
}
/**
* This module hook is called when a user gets disconnected from IRC.
*/
void OnIRCDisconnected() {
}
/**
* This module hook is called after a successful login to IRC.
*/
void OnIRCConnected() {
}
/**
* This module hook is called before logging in to the IRC server. The
* low-level connection is established at this point, but SSL handshakes
* didn't necessarily finish yet.
*
* @param sPass The server password that will be used.
* @param sNick The nick that will be used.
* @param sIdent The protocol identity that will be used. This is not the
* ident string that is transfered via e.g. oidentd!
* @param sRealName The real name that will be used.
* @return See CModule::EModRet.
*/
EModRet OnIRCRegistration(String sPass, String sNick, String sIdent, String sRealName) {
return EModRet.CONTINUE;
}
/**
* This module hook is called when a message is broadcasted to all users.
*
* @param sMessage The message that is broadcasted.
* @return see CModule::EModRet
*/
EModRet OnBroadcast(String sMessage) {
return EModRet.CONTINUE;
}
/**
* This module hook is called when a user mode on a channel changes.
*
* @param OpNick The nick who sent the mode change.
* @param Nick The nick whose channel mode changes.
* @param Channel The channel on which the user mode is changed.
* @param uMode The mode character that is changed, e.g. '
* @' for op.
* @param bAdded True if the mode is added, else false.
* @param bNoChange true if this mode change doesn't change anything because
* the nick already had this permission.
* @see CIRCSock::GetModeType() for converting uMode into a mode (e.g. 'o'
* for op).
*/
void OnChanPermission(final CNick OpNick, final CNick Nick, CChan Channel, char uMode, boolean bAdded, boolean bNoChange) {
}
/**
* Called when a nick is opped on a channel
*/
void OnOp(final CNick OpNick, final CNick Nick, CChan Channel, boolean bNoChange) {
}
/**
* Called when a nick is deopped on a channel
*/
void OnDeop(final CNick OpNick, final CNick Nick, CChan Channel, boolean bNoChange) {
}
/**
* Called when a nick is voiced on a channel
*/
void OnVoice(final CNick OpNick, final CNick Nick, CChan Channel, boolean bNoChange) {
}
/**
* Called when a nick is devoiced on a channel
*/
void OnDevoice(final CNick OpNick, final CNick Nick, CChan Channel, boolean bNoChange) {
}
/**
* Called on an individual channel mode change.
*
* @param OpNick The nick who changes the channel mode.
* @param Channel The channel whose mode is changed.
* @param uMode The mode character that is changed.
* @param sArg The argument to the mode character, if any.
* @param bAdded True if this mode is added ("+"), else false.
* @param bNoChange True if this mode was already effective before.
*/
void OnMode(final CNick OpNick, CChan Channel, char uMode, final String sArg, boolean bAdded, boolean bNoChange) {
}
/**
* Called on any channel mode change. This is called before the more
* detailed mode hooks like e.g. OnOp() and OnMode().
*
* @param OpNick The nick who changes the channel mode.
* @param Channel The channel whose mode is changed.
* @param sModes The raw mode change, e.g. "+s-io".
* @param sArgs All arguments to the mode change from sModes.
*/
void OnRawMode(final CNick OpNick, CChan Channel, final String sModes, final String sArgs) {
}
/**
* Called on any raw IRC line received from the <em>IRC server</em>.
*
* @param sLine The line read from the server.
* @return See CModule::EModRet.
*/
EModRet OnRaw(String sLine) {
return EModRet.CONTINUE;
}
/**
* Called when a command to *status is sent.
*
* @param sCommand The command sent.
* @return See CModule::EModRet.
*/
EModRet OnStatusCommand(String sCommand) {
return EModRet.CONTINUE;
}
/**
* Called when a command to your module is sent, e.g. query to *modname.
*
* @param sCommand The command that was sent.
*/
void OnModCommand(final String sCommand) {
}
/**
* This is similar to OnModCommand(), but it is only called if HandleCommand
* didn't find any that wants to handle this. This is only called if
* HandleCommand() is called, which practically means that this is only
* called if you don't overload OnModCommand().
*
* @param sCommand The command that was sent.
*/
void OnUnknownModCommand(final String sCommand) {
}
/**
* Called when a your module nick was sent a notice.
*
* @param sMessage The message which was sent.
*/
void OnModNotice(final String sMessage) {
}
/**
* Called when your module nick was sent a CTCP message. OnModCommand()
* won't be called for this message.
*
* @param sMessage The message which was sent.
*/
void OnModCTCP(final String sMessage) {
}
/**
* Called when a nick quit from IRC.
*
* @param Nick The nick which quit.
* @param sMessage The quit message.
* @param vChans List of channels which you and nick share.
*/
void OnQuit(final CNick Nick, final String sMessage, Collection<CChan> vChans) {
}
/**
* Called when a nickname change occurs. If we are changing our nick,
* sNewNick will equal m_pIRCSock->GetNick().
*
* @param Nick The nick which changed its nickname
* @param sNewNick The new nickname.
* @param vChans Channels which we and nick share.
*/
void OnNick(final CNick Nick, final String sNewNick, Collection<CChan> vChans) {
}
/**
* Called when a nick is kicked from a channel.
*
* @param OpNick The nick which generated the kick.
* @param sKickedNick The nick which was kicked.
* @param Channel The channel on which this kick occurs.
* @param sMessage The kick message.
*/
void OnKick(final CNick OpNick, final String sKickedNick, CChan Channel, final String sMessage) {
}
/**
* Called when a nick joins a channel.
*
* @param Nick The nick who joined.
* @param Channel The channel which was joined.
*/
void OnJoin(final CNick Nick, CChan Channel) {
}
/**
* Called when a nick parts a channel.
*
* @param Nick The nick who parted.
* @param Channel The channel which was parted.
* @param sMessage The part message.
*/
void OnPart(final CNick Nick, CChan Channel, final String sMessage) {
}
/**
* Called when user is invited into a channel
*
* @param Nick The nick who invited you.
* @param sChan The channel the user got invited into
* @return See CModule::EModRet.
*/
EModRet OnInvite(final CNick Nick, final String sChan) {
return EModRet.CONTINUE;
}
/**
* Called before a channel buffer is played back to a client.
*
* @param Chan The channel which will be played back.
* @param Client The client the buffer will be played back to.
* @return See CModule::EModRet.
*/
EModRet OnChanBufferStarting(CChan Chan, CClient Client) {
return EModRet.CONTINUE;
}
/**
* Called after a channel buffer was played back to a client.
*
* @param Chan The channel which was played back.
* @param Client The client the buffer was played back to.
* @return See CModule::EModRet.
*/
EModRet OnChanBufferEnding(CChan Chan, CClient Client) {
return EModRet.CONTINUE;
}
/**
* Called when for each line during a channel's buffer play back.
*
* @param Chan The channel this playback is from.
* @param Client The client the buffer is played back to.
* @param sLine The current line of buffer playback. This is a raw IRC
* traffic line!
* @return See CModule::EModRet.
*/
EModRet OnChanBufferPlayLine(CChan Chan, CClient Client, String sLine) {
return EModRet.CONTINUE;
}
/**
* Called when a line from the query buffer is played back.
*
* @param Client The client this line will go to.
* @param sLine The raw IRC traffic line from the buffer.
* @return See CModule::EModRet.
*/
EModRet OnPrivBufferPlayLine(CClient Client, String sLine) {
return EModRet.CONTINUE;
}
/**
* Called when a client successfully logged in to ZNC.
*/
void OnClientLogin() {
}
/**
* Called when a client disconnected from ZNC.
*/
void OnClientDisconnect() {
}
/**
* This module hook is called when a client sends a raw traffic line to ZNC.
*
* @param sLine The raw traffic line sent.
* @return See CModule::EModRet.
*/
EModRet OnUserRaw(String sLine) {
return EModRet.CONTINUE;
}
/**
* This module hook is called when a client sends a CTCP reply.
*
* @param sTarget The target for the CTCP reply. Could be a channel name or
* a nick name.
* @param sMessage The CTCP reply message.
* @return See CModule::EModRet.
*/
EModRet OnUserCTCPReply(String sTarget, String sMessage) {
return EModRet.CONTINUE;
}
/**
* This module hook is called when a client sends a CTCP request.
*
* @param sTarget The target for the CTCP request. Could be a channel name
* or a nick name.
* @param sMessage The CTCP request message.
* @return See CModule::EModRet.
* @note This is not called for CTCP ACTION messages, use
* CModule::OnUserAction() instead.
*/
EModRet OnUserCTCP(String sTarget, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when a client sends a CTCP ACTION request ("/me").
*
* @param sTarget The target for the CTCP ACTION. Could be a channel name or
* a nick name.
* @param sMessage The action message.
* @return See CModule::EModRet.
* @note CModule::OnUserCTCP() will not be called for this message.
*/
EModRet OnUserAction(String sTarget, String sMessage) {
return EModRet.CONTINUE;
}
/**
* This module hook is called when a user sends a normal IRC message.
*
* @param sTarget The target of the message. Could be a channel name or a
* nick name.
* @param sMessage The message which was sent.
* @return See CModule::EModRet.
*/
EModRet OnUserMsg(String sTarget, String sMessage) {
return EModRet.CONTINUE;
}
/**
* This module hook is called when a user sends a notice message.
*
* @param sTarget The target of the message. Could be a channel name or a
* nick name.
* @param sMessage The message which was sent.
* @return See CModule::EModRet.
*/
EModRet OnUserNotice(String sTarget, String sMessage) {
return EModRet.CONTINUE;
}
/**
* This hooks is called when a user sends a JOIN message.
*
* @param sChannel The channel name the join is for.
* @param sKey The key for the channel.
* @return See CModule::EModRet.
*/
EModRet OnUserJoin(String sChannel, String sKey) {
return EModRet.CONTINUE;
}
/**
* This hooks is called when a user sends a PART message.
*
* @param sChannel The channel name the part is for.
* @param sMessage The part message the client sent.
* @return See CModule::EModRet.
*/
EModRet OnUserPart(String sChannel, String sMessage) {
return EModRet.CONTINUE;
}
/**
* This module hook is called when a user wants to change a channel topic.
*
* @param sChannel The channel.
* @param sTopic The new topic which the user sent.
* @return See CModule::EModRet.
*/
EModRet OnUserTopic(String sChannel, String sTopic) {
return EModRet.CONTINUE;
}
/**
* This hook is called when a user requests a channel's topic.
*
* @param sChannel The channel for which the request is.
* @return See CModule::EModRet.
*/
EModRet OnUserTopicRequest(String sChannel) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a CTCP reply <em>from IRC</em>.
*
* @param Nick The nick the CTCP reply is from.
* @param sMessage The CTCP reply message.
* @return See CModule::EModRet.
*/
EModRet OnCTCPReply(CNick Nick, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a private CTCP request <em>from IRC</em>.
*
* @param Nick The nick the CTCP request is from.
* @param sMessage The CTCP request message.
* @return See CModule::EModRet.
*/
EModRet OnPrivCTCP(CNick Nick, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a channel CTCP request <em>from IRC</em>.
*
* @param Nick The nick the CTCP request is from.
* @param Channel The channel to which the request was sent.
* @param sMessage The CTCP request message.
* @return See CModule::EModRet.
*/
EModRet OnChanCTCP(CNick Nick, CChan Channel, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a private CTCP ACTION ("/me" in query) <em>from
* IRC</em>. This is called after CModule::OnPrivCTCP().
*
* @param Nick The nick the action came from.
* @param sMessage The action message
* @return See CModule::EModRet.
*/
EModRet OnPrivAction(CNick Nick, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a channel CTCP ACTION ("/me" in a channel)
* <em>from IRC</em>. This is called after CModule::OnChanCTCP().
*
* @param Nick The nick the action came from.
* @param Channel The channel the action was sent to.
* @param sMessage The action message
* @return See CModule::EModRet.
*/
EModRet OnChanAction(CNick Nick, CChan Channel, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a private message <em>from IRC</em>.
*
* @param Nick The nick which sent the message.
* @param sMessage The message.
* @return See CModule::EModRet.
*/
EModRet OnPrivMsg(CNick Nick, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a channel message <em>from IRC</em>.
*
* @param Nick The nick which sent the message.
* @param Channel The channel to which the message was sent.
* @param sMessage The message.
* @return See CModule::EModRet.
*/
EModRet OnChanMsg(CNick Nick, CChan Channel, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a private notice.
*
* @param Nick The nick which sent the notice.
* @param sMessage The notice message.
* @return See CModule::EModRet.
*/
EModRet OnPrivNotice(CNick Nick, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a channel notice.
*
* @param Nick The nick which sent the notice.
* @param Channel The channel to which the notice was sent.
* @param sMessage The notice message.
* @return See CModule::EModRet.
*/
EModRet OnChanNotice(CNick Nick, CChan Channel, String sMessage) {
return EModRet.CONTINUE;
}
/**
* Called when we receive a channel topic change <em>from IRC</em>.
*
* @param Nick The nick which changed the topic.
* @param Channel The channel whose topic was changed.
* @param sTopic The new topic.
* @return See CModule::EModRet.
*/
EModRet OnTopic(CNick Nick, CChan Channel, String sTopic) {
return EModRet.CONTINUE;
}
/**
* Called for every CAP received via CAP LS from server.
*
* @param sCap capability supported by server.
* @return true if your module supports this CAP and needs to turn it on
* with CAP REQ.
*/
boolean OnServerCapAvailable(final String sCap) {
return false;
}
/**
* Called for every CAP accepted or rejected by server (with CAP ACK or CAP
* NAK after our CAP REQ).
*
* @param sCap capability accepted/rejected by server.
* @param bSuccess true if capability was accepted, false if rejected.
*/
void OnServerCapResult(final String sCap, boolean bSuccess) {
}
/**
* This module hook is called just before ZNC tries to join a channel by
* itself because it's in the config but wasn't joined yet.
*
* @param Channel The channel which will be joined.
* @return See CModule::EModRet.
*/
EModRet OnTimerAutoJoin(CChan Channel) {
return EModRet.CONTINUE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment