ZNC
trunk
|
The base class for your own ZNC modules. More...
#include <Modules.h>
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 | |
CModule & | operator= (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 VWebSubPages & | GetSubPages () |
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 CString & | GetModName () const |
CString | GetModNick () const |
const CString & | GetModDataDir () 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) |
CTimer * | FindTimer (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) |
CSocket * | FindSocket (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 CModCommand * | FindCommand (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 CString & | GetSavePath () const |
CString | ExpandString (const CString &sStr) const |
CString & | ExpandString (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 CString & | GetDescription () const |
const CString & | GetArgs () const |
const CString & | GetModPath () const |
CUser * | GetUser () const |
CIRCNetwork * | GetNetwork () const |
CClient * | GetClient () const |
CSockManager * | GetManager () 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 |
CSockManager * | m_pManager |
CUser * | m_pUser |
CIRCNetwork * | m_pNetwork |
CClient * | m_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 |
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.
enum CModule::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) |
CModule::CModule | ( | ModHandle | pDLL, |
CUser * | pUser, | ||
CIRCNetwork * | pNetwork, | ||
const CString & | sModName, | ||
const CString & | sDataDir, | ||
CModInfo::EModuleType | eType = CModInfo::NetworkModule |
||
) |
|
virtual |
|
delete |
bool CModule::AddCommand | ( | const CModCommand & | Command | ) |
bool CModule::AddCommand | ( | const CString & | sCmd, |
CModCommand::ModCmdFunc | func, | ||
const CString & | sArgs = "" , |
||
const CString & | sDesc = "" |
||
) |
bool CModule::AddCommand | ( | const CString & | sCmd, |
const COptionalTranslation & | Args, | ||
const COptionalTranslation & | Desc, | ||
std::function< void(const CString &sLine)> | func | ||
) |
dDesc | Either a string "", or the result of t_d() |
void CModule::AddHelpCommand | ( | ) |
Register the "Help" command.
void CModule::AddJob | ( | CModuleJob * | pJob | ) |
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++.
bool CModule::AddSocket | ( | CSocket * | pSocket | ) |
|
inlinevirtual |
Registers a sub page for the sidebar.
spSubPage | The SubPage instance. |
bool CModule::AddTimer | ( | CTimer * | pTimer | ) |
bool CModule::AddTimer | ( | FPTimer_t | pFBCallback, |
const CString & | sLabel, | ||
u_int | uInterval, | ||
u_int | uCycles = 0 , |
||
const CString & | sDescription = "" |
||
) |
|
inline |
|
inline |
|
inline |
void CModule::CancelJob | ( | CModuleJob * | pJob | ) |
bool CModule::CancelJob | ( | const CString & | sJobName | ) |
void CModule::CancelJobs | ( | const std::set< CModuleJob * > & | sJobs | ) |
bool CModule::ClearNV | ( | bool | bWriteToDisk = true | ) |
|
inlinevirtual |
Removes all registered (AddSubPage'd) SubPages.
bool CModule::DelNV | ( | const CString & | sName, |
bool | bWriteToDisk = true |
||
) |
|
inline |
|
inline |
|
inline |
|
inline |
const CModCommand* CModule::FindCommand | ( | const CString & | sCmd | ) | const |
|
inline |
|
inline |
References m_sDescription.
|
inline |
|
inline |
References m_pClient.
|
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.
|
inline |
CString CModule::GetModNick | ( | ) | const |
|
inline |
const CString& CModule::GetSavePath | ( | ) | const |
|
inlinevirtual |
Returns a list of all registered SubPages.
Don't mess with it too much.
|
inline |
|
inline |
|
virtual |
|
inlinevirtual |
Return the title of the module's section in the web interface's side bar.
|
virtual |
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.
sLine | The command line to handle. |
void CModule::HandleHelpCommand | ( | const CString & | sLine = "" | ) |
Send a description of all registered commands via PutModule().
sLine | The help command that is being asked for. |
|
inline |
bool CModule::InternalServerDependentCapsIsClientCapSupported | ( | CClient * | pClient, |
const CString & | sCap, | ||
bool | bState | ||
) |
void CModule::InternalServerDependentCapsOnClientAttached | ( | ) |
void CModule::InternalServerDependentCapsOnClientCapRequest | ( | CClient * | pClient, |
const CString & | sCap, | ||
bool | bState | ||
) |
void CModule::InternalServerDependentCapsOnClientDetached | ( | ) |
void CModule::InternalServerDependentCapsOnIRCConnected | ( | ) |
void CModule::InternalServerDependentCapsOnIRCDisconnected | ( | ) |
bool CModule::InternalServerDependentCapsOnServerCap302Available | ( | const CString & | sCap, |
const CString & | sValue | ||
) |
void CModule::InternalServerDependentCapsOnServerCapResult | ( | const CString & | sCap, |
bool | bSuccess | ||
) |
|
virtual |
Called only to check if your module supports turning on/off named capability.
pClient | The client which wants to enable/disable a capability. |
sCap | name of capability. |
bState | On or off, depending on which case is interesting for client. |
|
virtual |
|
virtual |
bool CModule::LoadRegistry | ( | ) |
bool CModule::MoveRegistry | ( | const CString & | sPath | ) |
|
virtual |
This module hook is called when a network is being added.
Network | The new IRC network. |
sErrorRet | A message that may be displayed to the user if the module stops adding the network. |
This module hook is called when a user is being added.
User | The user which will be added. |
sErrorRet | A message that may be displayed to the user if the module stops adding the user. |
|
virtual |
This module hook is called during ZNC startup.
Only modules loaded from znc.conf get this call.
This module hook is called when a message is broadcasted to all users.
sMessage | The message that is broadcasted. |
|
virtual |
Called when we receive a channel CTCP ACTION ("/me" in a channel) from IRC.
Message | The action message |
Called after a channel buffer was played back to a client.
Chan | The channel which was played back. |
Client | The client the buffer was played back to. |
|
virtual |
|
virtual |
Called for each message during a channel's buffer play back.
Message | The playback message. |
Called before a channel buffer is played back to a client.
Chan | The channel which will be played back. |
Client | The client the buffer will be played back to. |
|
virtual |
Called when we receive a channel CTCP request from IRC.
Message | The CTCP request message. |
|
virtual |
Called when we receive a channel NOTICE message from IRC.
Message | The notice message. |
|
virtual |
|
virtual |
|
virtual |
This module hook is called when a user mode on a channel changes.
pOpNick | The nick who sent the mode change, or nullptr if set by server. |
Nick | The nick whose channel mode changes. |
Channel | The channel on which the user mode is changed. |
cMode | The mode character that is changed, e.g. '@' for op. |
bAdded | True if the mode is added, else false. |
bNoChange | true if this mode change doesn't change anything because the nick already had this permission. |
|
virtual |
Called when we receive a channel PRIVMSG message from IRC.
Message | The channel message. |
|
virtual |
Called after login, and also during JumpNetwork.
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.
pClient | The client which requested the list. |
ssCaps | set of caps which will be sent to client. |
|
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.
pClient | The client which requested the capability. |
sCap | name of wanted capability. |
bState | On or off, depending on which case client needs. |
|
virtual |
This module hook is called when there is an incoming connection on any of ZNC's listening sockets.
pSock | The incoming client socket. |
sHost | The IP the client is connecting from. |
uPort | The port the client is connecting from. |
|
virtual |
Called upon disconnect, and also during JumpNetwork.
|
virtual |
Called when a client disconnected from ZNC.
|
virtual |
Called when a client successfully logged in to ZNC.
|
virtual |
Called when we receive a CTCP reply from IRC.
Message | The CTCP reply message. |
|
virtual |
This module hook is called when a network is deleted.
Network | The IRC network which is going to be deleted. |
This module hook is called when a user is deleted.
User | The user which will be deleted. |
|
virtual |
|
virtual |
Called when a nick is deopped on a channel.
|
virtual |
|
virtual |
Called when a nick is devoiced on a channel.
|
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.
WebSock | Socket for web connection, don't do bad things with it. |
sPageName | Describes the place where web stuff is embedded to. |
Tmpl | Template. Depending on context, you can do various stuff with it. |
|
virtual |
Called after a client login was rejected.
sUsername | The username that tried to log in. |
sRemoteIP | The IP address from which the client tried to login. |
|
virtual |
Called when list of available mods is requested.
ssMods | put new modules here. |
bGlobal | true if global modules are needed. |
|
virtual |
Called when info about a module is needed.
[out] | ModInfo | put result here, if your module knows it. |
sModule | name of the module. | |
bSuccess | this module provided info about the module. | |
sRetMsg | text describing possible issues. |
Called when user is invited into a channel.
Nick | The nick who invited you. |
sChan | The channel the user got invited into |
|
virtual |
This module hook is called after a successful login to IRC.
This module hook is called just before ZNC tries to establish a connection to an IRC server.
pIRCSock | The socket that will be used for the connection. |
|
virtual |
This module hook is called when a CIRCSock fails to connect or a module returned HALTCORE from OnIRCConnecting.
pIRCSock | The socket that failed to connect. |
|
virtual |
This module hook is called when a user gets disconnected from IRC.
|
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.
sPass | The server password that will be used. |
sNick | The nick that will be used. |
sIdent | The protocol identity that will be used. This is not the ident string that is transferred via e.g. oidentd! |
sRealName | The real name that will be used. |
This module hook is called just before ZNC tries to join an IRC channel.
Chan | The channel which is about to get joined. |
|
virtual |
Called when a nick joins a channel.
Message | The join message. |
|
virtual |
|
virtual |
Called when a nick is kicked from a channel.
Message | The kick message. |
This module hook is called when a module is loaded.
sArgsi | The arguments for the modules. |
sMessage | A message that may be displayed to the user after loading the module. Useful for returning error messages. |
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;
Auth | The necessary authentication info for this login attempt. |
|
virtual |
Called when a command to your module is sent, e.g.
query to *modname.
sCommand | The command that was sent. |
|
virtual |
Called when your module nick was sent a CTCP message.
OnModCommand() won't be called for this message.
sMessage | The message which was sent. |
|
virtual |
|
virtual |
Called on an individual channel mode change.
pOpNick | The nick who changes the channel mode, or nullptr if set by server. |
Channel | The channel whose mode is changed. |
uMode | The mode character that is changed. |
sArg | The argument to the mode character, if any. |
bAdded | True if this mode is added ("+"), else false. |
bNoChange | True if this mode was already effective before. |
|
virtual |
Called when a your module nick was sent a notice.
sMessage | The message which was sent. |
|
virtual |
Called when a module is going to be loaded.
sModName | name of the module. | |
eType | wanted type of the module (user/global). | |
sArgs | arguments of the module. | |
[out] | bSuccess | the module was loaded successfully as result of this module hook? |
[out] | sRetMsg | text about loading of the module. |
|
virtual |
Called when a module is going to be unloaded.
pModule | the module. | |
[out] | bSuccess | the module was unloaded successfully as result of this module hook? |
[out] | sRetMsg | text about unloading of the module. |
|
virtual |
|
virtual |
Called when a nickname change occurs.
Message | The nick message. |
vChans | Channels which we and nick share. |
|
virtual |
Called when a numeric message is received from the IRC server.
Message | The received message. |
|
virtual |
|
virtual |
Called when a nick is opped on a channel.
|
virtual |
|
virtual |
Called when a nick parts a channel.
Message | The part message. |
|
virtual |
This module hook is called after a successful rehash.
|
virtual |
Called just before znc.conf is rehashed.
|
virtual |
Called when we receive a private CTCP ACTION ("/me" in query) from IRC.
Message | The action message |
Called after a query buffer was played back to a client.
Query | The query which was played back. |
Client | The client the buffer was played back to. |
|
virtual |
Called for each message during a query's buffer play back.
Message | The playback message. |
Called before a query buffer is played back to a client.
Query | The query which will be played back. |
Client | The client the buffer will be played back to. |
|
virtual |
Called when we receive a private CTCP request from IRC.
Message | The CTCP request message. |
|
virtual |
Called when we receive a private NOTICE message from IRC.
Message | The notice message. |
|
virtual |
Called when we receive a private PRIVMSG message from IRC.
Message | The private message. |
|
virtual |
|
virtual |
Called when a nick quit from IRC.
Message | The quit message. |
vChans | List of channels which you and nick share. |
Called on any raw IRC line received from the IRC server.
sLine | The line read from the server. |
Called on any raw message received from the IRC server.
Message | The received message. |
|
virtual |
|
virtual |
Called on any channel mode change.
This is called before the more detailed mode hooks like e.g. OnOp() and OnMode().
pOpNick | The nick who changes the channel mode, or nullptr if set by server. |
Channel | The channel whose mode is changed. |
sModes | The raw mode change, e.g. "+s-io". |
sArgs | All arguments to the mode change from sModes. |
Called immediately before ZNC sends a raw traffic line to a client.
Message | The message being sent to the client. |
Called immediately before ZNC sends a raw traffic line to the IRC server.
Message | The message being sent to the IRC server. |
|
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.
sCap | capability name supported by server. |
sValue | value. |
|
virtual |
Called for every CAP received via CAP LS from server.
If you need to also advertise the cap to clients, use AddServerDependentCapability() instead.
sCap | capability supported by server. |
|
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.
sCap | capability accepted/rejected by server. |
bSuccess | true if capability was accepted, false if rejected. |
Called when a command to *status is sent.
sCommand | The command sent. |
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.
Channel | The channel which will be joined. |
|
virtual |
Called when we receive a channel topic change from IRC.
Message | The topic message. |
|
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().
sCommand | The command that was sent. |
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.
pClient | The client which send this line. |
sLine | The raw traffic line which the client sent. |
|
virtual |
Called when a client sends a CTCP ACTION request ("/me").
Message | The action message. |
|
virtual |
This module hook is called when a client sends a CTCP request.
Message | The CTCP request message. |
|
virtual |
This module hook is called when a client sends a CTCP reply.
Message | The CTCP reply message. |
|
virtual |
This hooks is called when a user sends a JOIN message.
Message | The join message. |
|
virtual |
This module hook is called when a user sends a NOTICE message.
Message | The message which was sent. |
|
virtual |
This hooks is called when a user sends a PART message.
Message | The part message. |
|
virtual |
This module hook is called when a client quits ZNC.
Message | The quit message the client sent. |
This module hook is called when a client sends a raw traffic line to ZNC.
sLine | The raw traffic line sent. |
This module hook is called when a client sends any message to ZNC.
Message | The message sent. |
|
virtual |
This module hook is called when a user sends a PRIVMSG message.
Message | The message which was sent. |
|
virtual |
This module hook is called when a user wants to change a channel topic.
Message | The topic message. |
This hook is called when a user requests a channel's topic.
sChannel | The channel for which the request is. |
|
virtual |
|
virtual |
Called when a nick is voiced on a channel.
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.
WebSock | The active request. |
sPageName | The name of the page that has been requested. |
|
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.
WebSock | The active request. |
sPageName | The name of the page that has been requested. |
Tmpl | The active template. You can add variables, loops and stuff to it. |
|
virtual |
This function sends a given IRC message to the IRC server, if we are connected to one.
Else this message is discarded.
Message | The message which should be sent. |
|
virtual |
This function sends a given IRC line to the IRC server, if we are connected to one.
Else this line is discarded.
sLine | The line which should be sent. |
|
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.
sLine | The line which should be sent. |
|
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.
sLine | The message which should be sent. |
|
virtual |
This function calls CModule::PutModule(const CString&, const CString&, const CString&) for each line in the table.
table | The table which should be send. |
|
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.
sLine | The message which should be sent from *status. |
|
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.
sLine | The line which should be sent. |
bool CModule::RemCommand | ( | const CString & | sCmd | ) |
bool CModule::RemSocket | ( | const CString & | sSockName | ) |
bool CModule::RemSocket | ( | CSocket * | pSocket | ) |
bool CModule::RemTimer | ( | const CString & | sLabel | ) |
bool CModule::RemTimer | ( | CTimer * | pTimer | ) |
bool CModule::SaveRegistry | ( | ) | const |
|
inline |
References m_sModPath.
void CModule::SetClient | ( | CClient * | pClient | ) |
|
inline |
References m_sDescription.
void CModule::SetNetwork | ( | CIRCNetwork * | pNetwork | ) |
|
inline |
void CModule::SetUser | ( | CUser * | pUser | ) |
CDelayedTranslation CModule::t_d | ( | const CString & | sEnglish, |
const CString & | sContext = "" |
||
) | const |
CInlineFormatMessage CModule::t_f | ( | const CString & | sEnglish, |
const CString & | sContext = "" |
||
) | const |
CInlineFormatMessage CModule::t_p | ( | const CString & | sEnglish, |
const CString & | sEnglishes, | ||
int | iNum, | ||
const CString & | sContext = "" |
||
) | const |
bool CModule::UnlinkJob | ( | CModuleJob * | pJob | ) |
bool CModule::UnlinkSocket | ( | CSocket * | pSocket | ) |
bool CModule::UnlinkTimer | ( | CTimer * | pTimer | ) |
|
inline |
This function throws CModule::UNLOAD which causes this module to be unloaded.
|
virtual |
If ValidateWebRequestCSRFCheck returned false, a CSRF error will be printed.
WebSock | The active request. |
sPageName | The name of the page that has been requested. |
|
inlinevirtual |
Return true if this module should only be usable for admins on the web.
|
inlinevirtual |
Modules which can only be used with an active user session have to return true here.
|
protected |
Referenced by GetDescription(), and SetDescription().
|
protected |
|
protected |
Referenced by GetManager().
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by GetModPath().
|
protected |
|
protected |
Referenced by GetArgs(), and SetModPath().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |