ZNC  trunk
Public Types | Public Member Functions | Protected Attributes | List of all members
CModule Class Reference

The base class for your own ZNC modules. More...

#include <Modules.h>

+ Collaboration diagram for CModule:

Public Types

enum  EModRet { CONTINUE = 1 , HALT = 2 , HALTMODS = 3 , HALTCORE = 4 }
 This enum is just used for return from module hooks. More...
 
enum  EModException { UNLOAD }
 

Public Member Functions

 CModule (ModHandle pDLL, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sDataDir, CModInfo::EModuleType eType=CModInfo::NetworkModule)
 
virtual ~CModule ()
 
 CModule (const CModule &)=delete
 
CModuleoperator= (const CModule &)=delete
 
void SetUser (CUser *pUser)
 
void SetNetwork (CIRCNetwork *pNetwork)
 
void SetClient (CClient *pClient)
 
void Unload ()
 This function throws CModule::UNLOAD which causes this module to be unloaded. More...
 
virtual bool OnLoad (const CString &sArgsi, CString &sMessage)
 This module hook is called when a module is loaded. More...
 
virtual bool OnBoot ()
 This module hook is called during ZNC startup. More...
 
virtual bool WebRequiresLogin ()
 Modules which can only be used with an active user session have to return true here. More...
 
virtual bool WebRequiresAdmin ()
 Return true if this module should only be usable for admins on the web. More...
 
virtual CString GetWebMenuTitle ()
 Return the title of the module's section in the web interface's side bar. More...
 
virtual CString GetWebPath ()
 
virtual CString GetWebFilesPath ()
 
virtual bool OnWebPreRequest (CWebSock &WebSock, const CString &sPageName)
 For WebMods: Called before the list of registered SubPages will be checked. More...
 
virtual bool OnWebRequest (CWebSock &WebSock, const CString &sPageName, CTemplate &Tmpl)
 If OnWebPreRequest returned false, and the RequiresAdmin/IsAdmin check has been passed, this method will be called with the page name. More...
 
virtual bool ValidateWebRequestCSRFCheck (CWebSock &WebSock, const CString &sPageName)
 If ValidateWebRequestCSRFCheck returned false, a CSRF error will be printed. More...
 
virtual void AddSubPage (TWebSubPage spSubPage)
 Registers a sub page for the sidebar. More...
 
virtual void ClearSubPages ()
 Removes all registered (AddSubPage'd) SubPages. More...
 
virtual VWebSubPagesGetSubPages ()
 Returns a list of all registered SubPages. More...
 
virtual bool OnEmbeddedWebRequest (CWebSock &WebSock, const CString &sPageName, CTemplate &Tmpl)
 Using this hook, module can embed web stuff directly to different places. More...
 
virtual void OnPreRehash ()
 Called just before znc.conf is rehashed. More...
 
virtual void OnPostRehash ()
 This module hook is called after a successful rehash. More...
 
virtual void OnIRCDisconnected ()
 This module hook is called when a user gets disconnected from IRC. More...
 
virtual void OnIRCConnected ()
 This module hook is called after a successful login to IRC. More...
 
virtual EModRet OnIRCConnecting (CIRCSock *pIRCSock)
 This module hook is called just before ZNC tries to establish a connection to an IRC server. More...
 
virtual void OnIRCConnectionError (CIRCSock *pIRCSock)
 This module hook is called when a CIRCSock fails to connect or a module returned HALTCORE from OnIRCConnecting. More...
 
virtual EModRet OnIRCRegistration (CString &sPass, CString &sNick, CString &sIdent, CString &sRealName)
 This module hook is called before loging in to the IRC server. More...
 
virtual EModRet OnBroadcast (CString &sMessage)
 This module hook is called when a message is broadcasted to all users. More...
 
virtual void OnChanPermission3 (const CNick *pOpNick, const CNick &Nick, CChan &Channel, char cMode, bool bAdded, bool bNoChange)
 This module hook is called when a user mode on a channel changes. More...
 
virtual void OnChanPermission2 (const CNick *pOpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
 
virtual void OnChanPermission (const CNick &OpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
 
virtual void OnOp2 (const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
 Called when a nick is opped on a channel. More...
 
virtual void OnOp (const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
 
virtual void OnDeop2 (const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
 Called when a nick is deopped on a channel. More...
 
virtual void OnDeop (const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
 
virtual void OnVoice2 (const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
 Called when a nick is voiced on a channel. More...
 
virtual void OnVoice (const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
 
virtual void OnDevoice2 (const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
 Called when a nick is devoiced on a channel. More...
 
virtual void OnDevoice (const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
 
virtual void OnMode2 (const CNick *pOpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
 Called on an individual channel mode change. More...
 
virtual void OnMode (const CNick &OpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
 
virtual void OnRawMode2 (const CNick *pOpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
 Called on any channel mode change. More...
 
virtual void OnRawMode (const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
 
virtual EModRet OnRaw (CString &sLine)
 Called on any raw IRC line received from the IRC server. More...
 
virtual EModRet OnRawMessage (CMessage &Message)
 Called on any raw message received from the IRC server. More...
 
virtual EModRet OnNumericMessage (CNumericMessage &Message)
 Called when a numeric message is received from the IRC server. More...
 
virtual EModRet OnStatusCommand (CString &sCommand)
 Called when a command to *status is sent. More...
 
virtual void OnModCommand (const CString &sCommand)
 Called when a command to your module is sent, e.g. More...
 
virtual void OnUnknownModCommand (const CString &sCommand)
 This is similar to OnModCommand(), but it is only called if HandleCommand didn't find any that wants to handle this. More...
 
virtual void OnModNotice (const CString &sMessage)
 Called when a your module nick was sent a notice. More...
 
virtual void OnModCTCP (const CString &sMessage)
 Called when your module nick was sent a CTCP message. More...
 
virtual void OnQuitMessage (CQuitMessage &Message, const std::vector< CChan * > &vChans)
 Called when a nick quit from IRC. More...
 
virtual void OnQuit (const CNick &Nick, const CString &sMessage, const std::vector< CChan * > &vChans)
 
virtual void OnNickMessage (CNickMessage &Message, const std::vector< CChan * > &vChans)
 Called when a nickname change occurs. More...
 
virtual void OnNick (const CNick &Nick, const CString &sNewNick, const std::vector< CChan * > &vChans)
 
virtual void OnKickMessage (CKickMessage &Message)
 Called when a nick is kicked from a channel. More...
 
virtual void OnKick (const CNick &OpNick, const CString &sKickedNick, CChan &Channel, const CString &sMessage)
 
virtual EModRet OnJoining (CChan &Channel)
 This module hook is called just before ZNC tries to join an IRC channel. More...
 
virtual void OnJoinMessage (CJoinMessage &Message)
 Called when a nick joins a channel. More...
 
virtual void OnJoin (const CNick &Nick, CChan &Channel)
 
virtual void OnPartMessage (CPartMessage &Message)
 Called when a nick parts a channel. More...
 
virtual void OnPart (const CNick &Nick, CChan &Channel, const CString &sMessage)
 
virtual EModRet OnInvite (const CNick &Nick, const CString &sChan)
 Called when user is invited into a channel. More...
 
virtual EModRet OnChanBufferStarting (CChan &Chan, CClient &Client)
 Called before a channel buffer is played back to a client. More...
 
virtual EModRet OnChanBufferEnding (CChan &Chan, CClient &Client)
 Called after a channel buffer was played back to a client. More...
 
virtual EModRet OnChanBufferPlayMessage (CMessage &Message)
 Called for each message during a channel's buffer play back. More...
 
virtual EModRet OnChanBufferPlayLine2 (CChan &Chan, CClient &Client, CString &sLine, const timeval &tv)
 
virtual EModRet OnChanBufferPlayLine (CChan &Chan, CClient &Client, CString &sLine)
 
virtual EModRet OnPrivBufferStarting (CQuery &Query, CClient &Client)
 Called before a query buffer is played back to a client. More...
 
virtual EModRet OnPrivBufferEnding (CQuery &Query, CClient &Client)
 Called after a query buffer was played back to a client. More...
 
virtual EModRet OnPrivBufferPlayMessage (CMessage &Message)
 Called for each message during a query's buffer play back. More...
 
virtual EModRet OnPrivBufferPlayLine2 (CClient &Client, CString &sLine, const timeval &tv)
 
virtual EModRet OnPrivBufferPlayLine (CClient &Client, CString &sLine)
 
virtual void OnClientLogin ()
 Called when a client successfully logged in to ZNC. More...
 
virtual void OnClientDisconnect ()
 Called when a client disconnected from ZNC. More...
 
virtual EModRet OnUserRaw (CString &sLine)
 This module hook is called when a client sends a raw traffic line to ZNC. More...
 
virtual EModRet OnUserRawMessage (CMessage &Message)
 This module hook is called when a client sends any message to ZNC. More...
 
virtual EModRet OnUserCTCPReplyMessage (CCTCPMessage &Message)
 This module hook is called when a client sends a CTCP reply. More...
 
virtual EModRet OnUserCTCPReply (CString &sTarget, CString &sMessage)
 
virtual EModRet OnUserCTCPMessage (CCTCPMessage &Message)
 This module hook is called when a client sends a CTCP request. More...
 
virtual EModRet OnUserCTCP (CString &sTarget, CString &sMessage)
 
virtual EModRet OnUserActionMessage (CActionMessage &Message)
 Called when a client sends a CTCP ACTION request ("/me"). More...
 
virtual EModRet OnUserAction (CString &sTarget, CString &sMessage)
 
virtual EModRet OnUserTextMessage (CTextMessage &Message)
 This module hook is called when a user sends a PRIVMSG message. More...
 
virtual EModRet OnUserMsg (CString &sTarget, CString &sMessage)
 
virtual EModRet OnUserNoticeMessage (CNoticeMessage &Message)
 This module hook is called when a user sends a NOTICE message. More...
 
virtual EModRet OnUserNotice (CString &sTarget, CString &sMessage)
 
virtual EModRet OnUserJoinMessage (CJoinMessage &Message)
 This hooks is called when a user sends a JOIN message. More...
 
virtual EModRet OnUserJoin (CString &sChannel, CString &sKey)
 
virtual EModRet OnUserPartMessage (CPartMessage &Message)
 This hooks is called when a user sends a PART message. More...
 
virtual EModRet OnUserPart (CString &sChannel, CString &sMessage)
 
virtual EModRet OnUserTopicMessage (CTopicMessage &Message)
 This module hook is called when a user wants to change a channel topic. More...
 
virtual EModRet OnUserTopic (CString &sChannel, CString &sTopic)
 
virtual EModRet OnUserTopicRequest (CString &sChannel)
 This hook is called when a user requests a channel's topic. More...
 
virtual EModRet OnUserQuitMessage (CQuitMessage &Message)
 This module hook is called when a client quits ZNC. More...
 
virtual EModRet OnUserQuit (CString &sMessage)
 
virtual EModRet OnCTCPReplyMessage (CCTCPMessage &Message)
 Called when we receive a CTCP reply from IRC. More...
 
virtual EModRet OnCTCPReply (CNick &Nick, CString &sMessage)
 
virtual EModRet OnPrivCTCPMessage (CCTCPMessage &Message)
 Called when we receive a private CTCP request from IRC. More...
 
virtual EModRet OnPrivCTCP (CNick &Nick, CString &sMessage)
 
virtual EModRet OnChanCTCPMessage (CCTCPMessage &Message)
 Called when we receive a channel CTCP request from IRC. More...
 
virtual EModRet OnChanCTCP (CNick &Nick, CChan &Channel, CString &sMessage)
 
virtual EModRet OnPrivActionMessage (CActionMessage &Message)
 Called when we receive a private CTCP ACTION ("/me" in query) from IRC. More...
 
virtual EModRet OnPrivAction (CNick &Nick, CString &sMessage)
 
virtual EModRet OnChanActionMessage (CActionMessage &Message)
 Called when we receive a channel CTCP ACTION ("/me" in a channel) from IRC. More...
 
virtual EModRet OnChanAction (CNick &Nick, CChan &Channel, CString &sMessage)
 
virtual EModRet OnPrivTextMessage (CTextMessage &Message)
 Called when we receive a private PRIVMSG message from IRC. More...
 
virtual EModRet OnPrivMsg (CNick &Nick, CString &sMessage)
 
virtual EModRet OnChanTextMessage (CTextMessage &Message)
 Called when we receive a channel PRIVMSG message from IRC. More...
 
virtual EModRet OnChanMsg (CNick &Nick, CChan &Channel, CString &sMessage)
 
virtual EModRet OnPrivNoticeMessage (CNoticeMessage &Message)
 Called when we receive a private NOTICE message from IRC. More...
 
virtual EModRet OnPrivNotice (CNick &Nick, CString &sMessage)
 
virtual EModRet OnChanNoticeMessage (CNoticeMessage &Message)
 Called when we receive a channel NOTICE message from IRC. More...
 
virtual EModRet OnChanNotice (CNick &Nick, CChan &Channel, CString &sMessage)
 
virtual EModRet OnTopicMessage (CTopicMessage &Message)
 Called when we receive a channel topic change from IRC. More...
 
virtual EModRet OnTopic (CNick &Nick, CChan &Channel, CString &sTopic)
 
virtual bool OnServerCapAvailable (const CString &sCap)
 Called for every CAP received via CAP LS from server. More...
 
virtual bool OnServerCap302Available (const CString &sCap, const CString &sValue)
 Called for every CAP received via CAP LS from server. More...
 
virtual void OnServerCapResult (const CString &sCap, bool bSuccess)
 Called for every CAP accepted or rejected by server (with CAP ACK or CAP NAK after our CAP REQ). More...
 
virtual EModRet OnTimerAutoJoin (CChan &Channel)
 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. More...
 
virtual EModRet OnAddNetwork (CIRCNetwork &Network, CString &sErrorRet)
 This module hook is called when a network is being added. More...
 
virtual EModRet OnDeleteNetwork (CIRCNetwork &Network)
 This module hook is called when a network is deleted. More...
 
virtual EModRet OnSendToClientMessage (CMessage &Message)
 Called immediately before ZNC sends a raw traffic line to a client. More...
 
virtual EModRet OnSendToClient (CString &sLine, CClient &Client)
 
virtual EModRet OnSendToIRCMessage (CMessage &Message)
 Called immediately before ZNC sends a raw traffic line to the IRC server. More...
 
virtual EModRet OnSendToIRC (CString &sLine)
 
ModHandle GetDLL ()
 
virtual bool PutIRC (const CString &sLine)
 This function sends a given IRC line to the IRC server, if we are connected to one. More...
 
virtual bool PutIRC (const CMessage &Message)
 This function sends a given IRC message to the IRC server, if we are connected to one. More...
 
virtual bool PutUser (const CString &sLine)
 This function sends a given raw IRC line to a client. More...
 
virtual bool PutStatus (const CString &sLine)
 This function generates a query from *status. More...
 
virtual bool PutModule (const CString &sLine)
 This function sends a query from your module nick. More...
 
virtual unsigned int PutModule (const CTable &table)
 This function calls CModule::PutModule(const CString&, const CString&, const CString&) for each line in the table. More...
 
virtual bool PutModNotice (const CString &sLine)
 Send a notice from your module nick. More...
 
const CStringGetModName () const
 
CString GetModNick () const
 
const CStringGetModDataDir () const
 Get the module's data dir. More...
 
bool AddTimer (CTimer *pTimer)
 
bool AddTimer (FPTimer_t pFBCallback, const CString &sLabel, u_int uInterval, u_int uCycles=0, const CString &sDescription="")
 
bool RemTimer (CTimer *pTimer)
 
bool RemTimer (const CString &sLabel)
 
bool UnlinkTimer (CTimer *pTimer)
 
CTimerFindTimer (const CString &sLabel)
 
std::set< CTimer * >::const_iterator BeginTimers () const
 
std::set< CTimer * >::const_iterator EndTimers () const
 
virtual void ListTimers ()
 
bool AddSocket (CSocket *pSocket)
 
bool RemSocket (CSocket *pSocket)
 
bool RemSocket (const CString &sSockName)
 
bool UnlinkSocket (CSocket *pSocket)
 
CSocketFindSocket (const CString &sSockName)
 
std::set< CSocket * >::const_iterator BeginSockets () const
 
std::set< CSocket * >::const_iterator EndSockets () const
 
virtual void ListSockets ()
 
void AddJob (CModuleJob *pJob)
 
void CancelJob (CModuleJob *pJob)
 
bool CancelJob (const CString &sJobName)
 
void CancelJobs (const std::set< CModuleJob * > &sJobs)
 
bool UnlinkJob (CModuleJob *pJob)
 
void AddHelpCommand ()
 Register the "Help" command. More...
 
bool AddCommand (const CModCommand &Command)
 
bool AddCommand (const CString &sCmd, CModCommand::ModCmdFunc func, const CString &sArgs="", const CString &sDesc="")
 
bool AddCommand (const CString &sCmd, const COptionalTranslation &Args, const COptionalTranslation &Desc, std::function< void(const CString &sLine)> func)
 
bool RemCommand (const CString &sCmd)
 
const CModCommandFindCommand (const CString &sCmd) const
 
bool HandleCommand (const CString &sLine)
 This function tries to dispatch the given command via the correct instance of CModCommand. More...
 
void HandleHelpCommand (const CString &sLine="")
 Send a description of all registered commands via PutModule(). More...
 
bool LoadRegistry ()
 
bool SaveRegistry () const
 
bool MoveRegistry (const CString &sPath)
 
bool SetNV (const CString &sName, const CString &sValue, bool bWriteToDisk=true)
 
CString GetNV (const CString &sName) const
 
bool HasNV (const CString &sName) const
 
bool DelNV (const CString &sName, bool bWriteToDisk=true)
 
MCString::iterator FindNV (const CString &sName)
 
MCString::iterator EndNV ()
 
MCString::iterator BeginNV ()
 
void DelNV (MCString::iterator it)
 
bool ClearNV (bool bWriteToDisk=true)
 
const CStringGetSavePath () const
 
CString ExpandString (const CString &sStr) const
 
CStringExpandString (const CString &sStr, CString &sRet) const
 
void SetType (CModInfo::EModuleType eType)
 
void SetDescription (const CString &s)
 
void SetModPath (const CString &s)
 
void SetArgs (const CString &s)
 
CModInfo::EModuleType GetType () const
 
const CStringGetDescription () const
 
const CStringGetArgs () const
 
const CStringGetModPath () const
 
CUserGetUser () const
 
CIRCNetworkGetNetwork () const
 
CClientGetClient () const
 
CSockManagerGetManager () const
 
virtual EModRet OnAddUser (CUser &User, CString &sErrorRet)
 This module hook is called when a user is being added. More...
 
virtual EModRet OnDeleteUser (CUser &User)
 This module hook is called when a user is deleted. More...
 
virtual void OnClientConnect (CZNCSock *pSock, const CString &sHost, unsigned short uPort)
 This module hook is called when there is an incoming connection on any of ZNC's listening sockets. More...
 
virtual EModRet OnLoginAttempt (std::shared_ptr< CAuthBase > Auth)
 This module hook is called when a client tries to login. More...
 
virtual void OnFailedLogin (const CString &sUsername, const CString &sRemoteIP)
 Called after a client login was rejected. More...
 
virtual EModRet OnUnknownUserRaw (CClient *pClient, CString &sLine)
 This function behaves like CModule::OnUserRaw(), but is also called before the client successfully logged in to ZNC. More...
 
virtual EModRet OnUnknownUserRawMessage (CMessage &Message)
 
virtual void OnClientAttached ()
 Called after login, and also during JumpNetwork. More...
 
virtual void OnClientDetached ()
 Called upon disconnect, and also during JumpNetwork. More...
 
void AddServerDependentCapability (const CString &sName, std::unique_ptr< CCapability > pCap)
 Simple API to support client capabilities which depend on server to support that capability. More...
 
virtual void OnClientCapLs (CClient *pClient, SCString &ssCaps)
 Called when a client told us CAP LS. More...
 
virtual bool IsClientCapSupported (CClient *pClient, const CString &sCap, bool bState)
 Called only to check if your module supports turning on/off named capability. More...
 
virtual void OnClientCapRequest (CClient *pClient, const CString &sCap, bool bState)
 Called when we actually need to turn a capability on or off for a client. More...
 
virtual EModRet OnModuleLoading (const CString &sModName, const CString &sArgs, CModInfo::EModuleType eType, bool &bSuccess, CString &sRetMsg)
 Called when a module is going to be loaded. More...
 
virtual EModRet OnModuleUnloading (CModule *pModule, bool &bSuccess, CString &sRetMsg)
 Called when a module is going to be unloaded. More...
 
virtual EModRet OnGetModInfo (CModInfo &ModInfo, const CString &sModule, bool &bSuccess, CString &sRetMsg)
 Called when info about a module is needed. More...
 
virtual void OnGetAvailableMods (std::set< CModInfo > &ssMods, CModInfo::EModuleType eType)
 Called when list of available mods is requested. More...
 
CString t_s (const CString &sEnglish, const CString &sContext="") const
 
CInlineFormatMessage t_f (const CString &sEnglish, const CString &sContext="") const
 
CInlineFormatMessage t_p (const CString &sEnglish, const CString &sEnglishes, int iNum, const CString &sContext="") const
 
CDelayedTranslation t_d (const CString &sEnglish, const CString &sContext="") const
 
bool InternalServerDependentCapsOnServerCap302Available (const CString &sCap, const CString &sValue)
 
void InternalServerDependentCapsOnServerCapResult (const CString &sCap, bool bSuccess)
 
void InternalServerDependentCapsOnClientCapLs (CClient *pClient, SCString &ssCaps)
 
bool InternalServerDependentCapsIsClientCapSupported (CClient *pClient, const CString &sCap, bool bState)
 
void InternalServerDependentCapsOnClientCapRequest (CClient *pClient, const CString &sCap, bool bState)
 
void InternalServerDependentCapsOnClientAttached ()
 
void InternalServerDependentCapsOnClientDetached ()
 
void InternalServerDependentCapsOnIRCConnected ()
 
void InternalServerDependentCapsOnIRCDisconnected ()
 

Protected Attributes

CModInfo::EModuleType m_eType
 
CString m_sDescription
 
std::set< CTimer * > m_sTimers
 
std::set< CSocket * > m_sSockets
 
std::set< CModuleJob * > m_sJobs
 
ModHandle m_pDLL
 
CSockManagerm_pManager
 
CUserm_pUser
 
CIRCNetworkm_pNetwork
 
CClientm_pClient
 
CString m_sModName
 
CString m_sDataDir
 
CString m_sSavePath
 
CString m_sArgs
 
CString m_sModPath
 
CTranslationDomainRefHolder m_Translation
 
std::map< CString, std::unique_ptr< CCapability > > m_mServerDependentCaps
 

Detailed Description

The base class for your own ZNC modules.

If you want to write a module for ZNC, you will have to implement a class which inherits from this class. You should override some of the "On*" functions in this class. These function will then be called by ZNC when the associated event happens.

If such a module hook is called with a non-const reference to e.g. a CString, then it is free to modify that argument to influence ZNC's behavior.

See also
MODCONSTRUCTOR and MODULEDEFS

Member Enumeration Documentation

◆ EModException

Enumerator
UNLOAD 

Your module can throw this enum at any given time.

When this is thrown, the module will be unloaded.

◆ EModRet

This enum is just used for return from module hooks.

Based on this return, ZNC then decides what to do with the event which caused the module hook.

Enumerator
CONTINUE 

ZNC will continue event processing normally.

This is what you should return normally.

HALT 

This is the same as both CModule::HALTMODS and CModule::HALTCORE together.

HALTMODS 

Stop sending this even to other modules which were not called yet.

Internally, the event is handled normally.

HALTCORE 

Continue calling other modules.

When done, ignore the event in the ZNC core. (For most module hooks this means that a given event won't be forwarded to the connected users)

Constructor & Destructor Documentation

◆ CModule() [1/2]

CModule::CModule ( ModHandle  pDLL,
CUser pUser,
CIRCNetwork pNetwork,
const CString sModName,
const CString sDataDir,
CModInfo::EModuleType  eType = CModInfo::NetworkModule 
)

◆ ~CModule()

virtual CModule::~CModule ( )
virtual

◆ CModule() [2/2]

CModule::CModule ( const CModule )
delete

Member Function Documentation

◆ AddCommand() [1/3]

bool CModule::AddCommand ( const CModCommand Command)
Returns
True if the command was successfully added.

◆ AddCommand() [2/3]

bool CModule::AddCommand ( const CString sCmd,
CModCommand::ModCmdFunc  func,
const CString sArgs = "",
const CString sDesc = "" 
)
Returns
True if the command was successfully added.
Deprecated:
Use the variant with COptionalTranslation.

◆ AddCommand() [3/3]

bool CModule::AddCommand ( const CString sCmd,
const COptionalTranslation Args,
const COptionalTranslation Desc,
std::function< void(const CString &sLine)>  func 
)
Parameters
dDescEither a string "", or the result of t_d()
Returns
True if the command was successfully added.

◆ AddHelpCommand()

void CModule::AddHelpCommand ( )

Register the "Help" command.

◆ AddJob()

void CModule::AddJob ( CModuleJob pJob)

◆ AddServerDependentCapability()

void CModule::AddServerDependentCapability ( const CString sName,
std::unique_ptr< CCapability pCap 
)

Simple API to support client capabilities which depend on server to support that capability.

It is built on top of other CAP related API, but removes boilerplate, and handles some tricky cases related to cap-notify and JumpNetwork. To use, create a subclass of CCapability, and pass to this function; it will automatically set the module pointer, then call the callbacks to notify you when server and client accepted support of the capability, or stopped supporting it. Note that it's not a strict toggle: e.g. sometimes client will disable the cap even when it was already disabled for that client. For perl and python modules, this function accepts 3 parameters: name, server callback, client callback; signatures of the callbacks are the same as of the virtual functions you'd implement in C++.

◆ AddSocket()

bool CModule::AddSocket ( CSocket pSocket)

◆ AddSubPage()

virtual void CModule::AddSubPage ( TWebSubPage  spSubPage)
inlinevirtual

Registers a sub page for the sidebar.

Parameters
spSubPageThe SubPage instance.

◆ AddTimer() [1/2]

bool CModule::AddTimer ( CTimer pTimer)

◆ AddTimer() [2/2]

bool CModule::AddTimer ( FPTimer_t  pFBCallback,
const CString sLabel,
u_int  uInterval,
u_int  uCycles = 0,
const CString sDescription = "" 
)

◆ BeginNV()

MCString::iterator CModule::BeginNV ( )
inline

◆ BeginSockets()

std::set<CSocket*>::const_iterator CModule::BeginSockets ( ) const
inline

◆ BeginTimers()

std::set<CTimer*>::const_iterator CModule::BeginTimers ( ) const
inline

◆ CancelJob() [1/2]

void CModule::CancelJob ( CModuleJob pJob)

◆ CancelJob() [2/2]

bool CModule::CancelJob ( const CString sJobName)

◆ CancelJobs()

void CModule::CancelJobs ( const std::set< CModuleJob * > &  sJobs)

◆ ClearNV()

bool CModule::ClearNV ( bool  bWriteToDisk = true)

◆ ClearSubPages()

virtual void CModule::ClearSubPages ( )
inlinevirtual

Removes all registered (AddSubPage'd) SubPages.

◆ DelNV() [1/2]

bool CModule::DelNV ( const CString sName,
bool  bWriteToDisk = true 
)

◆ DelNV() [2/2]

void CModule::DelNV ( MCString::iterator  it)
inline

◆ EndNV()

MCString::iterator CModule::EndNV ( )
inline

◆ EndSockets()

std::set<CSocket*>::const_iterator CModule::EndSockets ( ) const
inline

◆ EndTimers()

std::set<CTimer*>::const_iterator CModule::EndTimers ( ) const
inline

◆ ExpandString() [1/2]

CString CModule::ExpandString ( const CString sStr) const

◆ ExpandString() [2/2]

CString& CModule::ExpandString ( const CString sStr,
CString sRet 
) const

◆ FindCommand()

const CModCommand* CModule::FindCommand ( const CString sCmd) const
Returns
The CModCommand instance or nullptr if none was found.

◆ FindNV()

MCString::iterator CModule::FindNV ( const CString sName)
inline

◆ FindSocket()

CSocket* CModule::FindSocket ( const CString sSockName)

◆ FindTimer()

CTimer* CModule::FindTimer ( const CString sLabel)

◆ GetArgs()

const CString& CModule::GetArgs ( ) const
inline

References m_sDescription.

◆ GetClient()

CClient* CModule::GetClient ( ) const
inline
Returns
nullptr except when we are in a client-specific module hook in which case this is the client for which the hook is called.

◆ GetDescription()

const CString& CModule::GetDescription ( ) const
inline

References m_eType.

◆ GetDLL()

ModHandle CModule::GetDLL ( )
inline

References m_pDLL.

◆ GetManager()

CSockManager* CModule::GetManager ( ) const
inline

References m_pClient.

◆ GetModDataDir()

const CString& CModule::GetModDataDir ( ) const
inline

Get the module's data dir.

Modules can be accompanied by static data, e.g. skins for webadmin. These function will return the path to that data.

◆ GetModName()

const CString& CModule::GetModName ( ) const
inline
Returns
The name of the module.

◆ GetModNick()

CString CModule::GetModNick ( ) const
Returns
The nick of the module. This is just the module name prefixed by the status prefix.

◆ GetModPath()

const CString& CModule::GetModPath ( ) const
inline

References m_sArgs.

◆ GetNetwork()

CIRCNetwork* CModule::GetNetwork ( ) const
inline
Returns
nullptr except when we are in a network-specific module hook in which case this is the network for which the hook is called.

◆ GetNV()

CString CModule::GetNV ( const CString sName) const

◆ GetSavePath()

const CString& CModule::GetSavePath ( ) const

◆ GetSubPages()

virtual VWebSubPages& CModule::GetSubPages ( )
inlinevirtual

Returns a list of all registered SubPages.

Don't mess with it too much.

Returns
The List.

◆ GetType()

CModInfo::EModuleType CModule::GetType ( ) const
inline

◆ GetUser()

CUser* CModule::GetUser ( ) const
inline
Returns
For user modules this returns the user for which this module was loaded. For global modules this returns nullptr, except when we are in a user-specific module hook in which case this is the user pointer.

◆ GetWebFilesPath()

virtual CString CModule::GetWebFilesPath ( )
virtual

◆ GetWebMenuTitle()

virtual CString CModule::GetWebMenuTitle ( )
inlinevirtual

Return the title of the module's section in the web interface's side bar.

Returns
The Title.

◆ GetWebPath()

virtual CString CModule::GetWebPath ( )
virtual

◆ HandleCommand()

bool CModule::HandleCommand ( const CString sLine)

This function tries to dispatch the given command via the correct instance of CModCommand.

Before this can be called, commands have to be added via AddCommand(). If no matching commands are found then OnUnknownModCommand will be called.

Parameters
sLineThe command line to handle.
Returns
True if something was done, else false.

◆ HandleHelpCommand()

void CModule::HandleHelpCommand ( const CString sLine = "")

Send a description of all registered commands via PutModule().

Parameters
sLineThe help command that is being asked for.

◆ HasNV()

bool CModule::HasNV ( const CString sName) const
inline

◆ InternalServerDependentCapsIsClientCapSupported()

bool CModule::InternalServerDependentCapsIsClientCapSupported ( CClient pClient,
const CString sCap,
bool  bState 
)

◆ InternalServerDependentCapsOnClientAttached()

void CModule::InternalServerDependentCapsOnClientAttached ( )

◆ InternalServerDependentCapsOnClientCapLs()

void CModule::InternalServerDependentCapsOnClientCapLs ( CClient pClient,
SCString ssCaps 
)

◆ InternalServerDependentCapsOnClientCapRequest()

void CModule::InternalServerDependentCapsOnClientCapRequest ( CClient pClient,
const CString sCap,
bool  bState 
)

◆ InternalServerDependentCapsOnClientDetached()

void CModule::InternalServerDependentCapsOnClientDetached ( )

◆ InternalServerDependentCapsOnIRCConnected()

void CModule::InternalServerDependentCapsOnIRCConnected ( )

◆ InternalServerDependentCapsOnIRCDisconnected()

void CModule::InternalServerDependentCapsOnIRCDisconnected ( )

◆ InternalServerDependentCapsOnServerCap302Available()

bool CModule::InternalServerDependentCapsOnServerCap302Available ( const CString sCap,
const CString sValue 
)

◆ InternalServerDependentCapsOnServerCapResult()

void CModule::InternalServerDependentCapsOnServerCapResult ( const CString sCap,
bool  bSuccess 
)

◆ IsClientCapSupported()

virtual bool CModule::IsClientCapSupported ( CClient pClient,
const CString sCap,
bool  bState 
)
virtual

Called only to check if your module supports turning on/off named capability.

Parameters
pClientThe client which wants to enable/disable a capability.
sCapname of capability.
bStateOn or off, depending on which case is interesting for client.
Returns
true if your module supports this capability in the specified state.

◆ ListSockets()

virtual void CModule::ListSockets ( )
virtual

◆ ListTimers()

virtual void CModule::ListTimers ( )
virtual

◆ LoadRegistry()

bool CModule::LoadRegistry ( )

◆ MoveRegistry()

bool CModule::MoveRegistry ( const CString sPath)

◆ OnAddNetwork()

virtual EModRet CModule::OnAddNetwork ( CIRCNetwork Network,
CString sErrorRet 
)
virtual

This module hook is called when a network is being added.

Parameters
NetworkThe new IRC network.
sErrorRetA message that may be displayed to the user if the module stops adding the network.
Returns
See CModule::EModRet.

◆ OnAddUser()

virtual EModRet CModule::OnAddUser ( CUser User,
CString sErrorRet 
)
virtual

This module hook is called when a user is being added.

Parameters
UserThe user which will be added.
sErrorRetA message that may be displayed to the user if the module stops adding the user.
Returns
See CModule::EModRet.

◆ OnBoot()

virtual bool CModule::OnBoot ( )
virtual

This module hook is called during ZNC startup.

Only modules loaded from znc.conf get this call.

Returns
false to abort ZNC startup.

◆ OnBroadcast()

virtual EModRet CModule::OnBroadcast ( CString sMessage)
virtual

This module hook is called when a message is broadcasted to all users.

Parameters
sMessageThe message that is broadcasted.
Returns
see CModule::EModRet

◆ OnChanAction()

virtual EModRet CModule::OnChanAction ( CNick Nick,
CChan Channel,
CString sMessage 
)
virtual

◆ OnChanActionMessage()

virtual EModRet CModule::OnChanActionMessage ( CActionMessage Message)
virtual

Called when we receive a channel CTCP ACTION ("/me" in a channel) from IRC.

Since
1.7.0
Parameters
MessageThe action message
Returns
See CModule::EModRet.

◆ OnChanBufferEnding()

virtual EModRet CModule::OnChanBufferEnding ( CChan Chan,
CClient Client 
)
virtual

Called after a channel buffer was played back to a client.

Parameters
ChanThe channel which was played back.
ClientThe client the buffer was played back to.
Returns
See CModule::EModRet.

◆ OnChanBufferPlayLine()

virtual EModRet CModule::OnChanBufferPlayLine ( CChan Chan,
CClient Client,
CString sLine 
)
virtual

◆ OnChanBufferPlayLine2()

virtual EModRet CModule::OnChanBufferPlayLine2 ( CChan Chan,
CClient Client,
CString sLine,
const timeval &  tv 
)
virtual

◆ OnChanBufferPlayMessage()

virtual EModRet CModule::OnChanBufferPlayMessage ( CMessage Message)
virtual

Called for each message during a channel's buffer play back.

Since
1.7.0
Parameters
MessageThe playback message.
Returns
See CModule::EModRet.

◆ OnChanBufferStarting()

virtual EModRet CModule::OnChanBufferStarting ( CChan Chan,
CClient Client 
)
virtual

Called before a channel buffer is played back to a client.

Parameters
ChanThe channel which will be played back.
ClientThe client the buffer will be played back to.
Returns
See CModule::EModRet.

◆ OnChanCTCP()

virtual EModRet CModule::OnChanCTCP ( CNick Nick,
CChan Channel,
CString sMessage 
)
virtual

◆ OnChanCTCPMessage()

virtual EModRet CModule::OnChanCTCPMessage ( CCTCPMessage Message)
virtual

Called when we receive a channel CTCP request from IRC.

Since
1.7.0
Parameters
MessageThe CTCP request message.
Returns
See CModule::EModRet.

◆ OnChanMsg()

virtual EModRet CModule::OnChanMsg ( CNick Nick,
CChan Channel,
CString sMessage 
)
virtual

◆ OnChanNotice()

virtual EModRet CModule::OnChanNotice ( CNick Nick,
CChan Channel,
CString sMessage 
)
virtual

◆ OnChanNoticeMessage()

virtual EModRet CModule::OnChanNoticeMessage ( CNoticeMessage Message)
virtual

Called when we receive a channel NOTICE message from IRC.

Since
1.7.0
Parameters
MessageThe notice message.
Returns
See CModule::EModRet.

◆ OnChanPermission()

virtual void CModule::OnChanPermission ( const CNick OpNick,
const CNick Nick,
CChan Channel,
unsigned char  uMode,
bool  bAdded,
bool  bNoChange 
)
virtual
Deprecated:
. Use OnChanPermission3.

◆ OnChanPermission2()

virtual void CModule::OnChanPermission2 ( const CNick pOpNick,
const CNick Nick,
CChan Channel,
unsigned char  uMode,
bool  bAdded,
bool  bNoChange 
)
virtual
Deprecated:
. Use OnChanPermission3.

◆ OnChanPermission3()

virtual void CModule::OnChanPermission3 ( const CNick pOpNick,
const CNick Nick,
CChan Channel,
char  cMode,
bool  bAdded,
bool  bNoChange 
)
virtual

This module hook is called when a user mode on a channel changes.

Parameters
pOpNickThe nick who sent the mode change, or nullptr if set by server.
NickThe nick whose channel mode changes.
ChannelThe channel on which the user mode is changed.
cModeThe mode character that is changed, e.g. '@' for op.
bAddedTrue if the mode is added, else false.
bNoChangetrue if this mode change doesn't change anything because the nick already had this permission.
See also
CIRCSock::GetModeType() for converting uMode into a mode (e.g. 'o' for op).

◆ OnChanTextMessage()

virtual EModRet CModule::OnChanTextMessage ( CTextMessage Message)
virtual

Called when we receive a channel PRIVMSG message from IRC.

Since
1.7.0
Parameters
MessageThe channel message.
Returns
See CModule::EModRet.

◆ OnClientAttached()

virtual void CModule::OnClientAttached ( )
virtual

Called after login, and also during JumpNetwork.

◆ OnClientCapLs()

virtual void CModule::OnClientCapLs ( CClient pClient,
SCString ssCaps 
)
virtual

Called when a client told us CAP LS.

Use ssCaps.insert("cap-name") for announcing capabilities which your module supports. If you need to adverite the cap to clients only when it's also supported by the server, use AddServerDependentCapability() instead.

Parameters
pClientThe client which requested the list.
ssCapsset of caps which will be sent to client.

◆ OnClientCapRequest()

virtual void CModule::OnClientCapRequest ( CClient pClient,
const CString sCap,
bool  bState 
)
virtual

Called when we actually need to turn a capability on or off for a client.

If you need to adverite the cap to clients only when it's also supported by the server, use AddServerDependentCapability() instead. If implementing a custom capability, make sure to call pClient->SetTagSupport("tag-name", bState) for each tag that the capability provides.

Parameters
pClientThe client which requested the capability.
sCapname of wanted capability.
bStateOn or off, depending on which case client needs.
See also
CClient::SetTagSupport()

◆ OnClientConnect()

virtual void CModule::OnClientConnect ( CZNCSock pSock,
const CString sHost,
unsigned short  uPort 
)
virtual

This module hook is called when there is an incoming connection on any of ZNC's listening sockets.

Parameters
pSockThe incoming client socket.
sHostThe IP the client is connecting from.
uPortThe port the client is connecting from.

◆ OnClientDetached()

virtual void CModule::OnClientDetached ( )
virtual

Called upon disconnect, and also during JumpNetwork.

◆ OnClientDisconnect()

virtual void CModule::OnClientDisconnect ( )
virtual

Called when a client disconnected from ZNC.

◆ OnClientLogin()

virtual void CModule::OnClientLogin ( )
virtual

Called when a client successfully logged in to ZNC.

◆ OnCTCPReply()

virtual EModRet CModule::OnCTCPReply ( CNick Nick,
CString sMessage 
)
virtual

◆ OnCTCPReplyMessage()

virtual EModRet CModule::OnCTCPReplyMessage ( CCTCPMessage Message)
virtual

Called when we receive a CTCP reply from IRC.

Since
1.7.0
Parameters
MessageThe CTCP reply message.
Returns
See CModule::EModRet.

◆ OnDeleteNetwork()

virtual EModRet CModule::OnDeleteNetwork ( CIRCNetwork Network)
virtual

This module hook is called when a network is deleted.

Parameters
NetworkThe IRC network which is going to be deleted.
Returns
See CModule::EModRet.

◆ OnDeleteUser()

virtual EModRet CModule::OnDeleteUser ( CUser User)
virtual

This module hook is called when a user is deleted.

Parameters
UserThe user which will be deleted.
Returns
See CModule::EModRet.

◆ OnDeop()

virtual void CModule::OnDeop ( const CNick OpNick,
const CNick Nick,
CChan Channel,
bool  bNoChange 
)
virtual

◆ OnDeop2()

virtual void CModule::OnDeop2 ( const CNick pOpNick,
const CNick Nick,
CChan Channel,
bool  bNoChange 
)
virtual

Called when a nick is deopped on a channel.

◆ OnDevoice()

virtual void CModule::OnDevoice ( const CNick OpNick,
const CNick Nick,
CChan Channel,
bool  bNoChange 
)
virtual

◆ OnDevoice2()

virtual void CModule::OnDevoice2 ( const CNick pOpNick,
const CNick Nick,
CChan Channel,
bool  bNoChange 
)
virtual

Called when a nick is devoiced on a channel.

◆ OnEmbeddedWebRequest()

virtual bool CModule::OnEmbeddedWebRequest ( CWebSock WebSock,
const CString sPageName,
CTemplate Tmpl 
)
virtual

Using this hook, module can embed web stuff directly to different places.

This method is called whenever embededded modules I/O happens. Name of used .tmpl file (if any) is up to caller.

Parameters
WebSockSocket for web connection, don't do bad things with it.
sPageNameDescribes the place where web stuff is embedded to.
TmplTemplate. Depending on context, you can do various stuff with it.
Returns
If you don't need to embed web stuff to the specified place, just return false. Exact meaning of return value is up to caller, and depends on context.

◆ OnFailedLogin()

virtual void CModule::OnFailedLogin ( const CString sUsername,
const CString sRemoteIP 
)
virtual

Called after a client login was rejected.

Parameters
sUsernameThe username that tried to log in.
sRemoteIPThe IP address from which the client tried to login.

◆ OnGetAvailableMods()

virtual void CModule::OnGetAvailableMods ( std::set< CModInfo > &  ssMods,
CModInfo::EModuleType  eType 
)
virtual

Called when list of available mods is requested.

Parameters
ssModsput new modules here.
bGlobaltrue if global modules are needed.

◆ OnGetModInfo()

virtual EModRet CModule::OnGetModInfo ( CModInfo ModInfo,
const CString sModule,
bool &  bSuccess,
CString sRetMsg 
)
virtual

Called when info about a module is needed.

Parameters
[out]ModInfoput result here, if your module knows it.
sModulename of the module.
bSuccessthis module provided info about the module.
sRetMsgtext describing possible issues.
Returns
See CModule::EModRet.

◆ OnInvite()

virtual EModRet CModule::OnInvite ( const CNick Nick,
const CString sChan 
)
virtual

Called when user is invited into a channel.

Parameters
NickThe nick who invited you.
sChanThe channel the user got invited into
Returns
See CModule::EModRet.
Todo:
Add OnInviteMessage() hook

◆ OnIRCConnected()

virtual void CModule::OnIRCConnected ( )
virtual

This module hook is called after a successful login to IRC.

◆ OnIRCConnecting()

virtual EModRet CModule::OnIRCConnecting ( CIRCSock pIRCSock)
virtual

This module hook is called just before ZNC tries to establish a connection to an IRC server.

Parameters
pIRCSockThe socket that will be used for the connection.
Returns
See CModule::EModRet.

◆ OnIRCConnectionError()

virtual void CModule::OnIRCConnectionError ( CIRCSock pIRCSock)
virtual

This module hook is called when a CIRCSock fails to connect or a module returned HALTCORE from OnIRCConnecting.

Parameters
pIRCSockThe socket that failed to connect.

◆ OnIRCDisconnected()

virtual void CModule::OnIRCDisconnected ( )
virtual

This module hook is called when a user gets disconnected from IRC.

◆ OnIRCRegistration()

virtual EModRet CModule::OnIRCRegistration ( CString sPass,
CString sNick,
CString sIdent,
CString sRealName 
)
virtual

This module hook is called before loging in to the IRC server.

The low-level connection is established at this point, but SSL handshakes didn't necessarily finish yet.

Parameters
sPassThe server password that will be used.
sNickThe nick that will be used.
sIdentThe protocol identity that will be used. This is not the ident string that is transferred via e.g. oidentd!
sRealNameThe real name that will be used.
Returns
See CModule::EModRet.

◆ OnJoin()

virtual void CModule::OnJoin ( const CNick Nick,
CChan Channel 
)
virtual

◆ OnJoining()

virtual EModRet CModule::OnJoining ( CChan Channel)
virtual

This module hook is called just before ZNC tries to join an IRC channel.

Parameters
ChanThe channel which is about to get joined.
Returns
See CModule::EModRet.

◆ OnJoinMessage()

virtual void CModule::OnJoinMessage ( CJoinMessage Message)
virtual

Called when a nick joins a channel.

Since
1.7.0
Parameters
MessageThe join message.

◆ OnKick()

virtual void CModule::OnKick ( const CNick OpNick,
const CString sKickedNick,
CChan Channel,
const CString sMessage 
)
virtual

◆ OnKickMessage()

virtual void CModule::OnKickMessage ( CKickMessage Message)
virtual

Called when a nick is kicked from a channel.

Since
1.7.0
Parameters
MessageThe kick message.

◆ OnLoad()

virtual bool CModule::OnLoad ( const CString sArgsi,
CString sMessage 
)
virtual

This module hook is called when a module is loaded.

Parameters
sArgsiThe arguments for the modules.
sMessageA message that may be displayed to the user after loading the module. Useful for returning error messages.
Returns
true if the module loaded successfully, else false.

◆ OnLoginAttempt()

virtual EModRet CModule::OnLoginAttempt ( std::shared_ptr< CAuthBase Auth)
virtual

This module hook is called when a client tries to login.

If your module wants to handle the login attempt, it must return CModule::EModRet::HALT;

Parameters
AuthThe necessary authentication info for this login attempt.
Returns
See CModule::EModRet.

◆ OnModCommand()

virtual void CModule::OnModCommand ( const CString sCommand)
virtual

Called when a command to your module is sent, e.g.

query to *modname.

Parameters
sCommandThe command that was sent.

◆ OnModCTCP()

virtual void CModule::OnModCTCP ( const CString sMessage)
virtual

Called when your module nick was sent a CTCP message.

OnModCommand() won't be called for this message.

Parameters
sMessageThe message which was sent.

◆ OnMode()

virtual void CModule::OnMode ( const CNick OpNick,
CChan Channel,
char  uMode,
const CString sArg,
bool  bAdded,
bool  bNoChange 
)
virtual

◆ OnMode2()

virtual void CModule::OnMode2 ( const CNick pOpNick,
CChan Channel,
char  uMode,
const CString sArg,
bool  bAdded,
bool  bNoChange 
)
virtual

Called on an individual channel mode change.

Parameters
pOpNickThe nick who changes the channel mode, or nullptr if set by server.
ChannelThe channel whose mode is changed.
uModeThe mode character that is changed.
sArgThe argument to the mode character, if any.
bAddedTrue if this mode is added ("+"), else false.
bNoChangeTrue if this mode was already effective before.

◆ OnModNotice()

virtual void CModule::OnModNotice ( const CString sMessage)
virtual

Called when a your module nick was sent a notice.

Parameters
sMessageThe message which was sent.

◆ OnModuleLoading()

virtual EModRet CModule::OnModuleLoading ( const CString sModName,
const CString sArgs,
CModInfo::EModuleType  eType,
bool &  bSuccess,
CString sRetMsg 
)
virtual

Called when a module is going to be loaded.

Parameters
sModNamename of the module.
eTypewanted type of the module (user/global).
sArgsarguments of the module.
[out]bSuccessthe module was loaded successfully as result of this module hook?
[out]sRetMsgtext about loading of the module.
Returns
See CModule::EModRet.

◆ OnModuleUnloading()

virtual EModRet CModule::OnModuleUnloading ( CModule pModule,
bool &  bSuccess,
CString sRetMsg 
)
virtual

Called when a module is going to be unloaded.

Parameters
pModulethe module.
[out]bSuccessthe module was unloaded successfully as result of this module hook?
[out]sRetMsgtext about unloading of the module.
Returns
See CModule::EModRet.

◆ OnNick()

virtual void CModule::OnNick ( const CNick Nick,
const CString sNewNick,
const std::vector< CChan * > &  vChans 
)
virtual

◆ OnNickMessage()

virtual void CModule::OnNickMessage ( CNickMessage Message,
const std::vector< CChan * > &  vChans 
)
virtual

Called when a nickname change occurs.

Since
1.7.0
Parameters
MessageThe nick message.
vChansChannels which we and nick share.

◆ OnNumericMessage()

virtual EModRet CModule::OnNumericMessage ( CNumericMessage Message)
virtual

Called when a numeric message is received from the IRC server.

Since
1.7.0
Parameters
MessageThe received message.
Returns
See CModule::EModRet.

◆ OnOp()

virtual void CModule::OnOp ( const CNick OpNick,
const CNick Nick,
CChan Channel,
bool  bNoChange 
)
virtual

◆ OnOp2()

virtual void CModule::OnOp2 ( const CNick pOpNick,
const CNick Nick,
CChan Channel,
bool  bNoChange 
)
virtual

Called when a nick is opped on a channel.

◆ OnPart()

virtual void CModule::OnPart ( const CNick Nick,
CChan Channel,
const CString sMessage 
)
virtual

◆ OnPartMessage()

virtual void CModule::OnPartMessage ( CPartMessage Message)
virtual

Called when a nick parts a channel.

Since
1.7.0
Parameters
MessageThe part message.

◆ OnPostRehash()

virtual void CModule::OnPostRehash ( )
virtual

This module hook is called after a successful rehash.

◆ OnPreRehash()

virtual void CModule::OnPreRehash ( )
virtual

Called just before znc.conf is rehashed.

◆ OnPrivAction()

virtual EModRet CModule::OnPrivAction ( CNick Nick,
CString sMessage 
)
virtual

◆ OnPrivActionMessage()

virtual EModRet CModule::OnPrivActionMessage ( CActionMessage Message)
virtual

Called when we receive a private CTCP ACTION ("/me" in query) from IRC.

Since
1.7.0
Parameters
MessageThe action message
Returns
See CModule::EModRet.

◆ OnPrivBufferEnding()

virtual EModRet CModule::OnPrivBufferEnding ( CQuery Query,
CClient Client 
)
virtual

Called after a query buffer was played back to a client.

Since
1.7.0
Parameters
QueryThe query which was played back.
ClientThe client the buffer was played back to.
Returns
See CModule::EModRet.

◆ OnPrivBufferPlayLine()

virtual EModRet CModule::OnPrivBufferPlayLine ( CClient Client,
CString sLine 
)
virtual

◆ OnPrivBufferPlayLine2()

virtual EModRet CModule::OnPrivBufferPlayLine2 ( CClient Client,
CString sLine,
const timeval &  tv 
)
virtual

◆ OnPrivBufferPlayMessage()

virtual EModRet CModule::OnPrivBufferPlayMessage ( CMessage Message)
virtual

Called for each message during a query's buffer play back.

Since
1.7.0
Parameters
MessageThe playback message.
Returns
See CModule::EModRet.

◆ OnPrivBufferStarting()

virtual EModRet CModule::OnPrivBufferStarting ( CQuery Query,
CClient Client 
)
virtual

Called before a query buffer is played back to a client.

Since
1.7.0
Parameters
QueryThe query which will be played back.
ClientThe client the buffer will be played back to.
Returns
See CModule::EModRet.

◆ OnPrivCTCP()

virtual EModRet CModule::OnPrivCTCP ( CNick Nick,
CString sMessage 
)
virtual

◆ OnPrivCTCPMessage()

virtual EModRet CModule::OnPrivCTCPMessage ( CCTCPMessage Message)
virtual

Called when we receive a private CTCP request from IRC.

Since
1.7.0
Parameters
MessageThe CTCP request message.
Returns
See CModule::EModRet.

◆ OnPrivMsg()

virtual EModRet CModule::OnPrivMsg ( CNick Nick,
CString sMessage 
)
virtual

◆ OnPrivNotice()

virtual EModRet CModule::OnPrivNotice ( CNick Nick,
CString sMessage 
)
virtual

◆ OnPrivNoticeMessage()

virtual EModRet CModule::OnPrivNoticeMessage ( CNoticeMessage Message)
virtual

Called when we receive a private NOTICE message from IRC.

Since
1.7.0
Parameters
MessageThe notice message.
Returns
See CModule::EModRet.

◆ OnPrivTextMessage()

virtual EModRet CModule::OnPrivTextMessage ( CTextMessage Message)
virtual

Called when we receive a private PRIVMSG message from IRC.

Since
1.7.0
Parameters
MessageThe private message.
Returns
See CModule::EModRet.

◆ OnQuit()

virtual void CModule::OnQuit ( const CNick Nick,
const CString sMessage,
const std::vector< CChan * > &  vChans 
)
virtual

◆ OnQuitMessage()

virtual void CModule::OnQuitMessage ( CQuitMessage Message,
const std::vector< CChan * > &  vChans 
)
virtual

Called when a nick quit from IRC.

Since
1.7.0
Parameters
MessageThe quit message.
vChansList of channels which you and nick share.

◆ OnRaw()

virtual EModRet CModule::OnRaw ( CString sLine)
virtual

Called on any raw IRC line received from the IRC server.

Parameters
sLineThe line read from the server.
Note
The line does not include message tags. Use OnRawMessage() to access them.
Returns
See CModule::EModRet.

◆ OnRawMessage()

virtual EModRet CModule::OnRawMessage ( CMessage Message)
virtual

Called on any raw message received from the IRC server.

Since
1.7.0
Parameters
MessageThe received message.
Returns
See CModule::EModRet.

◆ OnRawMode()

virtual void CModule::OnRawMode ( const CNick OpNick,
CChan Channel,
const CString sModes,
const CString sArgs 
)
virtual

◆ OnRawMode2()

virtual void CModule::OnRawMode2 ( const CNick pOpNick,
CChan Channel,
const CString sModes,
const CString sArgs 
)
virtual

Called on any channel mode change.

This is called before the more detailed mode hooks like e.g. OnOp() and OnMode().

Parameters
pOpNickThe nick who changes the channel mode, or nullptr if set by server.
ChannelThe channel whose mode is changed.
sModesThe raw mode change, e.g. "+s-io".
sArgsAll arguments to the mode change from sModes.

◆ OnSendToClient()

virtual EModRet CModule::OnSendToClient ( CString sLine,
CClient Client 
)
virtual

◆ OnSendToClientMessage()

virtual EModRet CModule::OnSendToClientMessage ( CMessage Message)
virtual

Called immediately before ZNC sends a raw traffic line to a client.

Since
1.7.0
Parameters
MessageThe message being sent to the client.
Warning
Calling PutUser() from within this hook leads to infinite recursion.
Returns
See CModule::EModRet.

◆ OnSendToIRC()

virtual EModRet CModule::OnSendToIRC ( CString sLine)
virtual

◆ OnSendToIRCMessage()

virtual EModRet CModule::OnSendToIRCMessage ( CMessage Message)
virtual

Called immediately before ZNC sends a raw traffic line to the IRC server.

Since
1.7.0
Parameters
MessageThe message being sent to the IRC server.
Warning
Calling PutIRC() from within this hook leads to infinite recursion.
Returns
See CModule::EModRet.

◆ OnServerCap302Available()

virtual bool CModule::OnServerCap302Available ( const CString sCap,
const CString sValue 
)
virtual

Called for every CAP received via CAP LS from server.

By default just calls OnServerCapAvailable() without sValue, so overriding one of the two is enough. If you need to also advertise the cap to clients, use AddServerDependentCapability() instead.

Parameters
sCapcapability name supported by server.
sValuevalue.
Returns
true if your module supports this CAP and needs to turn it on with CAP REQ.

◆ OnServerCapAvailable()

virtual bool CModule::OnServerCapAvailable ( const CString sCap)
virtual

Called for every CAP received via CAP LS from server.

If you need to also advertise the cap to clients, use AddServerDependentCapability() instead.

Parameters
sCapcapability supported by server.
Returns
true if your module supports this CAP and needs to turn it on with CAP REQ.

◆ OnServerCapResult()

virtual void CModule::OnServerCapResult ( const CString sCap,
bool  bSuccess 
)
virtual

Called for every CAP accepted or rejected by server (with CAP ACK or CAP NAK after our CAP REQ).

If you need to also advertise the cap to clients, use AddServerDependentCapability() instead.

Parameters
sCapcapability accepted/rejected by server.
bSuccesstrue if capability was accepted, false if rejected.

◆ OnStatusCommand()

virtual EModRet CModule::OnStatusCommand ( CString sCommand)
virtual

Called when a command to *status is sent.

Parameters
sCommandThe command sent.
Returns
See CModule::EModRet.

◆ OnTimerAutoJoin()

virtual EModRet CModule::OnTimerAutoJoin ( CChan Channel)
virtual

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.

Parameters
ChannelThe channel which will be joined.
Returns
See CModule::EModRet.

◆ OnTopic()

virtual EModRet CModule::OnTopic ( CNick Nick,
CChan Channel,
CString sTopic 
)
virtual

◆ OnTopicMessage()

virtual EModRet CModule::OnTopicMessage ( CTopicMessage Message)
virtual

Called when we receive a channel topic change from IRC.

Since
1.7.0
Parameters
MessageThe topic message.
Returns
See CModule::EModRet.

◆ OnUnknownModCommand()

virtual void CModule::OnUnknownModCommand ( const CString sCommand)
virtual

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().

Parameters
sCommandThe command that was sent.

◆ OnUnknownUserRaw()

virtual EModRet CModule::OnUnknownUserRaw ( CClient pClient,
CString sLine 
)
virtual

This function behaves like CModule::OnUserRaw(), but is also called before the client successfully logged in to ZNC.

You should always prefer to use CModule::OnUserRaw() if possible.

Parameters
pClientThe client which send this line.
sLineThe raw traffic line which the client sent.

◆ OnUnknownUserRawMessage()

virtual EModRet CModule::OnUnknownUserRawMessage ( CMessage Message)
virtual

◆ OnUserAction()

virtual EModRet CModule::OnUserAction ( CString sTarget,
CString sMessage 
)
virtual

◆ OnUserActionMessage()

virtual EModRet CModule::OnUserActionMessage ( CActionMessage Message)
virtual

Called when a client sends a CTCP ACTION request ("/me").

Since
1.7.0
Parameters
MessageThe action message.
Returns
See CModule::EModRet.
Note
CModule::OnUserCTCPMessage() will not be called for this message.

◆ OnUserCTCP()

virtual EModRet CModule::OnUserCTCP ( CString sTarget,
CString sMessage 
)
virtual

◆ OnUserCTCPMessage()

virtual EModRet CModule::OnUserCTCPMessage ( CCTCPMessage Message)
virtual

This module hook is called when a client sends a CTCP request.

Since
1.7.0
Parameters
MessageThe CTCP request message.
Returns
See CModule::EModRet.
Note
This is not called for CTCP ACTION messages, use CModule::OnUserActionMessage() instead.

◆ OnUserCTCPReply()

virtual EModRet CModule::OnUserCTCPReply ( CString sTarget,
CString sMessage 
)
virtual

◆ OnUserCTCPReplyMessage()

virtual EModRet CModule::OnUserCTCPReplyMessage ( CCTCPMessage Message)
virtual

This module hook is called when a client sends a CTCP reply.

Since
1.7.0
Parameters
MessageThe CTCP reply message.
Returns
See CModule::EModRet.

◆ OnUserJoin()

virtual EModRet CModule::OnUserJoin ( CString sChannel,
CString sKey 
)
virtual

◆ OnUserJoinMessage()

virtual EModRet CModule::OnUserJoinMessage ( CJoinMessage Message)
virtual

This hooks is called when a user sends a JOIN message.

Since
1.7.0
Parameters
MessageThe join message.
Returns
See CModule::EModRet.

◆ OnUserMsg()

virtual EModRet CModule::OnUserMsg ( CString sTarget,
CString sMessage 
)
virtual

◆ OnUserNotice()

virtual EModRet CModule::OnUserNotice ( CString sTarget,
CString sMessage 
)
virtual

◆ OnUserNoticeMessage()

virtual EModRet CModule::OnUserNoticeMessage ( CNoticeMessage Message)
virtual

This module hook is called when a user sends a NOTICE message.

Since
1.7.0
Parameters
MessageThe message which was sent.
Returns
See CModule::EModRet.

◆ OnUserPart()

virtual EModRet CModule::OnUserPart ( CString sChannel,
CString sMessage 
)
virtual

◆ OnUserPartMessage()

virtual EModRet CModule::OnUserPartMessage ( CPartMessage Message)
virtual

This hooks is called when a user sends a PART message.

Since
1.7.0
Parameters
MessageThe part message.
Returns
See CModule::EModRet.

◆ OnUserQuit()

virtual EModRet CModule::OnUserQuit ( CString sMessage)
virtual

◆ OnUserQuitMessage()

virtual EModRet CModule::OnUserQuitMessage ( CQuitMessage Message)
virtual

This module hook is called when a client quits ZNC.

Since
1.7.0
Parameters
MessageThe quit message the client sent.
Returns
See CModule::EModRet.

◆ OnUserRaw()

virtual EModRet CModule::OnUserRaw ( CString sLine)
virtual

This module hook is called when a client sends a raw traffic line to ZNC.

Parameters
sLineThe raw traffic line sent.
Returns
See CModule::EModRet.

◆ OnUserRawMessage()

virtual EModRet CModule::OnUserRawMessage ( CMessage Message)
virtual

This module hook is called when a client sends any message to ZNC.

Since
1.7.0
Parameters
MessageThe message sent.
Returns
See CModule::EModRet.

◆ OnUserTextMessage()

virtual EModRet CModule::OnUserTextMessage ( CTextMessage Message)
virtual

This module hook is called when a user sends a PRIVMSG message.

Since
1.7.0
Parameters
MessageThe message which was sent.
Returns
See CModule::EModRet.

◆ OnUserTopic()

virtual EModRet CModule::OnUserTopic ( CString sChannel,
CString sTopic 
)
virtual

◆ OnUserTopicMessage()

virtual EModRet CModule::OnUserTopicMessage ( CTopicMessage Message)
virtual

This module hook is called when a user wants to change a channel topic.

Since
1.7.0
Parameters
MessageThe topic message.
Returns
See CModule::EModRet.

◆ OnUserTopicRequest()

virtual EModRet CModule::OnUserTopicRequest ( CString sChannel)
virtual

This hook is called when a user requests a channel's topic.

Parameters
sChannelThe channel for which the request is.
Returns
See CModule::EModRet.

◆ OnVoice()

virtual void CModule::OnVoice ( const CNick OpNick,
const CNick Nick,
CChan Channel,
bool  bNoChange 
)
virtual

◆ OnVoice2()

virtual void CModule::OnVoice2 ( const CNick pOpNick,
const CNick Nick,
CChan Channel,
bool  bNoChange 
)
virtual

Called when a nick is voiced on a channel.

◆ OnWebPreRequest()

virtual bool CModule::OnWebPreRequest ( CWebSock WebSock,
const CString sPageName 
)
virtual

For WebMods: Called before the list of registered SubPages will be checked.

Important: If you return true, you need to take care of calling WebSock.Close! This allows for stuff like returning non-templated data, long-polling and other fun.

Parameters
WebSockThe active request.
sPageNameThe name of the page that has been requested.
Returns
true if you handled the page request or false if the name is to be checked against the list of registered SubPages and their permission settings.

◆ OnWebRequest()

virtual bool CModule::OnWebRequest ( CWebSock WebSock,
const CString sPageName,
CTemplate Tmpl 
)
virtual

If OnWebPreRequest returned false, and the RequiresAdmin/IsAdmin check has been passed, this method will be called with the page name.

It will also be called for pages that have NOT been specifically registered with AddSubPage.

Parameters
WebSockThe active request.
sPageNameThe name of the page that has been requested.
TmplThe active template. You can add variables, loops and stuff to it.
Returns
You MUST return true if you want the template to be evaluated and sent to the browser. Return false if you called Redirect() or PrintErrorPage(). If you didn't, a 404 page will be sent.

◆ operator=()

CModule& CModule::operator= ( const CModule )
delete

References CONTINUE, HALT, and HALTMODS.

◆ PutIRC() [1/2]

virtual bool CModule::PutIRC ( const CMessage Message)
virtual

This function sends a given IRC message to the IRC server, if we are connected to one.

Else this message is discarded.

Parameters
MessageThe message which should be sent.
Returns
true if the message was queued for sending.

◆ PutIRC() [2/2]

virtual bool CModule::PutIRC ( const CString sLine)
virtual

This function sends a given IRC line to the IRC server, if we are connected to one.

Else this line is discarded.

Parameters
sLineThe line which should be sent.
Returns
true if the line was queued for sending.

◆ PutModNotice()

virtual bool CModule::PutModNotice ( const CString sLine)
virtual

Send a notice from your module nick.

If we are in a module hook for a specific client, only that client gets this notice, else all clients will receive it.

Parameters
sLineThe line which should be sent.
Returns
true if the line was sent to at least one client.

◆ PutModule() [1/2]

virtual bool CModule::PutModule ( const CString sLine)
virtual

This function sends a query from your module nick.

If we are in a module hook for a specific client, only that client gets this message, else all connected clients will receive it.

Parameters
sLineThe message which should be sent.
Returns
true if the line was sent to at least one client.

◆ PutModule() [2/2]

virtual unsigned int CModule::PutModule ( const CTable table)
virtual

This function calls CModule::PutModule(const CString&, const CString&, const CString&) for each line in the table.

Parameters
tableThe table which should be send.
Returns
The number of lines sent.

◆ PutStatus()

virtual bool CModule::PutStatus ( const CString sLine)
virtual

This function generates a query from *status.

If we are in a module hook for a specific client, only that client gets this message, else all connected clients will receive it.

Parameters
sLineThe message which should be sent from *status.
Returns
true if the line was sent to at least one client.

◆ PutUser()

virtual bool CModule::PutUser ( const CString sLine)
virtual

This function sends a given raw IRC line to a client.

If we are in a module hook which is called for a specific client, only that client will get the line, else all connected clients will receive this line.

Parameters
sLineThe line which should be sent.
Returns
true if the line was sent to at least one client.

◆ RemCommand()

bool CModule::RemCommand ( const CString sCmd)
Returns
True if the command was successfully removed.

◆ RemSocket() [1/2]

bool CModule::RemSocket ( const CString sSockName)

◆ RemSocket() [2/2]

bool CModule::RemSocket ( CSocket pSocket)

◆ RemTimer() [1/2]

bool CModule::RemTimer ( const CString sLabel)

◆ RemTimer() [2/2]

bool CModule::RemTimer ( CTimer pTimer)

◆ SaveRegistry()

bool CModule::SaveRegistry ( ) const

◆ SetArgs()

void CModule::SetArgs ( const CString s)
inline

References m_sModPath.

◆ SetClient()

void CModule::SetClient ( CClient pClient)

◆ SetDescription()

void CModule::SetDescription ( const CString s)
inline

References m_eType.

◆ SetModPath()

void CModule::SetModPath ( const CString s)
inline

References m_sDescription.

◆ SetNetwork()

void CModule::SetNetwork ( CIRCNetwork pNetwork)

◆ SetNV()

bool CModule::SetNV ( const CString sName,
const CString sValue,
bool  bWriteToDisk = true 
)

◆ SetType()

void CModule::SetType ( CModInfo::EModuleType  eType)
inline

◆ SetUser()

void CModule::SetUser ( CUser pUser)

◆ t_d()

CDelayedTranslation CModule::t_d ( const CString sEnglish,
const CString sContext = "" 
) const

◆ t_f()

CInlineFormatMessage CModule::t_f ( const CString sEnglish,
const CString sContext = "" 
) const

◆ t_p()

CInlineFormatMessage CModule::t_p ( const CString sEnglish,
const CString sEnglishes,
int  iNum,
const CString sContext = "" 
) const

◆ t_s()

CString CModule::t_s ( const CString sEnglish,
const CString sContext = "" 
) const

◆ UnlinkJob()

bool CModule::UnlinkJob ( CModuleJob pJob)

◆ UnlinkSocket()

bool CModule::UnlinkSocket ( CSocket pSocket)

◆ UnlinkTimer()

bool CModule::UnlinkTimer ( CTimer pTimer)

◆ Unload()

void CModule::Unload ( )
inline

This function throws CModule::UNLOAD which causes this module to be unloaded.

◆ ValidateWebRequestCSRFCheck()

virtual bool CModule::ValidateWebRequestCSRFCheck ( CWebSock WebSock,
const CString sPageName 
)
virtual

If ValidateWebRequestCSRFCheck returned false, a CSRF error will be printed.

Parameters
WebSockThe active request.
sPageNameThe name of the page that has been requested.
Returns
You MUST return true if the CSRF token is valid.

◆ WebRequiresAdmin()

virtual bool CModule::WebRequiresAdmin ( )
inlinevirtual

Return true if this module should only be usable for admins on the web.

Returns
false if normal users can use this module's web pages as well.

◆ WebRequiresLogin()

virtual bool CModule::WebRequiresLogin ( )
inlinevirtual

Modules which can only be used with an active user session have to return true here.

Returns
false for modules that can do stuff for non-logged in web users as well.

Member Data Documentation

◆ m_eType

CModInfo::EModuleType CModule::m_eType
protected

Referenced by GetDescription(), and SetDescription().

◆ m_mServerDependentCaps

std::map<CString, std::unique_ptr<CCapability> > CModule::m_mServerDependentCaps
protected

◆ m_pClient

CClient* CModule::m_pClient
protected

Referenced by GetManager().

◆ m_pDLL

ModHandle CModule::m_pDLL
protected

Referenced by GetDLL().

◆ m_pManager

CSockManager* CModule::m_pManager
protected

◆ m_pNetwork

CIRCNetwork* CModule::m_pNetwork
protected

◆ m_pUser

CUser* CModule::m_pUser
protected

◆ m_sArgs

CString CModule::m_sArgs
protected

Referenced by GetModPath().

◆ m_sDataDir

CString CModule::m_sDataDir
protected

◆ m_sDescription

CString CModule::m_sDescription
protected

Referenced by GetArgs(), and SetModPath().

◆ m_sJobs

std::set<CModuleJob*> CModule::m_sJobs
protected

◆ m_sModName

CString CModule::m_sModName
protected

◆ m_sModPath

CString CModule::m_sModPath
protected

Referenced by SetArgs().

◆ m_sSavePath

CString CModule::m_sSavePath
protected

◆ m_sSockets

std::set<CSocket*> CModule::m_sSockets
protected

◆ m_sTimers

std::set<CTimer*> CModule::m_sTimers
protected

◆ m_Translation

CTranslationDomainRefHolder CModule::m_Translation
protected

The documentation for this class was generated from the following file: