ZNC  trunk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Modules.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2014 ZNC, see the NOTICE file for details.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _MODULES_H
18 #define _MODULES_H
19 
20 #include <znc/zncconfig.h>
21 #include <znc/WebModules.h>
22 #include <znc/main.h>
23 #include <set>
24 #include <queue>
25 
26 // Forward Declarations
27 class CAuthBase;
28 class CChan;
29 class CIRCNetwork;
30 class CClient;
31 class CWebSock;
32 class CTemplate;
33 class CIRCSock;
34 class CModule;
35 class CModInfo;
36 // !Forward Declarations
37 
38 #ifdef REQUIRESSL
39 #ifndef HAVE_LIBSSL
40 #error -
41 #error -
42 #error This module only works when ZNC is compiled with OpenSSL support
43 #error -
44 #error -
45 #endif
46 #endif
47 
48 typedef void* ModHandle;
49 
50 template<class M> void TModInfo(CModInfo& Info) {}
51 
52 template<class M> CModule* TModLoad(ModHandle p, CUser* pUser,
53  CIRCNetwork* pNetwork, const CString& sModName,
54  const CString& sModPath) {
55  return new M(p, pUser, pNetwork, sModName, sModPath);
56 }
57 
58 #if HAVE_VISIBILITY
59 # define MODULE_EXPORT __attribute__((__visibility__("default")))
60 #else
61 # define MODULE_EXPORT
62 #endif
63 
64 #define MODCOMMONDEFS(CLASS, DESCRIPTION, TYPE) \
65  extern "C" { \
66  MODULE_EXPORT bool ZNCModInfo(double dCoreVersion, CModInfo& Info); \
67  bool ZNCModInfo(double dCoreVersion, CModInfo& Info) { \
68  if (dCoreVersion != VERSION) \
69  return false; \
70  Info.SetDescription(DESCRIPTION); \
71  Info.SetDefaultType(TYPE); \
72  Info.AddType(TYPE); \
73  Info.SetLoader(TModLoad<CLASS>); \
74  TModInfo<CLASS>(Info); \
75  return true; \
76  } \
77  }
78 
94 #define MODCONSTRUCTOR(CLASS) \
95  CLASS(ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, \
96  const CString& sModPath) \
97  : CModule(pDLL, pUser, pNetwork, sModName, sModPath)
98 
99 // User Module Macros
101 #define USERMODULEDEFS(CLASS, DESCRIPTION) \
102  MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::UserModule)
103 // !User Module Macros
104 
105 // Global Module Macros
107 #define GLOBALMODULEDEFS(CLASS, DESCRIPTION) \
108  MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::GlobalModule)
109 // !Global Module Macros
110 
111 // Network Module Macros
113 #define NETWORKMODULEDEFS(CLASS, DESCRIPTION) \
114  MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::NetworkModule)
115 // !Network Module Macros
116 
123 #define MODULEDEFS(CLASS, DESCRIPTION) NETWORKMODULEDEFS(CLASS, DESCRIPTION)
124 
125 // Forward Declarations
126 class CZNC;
127 class CUser;
128 class CNick;
129 class CChan;
130 class CModule;
131 class CFPTimer;
132 class CSockManager;
133 // !Forward Declarations
134 
135 class CTimer : public CCron {
136 public:
137  CTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription);
138 
139  virtual ~CTimer();
140 
141  // Setters
142  void SetModule(CModule* p);
143  void SetDescription(const CString& s);
144  // !Setters
145 
146  // Getters
147  CModule* GetModule() const;
148  const CString& GetDescription() const;
149  // !Getters
150 private:
151 protected:
154 };
155 
156 typedef void (*FPTimer_t)(CModule *, CFPTimer *);
157 
158 class CFPTimer : public CTimer {
159 public:
160  CFPTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription)
161  : CTimer(pModule, uInterval, uCycles, sLabel, sDescription) {
162  m_pFBCallback = NULL;
163  }
164 
165  virtual ~CFPTimer() {}
166 
167  void SetFPCallback(FPTimer_t p) { m_pFBCallback = p; }
168 
169 protected:
170  virtual void RunJob() {
171  if (m_pFBCallback) {
172  m_pFBCallback(m_pModule, this);
173  }
174  }
175 
176 private:
177  FPTimer_t m_pFBCallback;
178 };
179 
180 class CModInfo {
181 public:
182  typedef CModule* (*ModLoader)(ModHandle p, CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, const CString& sModPath);
183 
184  typedef enum {
188  } EModuleType;
189 
191  m_fLoader = NULL;
192  m_bHasArgs = false;
193  }
194  CModInfo(const CString& sName, const CString& sPath, EModuleType eType) {
195  m_sName = sName;
196  m_sPath = sPath;
197  m_fLoader = NULL;
198  m_bHasArgs = false;
199  }
201 
202  bool operator < (const CModInfo& Info) const {
203  return (GetName() < Info.GetName());
204  }
205 
206  bool SupportsType(EModuleType eType) {
207  return m_seType.find(eType) != m_seType.end();
208  }
209 
210  void AddType(EModuleType eType) {
211  m_seType.insert(eType);
212  }
213 
215  switch (eType) {
216  case GlobalModule: return "Global";
217  case UserModule: return "User";
218  case NetworkModule: return "Network";
219  default: return "UNKNOWN";
220  }
221  }
222 
223  // Getters
224  const CString& GetName() const { return m_sName; }
225  const CString& GetPath() const { return m_sPath; }
226  const CString& GetDescription() const { return m_sDescription; }
227  const CString& GetWikiPage() const { return m_sWikiPage; }
228  const CString& GetArgsHelpText() const { return m_sArgsHelpText; }
229  bool GetHasArgs() const { return m_bHasArgs; }
230  ModLoader GetLoader() const { return m_fLoader; }
232  // !Getters
233 
234  // Setters
235  void SetName(const CString& s) { m_sName = s; }
236  void SetPath(const CString& s) { m_sPath = s; }
237  void SetDescription(const CString& s) { m_sDescription = s; }
238  void SetWikiPage(const CString& s) { m_sWikiPage = s; }
239  void SetArgsHelpText(const CString& s) { m_sArgsHelpText = s; }
240  void SetHasArgs(bool b = false) { m_bHasArgs = b; }
241  void SetLoader(ModLoader fLoader) { m_fLoader = fLoader; }
242  void SetDefaultType(EModuleType eType) { m_eDefaultType = eType; }
243  // !Setters
244 private:
245 protected:
246  std::set<EModuleType> m_seType;
255 };
256 
258 class CModCommand {
259 public:
261  typedef void (CModule::*ModCmdFunc)(const CString& sLine);
262 
264  CModCommand();
265 
272  CModCommand(const CString& sCmd, ModCmdFunc func, const CString& sArgs, const CString& sDesc);
273 
277  CModCommand(const CModCommand& other);
278 
282  CModCommand& operator=(const CModCommand& other);
283 
287  static void InitHelp(CTable& Table);
288 
293  void AddHelp(CTable& Table) const;
294 
295  const CString& GetCommand() const { return m_sCmd; }
296  ModCmdFunc GetFunction() const { return m_pFunc; }
297  const CString& GetArgs() const { return m_sArgs; }
298  const CString& GetDescription() const { return m_sDesc; }
299 
300  void Call(CModule *pMod, const CString& sLine) const { (pMod->*m_pFunc)(sLine); }
301 
302 private:
303  CString m_sCmd;
304  ModCmdFunc m_pFunc;
305  CString m_sArgs;
306  CString m_sDesc;
307 };
308 
322 class CModule {
323 public:
324  CModule(ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName,
325  const CString& sDataDir);
326  virtual ~CModule();
327 
332  typedef enum {
336  CONTINUE = 1,
340  HALT = 2,
344  HALTMODS = 3,
350  } EModRet;
351 
352  typedef enum {
357  } EModException;
358 
359  void SetUser(CUser* pUser);
360  void SetNetwork(CIRCNetwork* pNetwork);
361  void SetClient(CClient* pClient);
362 
365  void Unload() { throw UNLOAD; }
366 
373  virtual bool OnLoad(const CString& sArgsi, CString& sMessage);
378  virtual bool OnBoot();
379 
380 
384  virtual bool WebRequiresLogin() { return true; }
388  virtual bool WebRequiresAdmin() { return false; }
392  virtual CString GetWebMenuTitle() { return ""; }
393  virtual CString GetWebPath();
394  virtual CString GetWebFilesPath();
403  virtual bool OnWebPreRequest(CWebSock& WebSock, const CString& sPageName);
413  virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl);
417  virtual void AddSubPage(TWebSubPage spSubPage) { m_vSubPages.push_back(spSubPage); }
420  virtual void ClearSubPages() { m_vSubPages.clear(); }
424  virtual VWebSubPages& GetSubPages() { return m_vSubPages; }
434  virtual bool OnEmbeddedWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl);
435 
436 
438  virtual void OnPreRehash();
440  virtual void OnPostRehash();
442  virtual void OnIRCDisconnected();
444  virtual void OnIRCConnected();
450  virtual EModRet OnIRCConnecting(CIRCSock *pIRCSock);
455  virtual void OnIRCConnectionError(CIRCSock *pIRCSock);
466  virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName);
471  virtual EModRet OnBroadcast(CString& sMessage);
472 
484  virtual void OnChanPermission2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange);
485  virtual void OnChanPermission(const CNick& OpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange);
487  virtual void OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
488  virtual void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
490  virtual void OnDeop2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
491  virtual void OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
493  virtual void OnVoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
494  virtual void OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
496  virtual void OnDevoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
497  virtual void OnDevoice(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
506  virtual void OnMode2(const CNick* pOpNick, CChan& Channel, char uMode, const CString& sArg, bool bAdded, bool bNoChange);
507  virtual void OnMode(const CNick& OpNick, CChan& Channel, char uMode, const CString& sArg, bool bAdded, bool bNoChange);
515  virtual void OnRawMode2(const CNick* pOpNick, CChan& Channel, const CString& sModes, const CString& sArgs);
516  virtual void OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes, const CString& sArgs);
517 
522  virtual EModRet OnRaw(CString& sLine);
523 
528  virtual EModRet OnStatusCommand(CString& sCommand);
532  virtual void OnModCommand(const CString& sCommand);
539  virtual void OnUnknownModCommand(const CString& sCommand);
543  virtual void OnModNotice(const CString& sMessage);
548  virtual void OnModCTCP(const CString& sMessage);
549 
555  virtual void OnQuit(const CNick& Nick, const CString& sMessage, const std::vector<CChan*>& vChans);
562  virtual void OnNick(const CNick& Nick, const CString& sNewNick, const std::vector<CChan*>& vChans);
569  virtual void OnKick(const CNick& OpNick, const CString& sKickedNick, CChan& Channel, const CString& sMessage);
574  virtual void OnJoin(const CNick& Nick, CChan& Channel);
580  virtual void OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage);
586  virtual EModRet OnInvite(const CNick& Nick, const CString& sChan);
587 
593  virtual EModRet OnChanBufferStarting(CChan& Chan, CClient& Client);
599  virtual EModRet OnChanBufferEnding(CChan& Chan, CClient& Client);
607  virtual EModRet OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
613  virtual EModRet OnPrivBufferPlayLine(CClient& Client, CString& sLine);
614 
616  virtual void OnClientLogin();
618  virtual void OnClientDisconnect();
623  virtual EModRet OnUserRaw(CString& sLine);
630  virtual EModRet OnUserCTCPReply(CString& sTarget, CString& sMessage);
639  virtual EModRet OnUserCTCP(CString& sTarget, CString& sMessage);
647  virtual EModRet OnUserAction(CString& sTarget, CString& sMessage);
654  virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage);
661  virtual EModRet OnUserNotice(CString& sTarget, CString& sMessage);
667  virtual EModRet OnUserJoin(CString& sChannel, CString& sKey);
673  virtual EModRet OnUserPart(CString& sChannel, CString& sMessage);
679  virtual EModRet OnUserTopic(CString& sChannel, CString& sTopic);
684  virtual EModRet OnUserTopicRequest(CString& sChannel);
685 
691  virtual EModRet OnCTCPReply(CNick& Nick, CString& sMessage);
697  virtual EModRet OnPrivCTCP(CNick& Nick, CString& sMessage);
704  virtual EModRet OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
711  virtual EModRet OnPrivAction(CNick& Nick, CString& sMessage);
719  virtual EModRet OnChanAction(CNick& Nick, CChan& Channel, CString& sMessage);
725  virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage);
732  virtual EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
738  virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage);
745  virtual EModRet OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage);
752  virtual EModRet OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
753 
759  virtual bool OnServerCapAvailable(const CString& sCap);
765  virtual void OnServerCapResult(const CString& sCap, bool bSuccess);
766 
772  virtual EModRet OnTimerAutoJoin(CChan& Channel);
773 
780  virtual EModRet OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
785  virtual EModRet OnDeleteNetwork(CIRCNetwork& Network);
786 
793  virtual EModRet OnSendToClient(CString& sLine, CClient& Client);
799  virtual EModRet OnSendToIRC(CString& sLine);
800 
801  ModHandle GetDLL() { return m_pDLL; }
802  static double GetCoreVersion() { return VERSION; }
803 
809  virtual bool PutIRC(const CString& sLine);
817  virtual bool PutUser(const CString& sLine);
824  virtual bool PutStatus(const CString& sLine);
831  virtual bool PutModule(const CString& sLine);
837  virtual unsigned int PutModule(const CTable& table);
844  virtual bool PutModNotice(const CString& sLine);
845 
847  const CString& GetModName() const { return m_sModName; }
848 
852  CString GetModNick() const;
853 
858  const CString& GetModDataDir() const { return m_sDataDir; }
859 
860  // Timer stuff
861  bool AddTimer(CTimer* pTimer);
862  bool AddTimer(FPTimer_t pFBCallback, const CString& sLabel, u_int uInterval, u_int uCycles = 0, const CString& sDescription = "");
863  bool RemTimer(CTimer* pTimer);
864  bool RemTimer(const CString& sLabel);
865  bool UnlinkTimer(CTimer* pTimer);
866  CTimer* FindTimer(const CString& sLabel);
867  std::set<CTimer*>::const_iterator BeginTimers() const { return m_sTimers.begin(); }
868  std::set<CTimer*>::const_iterator EndTimers() const { return m_sTimers.end(); }
869  virtual void ListTimers();
870  // !Timer stuff
871 
872  // Socket stuff
873  bool AddSocket(CSocket* pSocket);
874  bool RemSocket(CSocket* pSocket);
875  bool RemSocket(const CString& sSockName);
876  bool UnlinkSocket(CSocket* pSocket);
877  CSocket* FindSocket(const CString& sSockName);
878  std::set<CSocket*>::const_iterator BeginSockets() const { return m_sSockets.begin(); }
879  std::set<CSocket*>::const_iterator EndSockets() const { return m_sSockets.end(); }
880  virtual void ListSockets();
881  // !Socket stuff
882 
883  // Command stuff
885  void AddHelpCommand();
887  bool AddCommand(const CModCommand& Command);
889  bool AddCommand(const CString& sCmd, CModCommand::ModCmdFunc func, const CString& sArgs = "", const CString& sDesc = "");
891  bool RemCommand(const CString& sCmd);
893  const CModCommand* FindCommand(const CString& sCmd) const;
901  bool HandleCommand(const CString& sLine);
905  void HandleHelpCommand(const CString& sLine = "");
906  // !Command stuff
907 
908  bool LoadRegistry();
909  bool SaveRegistry() const;
910  bool SetNV(const CString & sName, const CString & sValue, bool bWriteToDisk = true);
911  CString GetNV(const CString & sName) const;
912  bool DelNV(const CString & sName, bool bWriteToDisk = true);
913  MCString::iterator FindNV(const CString & sName) { return m_mssRegistry.find(sName); }
914  MCString::iterator EndNV() { return m_mssRegistry.end(); }
915  MCString::iterator BeginNV() { return m_mssRegistry.begin(); }
916  void DelNV(MCString::iterator it) { m_mssRegistry.erase(it); }
917  bool ClearNV(bool bWriteToDisk = true);
918 
919  const CString& GetSavePath() const;
920  CString ExpandString(const CString& sStr) const;
921  CString& ExpandString(const CString& sStr, CString& sRet) const;
922 
923  // Setters
924  void SetType(CModInfo::EModuleType eType) { m_eType = eType; }
925  void SetDescription(const CString& s) { m_sDescription = s; }
926  void SetModPath(const CString& s) { m_sModPath = s; }
927  void SetArgs(const CString& s) { m_sArgs = s; }
928  // !Setters
929 
930  // Getters
932  const CString& GetDescription() const { return m_sDescription; }
933  const CString& GetArgs() const { return m_sArgs; }
934  const CString& GetModPath() const { return m_sModPath; }
935 
941  CUser* GetUser() { return m_pUser; }
946  CClient* GetClient() { return m_pClient; }
948  // !Getters
949 
950  // Global Modules
957  virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
962  virtual EModRet OnDeleteUser(CUser& User);
969  virtual void OnClientConnect(CZNCSock* pSock, const CString& sHost, unsigned short uPort);
981  virtual void OnFailedLogin(const CString& sUsername, const CString& sRemoteIP);
988  virtual EModRet OnUnknownUserRaw(CClient* pClient, CString& sLine);
989 
995  virtual void OnClientCapLs(CClient* pClient, SCString& ssCaps);
1002  virtual bool IsClientCapSupported(CClient* pClient, const CString& sCap, bool bState);
1008  virtual void OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState);
1009 
1019  virtual EModRet OnModuleLoading(const CString& sModName, const CString& sArgs,
1020  CModInfo::EModuleType eType, bool& bSuccess, CString& sRetMsg);
1028  virtual EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
1036  virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
1037  bool& bSuccess, CString& sRetMsg);
1042  virtual void OnGetAvailableMods(std::set<CModInfo>& ssMods, CModInfo::EModuleType eType);
1043  // !Global Modules
1044 
1045 protected:
1048  std::set<CTimer*> m_sTimers;
1049  std::set<CSocket*> m_sSockets;
1060 private:
1061  MCString m_mssRegistry;
1062  VWebSubPages m_vSubPages;
1063  std::map<CString, CModCommand> m_mCommands;
1064 };
1065 
1066 class CModules : public std::vector<CModule*> {
1067 public:
1068  CModules();
1069  ~CModules();
1070 
1071  void SetUser(CUser* pUser) { m_pUser = pUser; }
1072  void SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
1073  void SetClient(CClient* pClient) { m_pClient = pClient; }
1074  CUser* GetUser() { return m_pUser; }
1076  CClient* GetClient() { return m_pClient; }
1077 
1078  void UnloadAll();
1079 
1080  bool OnBoot();
1081  bool OnPreRehash();
1082  bool OnPostRehash();
1083  bool OnIRCDisconnected();
1084  bool OnIRCConnected();
1085  bool OnIRCConnecting(CIRCSock *pIRCSock);
1086  bool OnIRCConnectionError(CIRCSock *pIRCSock);
1087  bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName);
1088  bool OnBroadcast(CString& sMessage);
1089 
1090  bool OnChanPermission2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange);
1091  bool OnChanPermission(const CNick& OpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange);
1092  bool OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
1093  bool OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
1094  bool OnDeop2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
1095  bool OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
1096  bool OnVoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
1097  bool OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
1098  bool OnDevoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
1099  bool OnDevoice(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
1100  bool OnRawMode2(const CNick* pOpNick, CChan& Channel, const CString& sModes, const CString& sArgs);
1101  bool OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes, const CString& sArgs);
1102  bool OnMode2(const CNick* pOpNick, CChan& Channel, char uMode, const CString& sArg, bool bAdded, bool bNoChange);
1103  bool OnMode(const CNick& OpNick, CChan& Channel, char uMode, const CString& sArg, bool bAdded, bool bNoChange);
1104 
1105  bool OnRaw(CString& sLine);
1106 
1107  bool OnStatusCommand(CString& sCommand);
1108  bool OnModCommand(const CString& sCommand);
1109  bool OnModNotice(const CString& sMessage);
1110  bool OnModCTCP(const CString& sMessage);
1111 
1112  bool OnQuit(const CNick& Nick, const CString& sMessage, const std::vector<CChan*>& vChans);
1113  bool OnNick(const CNick& Nick, const CString& sNewNick, const std::vector<CChan*>& vChans);
1114  bool OnKick(const CNick& Nick, const CString& sOpNick, CChan& Channel, const CString& sMessage);
1115  bool OnJoin(const CNick& Nick, CChan& Channel);
1116  bool OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage);
1117  bool OnInvite(const CNick& Nick, const CString& sChan);
1118 
1119  bool OnChanBufferStarting(CChan& Chan, CClient& Client);
1120  bool OnChanBufferEnding(CChan& Chan, CClient& Client);
1121  bool OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
1122  bool OnPrivBufferPlayLine(CClient& Client, CString& sLine);
1123 
1124  bool OnClientLogin();
1125  bool OnClientDisconnect();
1126  bool OnUserRaw(CString& sLine);
1127  bool OnUserCTCPReply(CString& sTarget, CString& sMessage);
1128  bool OnUserCTCP(CString& sTarget, CString& sMessage);
1129  bool OnUserAction(CString& sTarget, CString& sMessage);
1130  bool OnUserMsg(CString& sTarget, CString& sMessage);
1131  bool OnUserNotice(CString& sTarget, CString& sMessage);
1132  bool OnUserJoin(CString& sChannel, CString& sKey);
1133  bool OnUserPart(CString& sChannel, CString& sMessage);
1134  bool OnUserTopic(CString& sChannel, CString& sTopic);
1135  bool OnUserTopicRequest(CString& sChannel);
1136 
1137  bool OnCTCPReply(CNick& Nick, CString& sMessage);
1138  bool OnPrivCTCP(CNick& Nick, CString& sMessage);
1139  bool OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
1140  bool OnPrivAction(CNick& Nick, CString& sMessage);
1141  bool OnChanAction(CNick& Nick, CChan& Channel, CString& sMessage);
1142  bool OnPrivMsg(CNick& Nick, CString& sMessage);
1143  bool OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
1144  bool OnPrivNotice(CNick& Nick, CString& sMessage);
1145  bool OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage);
1146  bool OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
1147  bool OnTimerAutoJoin(CChan& Channel);
1148 
1149  bool OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1150  bool OnDeleteNetwork(CIRCNetwork& Network);
1151 
1152  bool OnSendToClient(CString& sLine, CClient& Client);
1153  bool OnSendToIRC(CString& sLine);
1154 
1155  bool OnServerCapAvailable(const CString& sCap);
1156  bool OnServerCapResult(const CString& sCap, bool bSuccess);
1157 
1158  CModule* FindModule(const CString& sModule) const;
1159  bool LoadModule(const CString& sModule, const CString& sArgs, CModInfo::EModuleType eType, CUser* pUser, CIRCNetwork* pNetwork, CString& sRetMsg);
1160  bool UnloadModule(const CString& sModule);
1161  bool UnloadModule(const CString& sModule, CString& sRetMsg);
1162  bool ReloadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CIRCNetwork* pNetwork, CString& sRetMsg);
1163 
1164  static bool GetModInfo(CModInfo& ModInfo, const CString& sModule, CString &sRetMsg);
1165  static bool GetModPathInfo(CModInfo& ModInfo, const CString& sModule, const CString& sModPath, CString &sRetMsg);
1166  static void GetAvailableMods(std::set<CModInfo>& ssMods, CModInfo::EModuleType eType = CModInfo::UserModule);
1167 
1168  // This returns the path to the .so and to the data dir
1169  // which is where static data (webadmin skins) are saved
1170  static bool FindModPath(const CString& sModule, CString& sModPath,
1171  CString& sDataPath);
1172  // Return a list of <module dir, data dir> pairs for directories in
1173  // which modules can be found.
1174  typedef std::queue<std::pair<CString, CString> > ModDirList;
1175  static ModDirList GetModDirs();
1176 
1177  // Global Modules
1178  bool OnAddUser(CUser& User, CString& sErrorRet);
1179  bool OnDeleteUser(CUser& User);
1180  bool OnClientConnect(CZNCSock* pSock, const CString& sHost, unsigned short uPort);
1182  bool OnFailedLogin(const CString& sUsername, const CString& sRemoteIP);
1183  bool OnUnknownUserRaw(CClient* pClient, CString& sLine);
1184  bool OnClientCapLs(CClient* pClient, SCString& ssCaps);
1185  bool IsClientCapSupported(CClient* pClient, const CString& sCap, bool bState);
1186  bool OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState);
1187  bool OnModuleLoading(const CString& sModName, const CString& sArgs,
1188  CModInfo::EModuleType eType, bool& bSuccess, CString& sRetMsg);
1189  bool OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
1190  bool OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
1191  bool& bSuccess, CString& sRetMsg);
1192  bool OnGetAvailableMods(std::set<CModInfo>& ssMods, CModInfo::EModuleType eType);
1193  // !Global Modules
1194 
1195 private:
1196  static ModHandle OpenModule(const CString& sModule, const CString& sModPath,
1197  bool &bVersionMismatch, CModInfo& Info, CString& sRetMsg);
1198 
1199 protected:
1203 };
1204 
1205 #endif // !_MODULES_H
virtual EModRet OnAddUser(CUser &User, CString &sErrorRet)
This module hook is called when a user is being added.
virtual void OnOp(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnServerCapAvailable(const CString &sCap)
void(CModule::* ModCmdFunc)(const CString &sLine)
Type for the callback function that handles the actual command.
Definition: Modules.h:261
void(* FPTimer_t)(CModule *, CFPTimer *)
Definition: Modules.h:156
bool UnlinkSocket(CSocket *pSocket)
void SetDescription(const CString &s)
virtual bool OnBoot()
This module hook is called during ZNC startup.
virtual void OnOp2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is opped on a channel.
void SetArgs(const CString &s)
Definition: Modules.h:927
virtual EModRet OnUserCTCP(CString &sTarget, CString &sMessage)
This module hook is called when a client sends a CTCP request.
Definition: User.h:37
CModInfo()
Definition: Modules.h:190
bool OnBoot()
bool OnChanAction(CNick &Nick, CChan &Channel, CString &sMessage)
static bool GetModPathInfo(CModInfo &ModInfo, const CString &sModule, const CString &sModPath, CString &sRetMsg)
virtual EModRet OnTopic(CNick &Nick, CChan &Channel, CString &sTopic)
Called when we receive a channel topic change from IRC.
bool OnAddNetwork(CIRCNetwork &Network, CString &sErrorRet)
const CString & GetArgs() const
Definition: Modules.h:933
void SetHasArgs(bool b=false)
Definition: Modules.h:240
static void InitHelp(CTable &Table)
Initialize a CTable so that it can be used with AddHelp().
virtual ~CModule()
#define VERSION
Definition: version.h:8
CModule * GetModule() const
virtual CString GetWebPath()
CString m_sDescription
Definition: Modules.h:153
bool OnKick(const CNick &Nick, const CString &sOpNick, CChan &Channel, const CString &sMessage)
virtual EModRet OnInvite(const CNick &Nick, const CString &sChan)
Called when user is invited into a channel.
virtual EModRet OnLoginAttempt(CSmartPtr< CAuthBase > Auth)
This module hook is called when a client tries to login.
bool AddSocket(CSocket *pSocket)
bool OnPrivBufferPlayLine(CClient &Client, CString &sLine)
void SetNetwork(CIRCNetwork *pNetwork)
Definition: Modules.h:1072
bool OnDeop(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnIRCConnecting(CIRCSock *pIRCSock)
CString GetNV(const CString &sName) const
CModInfo(const CString &sName, const CString &sPath, EModuleType eType)
Definition: Modules.h:194
virtual void OnModNotice(const CString &sMessage)
Called when a your module nick was sent a notice.
CString m_sSavePath
Definition: Modules.h:1057
ZNC will continue event processing normally.
Definition: Modules.h:336
bool GetHasArgs() const
Definition: Modules.h:229
virtual EModRet OnUnknownUserRaw(CClient *pClient, CString &sLine)
This function behaves like CModule::OnRaw(), but is also called before the client successfully logged...
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.
EModuleType m_eDefaultType
Definition: Modules.h:247
virtual EModRet OnChanNotice(CNick &Nick, CChan &Channel, CString &sMessage)
Called when we receive a channel notice.
EModuleType
Definition: Modules.h:184
virtual void OnUnknownModCommand(const CString &sCommand)
This is similar to OnModCommand(), but it is only called if HandleCommand didn&#39;t find any that wants ...
virtual bool PutUser(const CString &sLine)
This function sends a given raw IRC line to a client.
void SetUser(CUser *pUser)
Definition: Modules.h:1071
bool OnIRCConnected()
virtual void OnDeop(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CString m_sWikiPage
Definition: Modules.h:251
bool OnGetModInfo(CModInfo &ModInfo, const CString &sModule, bool &bSuccess, CString &sRetMsg)
void Call(CModule *pMod, const CString &sLine) const
Definition: Modules.h:300
CUser * GetUser()
Definition: Modules.h:941
virtual void OnFailedLogin(const CString &sUsername, const CString &sRemoteIP)
Called after a client login was rejected.
std::queue< std::pair< CString, CString > > ModDirList
Definition: Modules.h:1174
bool OnUserJoin(CString &sChannel, CString &sKey)
virtual void OnChanPermission(const CNick &OpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
void AddHelpCommand()
Register the &quot;Help&quot; command.
MCString::iterator FindNV(const CString &sName)
Definition: Modules.h:913
virtual void OnPostRehash()
This module hook is called after a successful rehash.
static void GetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType=CModInfo::UserModule)
CTimer * FindTimer(const CString &sLabel)
void SetModPath(const CString &s)
Definition: Modules.h:926
CModule *(* ModLoader)(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath)
Definition: Modules.h:182
bool OnSendToIRC(CString &sLine)
bool OnChanNotice(CNick &Nick, CChan &Channel, CString &sMessage)
virtual EModRet OnTimerAutoJoin(CChan &Channel)
This module hook is called just before ZNC tries to join a channel by itself because it&#39;s in the conf...
void SetFPCallback(FPTimer_t p)
Definition: Modules.h:167
virtual void OnMode2(const CNick *pOpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
Called on an individual channel mode change.
bool OnSendToClient(CString &sLine, CClient &Client)
virtual void OnClientCapLs(CClient *pClient, SCString &ssCaps)
Called when a client told us CAP LS.
std::set< CTimer * > m_sTimers
Definition: Modules.h:1048
Definition: Client.h:84
bool OnPrivCTCP(CNick &Nick, CString &sMessage)
CModInfo::EModuleType GetType() const
Definition: Modules.h:931
bool LoadRegistry()
bool OnUserRaw(CString &sLine)
bool OnMode2(const CNick *pOpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
virtual void OnModCTCP(const CString &sMessage)
Called when your module nick was sent a CTCP message.
std::set< CSocket * >::const_iterator BeginSockets() const
Definition: Modules.h:878
bool OnPreRehash()
bool OnClientDisconnect()
CClient * GetClient()
Definition: Modules.h:946
void SetModule(CModule *p)
bool OnClientCapLs(CClient *pClient, SCString &ssCaps)
CSockManager * m_pManager
Definition: Modules.h:1051
bool DelNV(const CString &sName, bool bWriteToDisk=true)
void UnloadAll()
CModCommand()
Default constructor, needed so that this can be saved in a std::map.
virtual EModRet OnIRCConnecting(CIRCSock *pIRCSock)
This module hook is called just before ZNC tries to establish a connection to an IRC server...
bool OnServerCapResult(const CString &sCap, bool bSuccess)
This is the same as both CModule::HALTMODS and CModule::HALTCORE together.
Definition: Modules.h:340
std::set< CSocket * > m_sSockets
Definition: Modules.h:1049
CModule * FindModule(const CString &sModule) const
bool OnChanPermission(const CNick &OpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
bool UnloadModule(const CString &sModule)
bool OnTopic(CNick &Nick, CChan &Channel, CString &sTopic)
const CString & GetArgs() const
Definition: Modules.h:297
CString m_sArgsHelpText
Definition: Modules.h:252
Definition: Modules.h:1066
bool OnModuleUnloading(CModule *pModule, bool &bSuccess, CString &sRetMsg)
bool IsClientCapSupported(CClient *pClient, const CString &sCap, bool bState)
virtual bool OnEmbeddedWebRequest(CWebSock &WebSock, const CString &sPageName, CTemplate &Tmpl)
Using this hook, module can embed web stuff directly to different places.
CString ExpandString(const CString &sStr) const
void SetDescription(const CString &s)
Definition: Modules.h:925
CClient * m_pClient
Definition: Modules.h:1054
Definition: Nick.h:29
virtual EModRet OnUserNotice(CString &sTarget, CString &sMessage)
This module hook is called when a user sends a notice message.
virtual void OnDevoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
void SetPath(const CString &s)
Definition: Modules.h:236
Definition: Socket.h:46
virtual void OnClientLogin()
Called when a client successfully logged in to ZNC.
bool OnPrivMsg(CNick &Nick, CString &sMessage)
bool ClearNV(bool bWriteToDisk=true)
const CString & GetCommand() const
Definition: Modules.h:295
bool m_bHasArgs
Definition: Modules.h:253
std::vector< TWebSubPage > VWebSubPages
Definition: WebModules.h:31
virtual void OnKick(const CNick &OpNick, const CString &sKickedNick, CChan &Channel, const CString &sMessage)
Called when a nick is kicked from a channel.
std::set< CString > SCString
Definition: ZNCString.h:34
Definition: Modules.h:187
virtual EModRet OnGetModInfo(CModInfo &ModInfo, const CString &sModule, bool &bSuccess, CString &sRetMsg)
Called when info about a module is needed.
CClient * m_pClient
Definition: Modules.h:1202
void SetClient(CClient *pClient)
const CString & GetPath() const
Definition: Modules.h:225
bool OnIRCConnectionError(CIRCSock *pIRCSock)
std::set< EModuleType > m_seType
Definition: Modules.h:246
Definition: Socket.h:26
EModuleType GetDefaultType() const
Definition: Modules.h:231
bool OnLoginAttempt(CSmartPtr< CAuthBase > Auth)
Base Csock implementation to be used by modules.
Definition: Socket.h:164
bool OnBroadcast(CString &sMessage)
void HandleHelpCommand(const CString &sLine="")
Send a description of all registered commands via PutModule().
bool OnOp(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual void OnClientDisconnect()
Called when a client disconnected from ZNC.
void SetNetwork(CIRCNetwork *pNetwork)
Definition: Modules.h:158
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.
Definition: Modules.h:135
bool SaveRegistry() const
void SetLoader(ModLoader fLoader)
Definition: Modules.h:241
virtual EModRet OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
Called when we receive a channel CTCP request from IRC.
const CString & GetModPath() const
Definition: Modules.h:934
bool AddCommand(const CModCommand &Command)
virtual ~CTimer()
virtual EModRet OnUserAction(CString &sTarget, CString &sMessage)
Called when a client sends a CTCP ACTION request (&quot;/me&quot;).
bool OnRawMode(const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
virtual void OnDevoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is devoiced on a channel.
void * ModHandle
Definition: Modules.h:35
bool AddTimer(CTimer *pTimer)
bool OnIRCRegistration(CString &sPass, CString &sNick, CString &sIdent, CString &sRealName)
virtual EModRet OnUserTopicRequest(CString &sChannel)
This hook is called when a user requests a channel&#39;s topic.
virtual EModRet OnPrivCTCP(CNick &Nick, CString &sMessage)
Called when we receive a private CTCP request from IRC.
CModCommand & operator=(const CModCommand &other)
Assignment operator, needed so that this can be saved in a std::map.
virtual bool PutModule(const CString &sLine)
This function sends a query from your module nick.
ModCmdFunc GetFunction() const
Definition: Modules.h:296
virtual void OnIRCConnectionError(CIRCSock *pIRCSock)
This module hook is called when a CIRCSock fails to connect or a module returned HALTCORE from OnIRCC...
Definition: znc.h:35
bool OnTimerAutoJoin(CChan &Channel)
Definition: Template.h:117
bool OnModNotice(const CString &sMessage)
virtual EModRet OnUserPart(CString &sChannel, CString &sMessage)
This hooks is called when a user sends a PART message.
virtual bool IsClientCapSupported(CClient *pClient, const CString &sCap, bool bState)
Called only to check if your module supports turning on/off named capability.
Definition: IRCNetwork.h:36
virtual bool WebRequiresLogin()
Modules which can only be used with an active user session have to return true here.
Definition: Modules.h:384
bool OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
bool OnVoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
EModException
Definition: Modules.h:352
CIRCNetwork * GetNetwork()
Definition: Modules.h:1075
const CString & GetWikiPage() const
Definition: Modules.h:227
bool LoadModule(const CString &sModule, const CString &sArgs, CModInfo::EModuleType eType, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
~CModInfo()
Definition: Modules.h:200
virtual void OnModCommand(const CString &sCommand)
Called when a command to your module is sent, e.g.
void SetName(const CString &s)
Definition: Modules.h:235
CUser * m_pUser
Definition: Modules.h:1200
virtual EModRet OnAddNetwork(CIRCNetwork &Network, CString &sErrorRet)
This module hook is called when a network is being added.
bool OnUserTopic(CString &sChannel, CString &sTopic)
bool UnlinkTimer(CTimer *pTimer)
virtual ~CFPTimer()
Definition: Modules.h:165
String class that is used inside ZNC.
Definition: ZNCString.h:67
virtual EModRet OnBroadcast(CString &sMessage)
This module hook is called when a message is broadcasted to all users.
bool OnDeop2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual EModRet OnSendToIRC(CString &sLine)
Called when ZNC sends a raw traffic line to the IRC server.
virtual void OnRawMode(const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
Continue calling other modules.
Definition: Modules.h:349
virtual bool OnServerCapAvailable(const CString &sCap)
Called for every CAP received via CAP LS from server.
virtual EModRet OnSendToClient(CString &sLine, CClient &Client)
Called when ZNC sends a raw traffic line to a client.
virtual void OnPart(const CNick &Nick, CChan &Channel, const CString &sMessage)
Called when a nick parts a channel.
This is a standard reference counting pointer. Be careful not to have two of these point to the same ...
Definition: Utils.h:363
bool OnJoin(const CNick &Nick, CChan &Channel)
void Unload()
This function throws CModule::UNLOAD which causes this module to be unloaded.
Definition: Modules.h:365
virtual void OnGetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType)
Called when list of available mods is requested.
EModRet
This enum is just used for return from module hooks.
Definition: Modules.h:332
Definition: Modules.h:185
void DelNV(MCString::iterator it)
Definition: Modules.h:916
virtual bool OnWebPreRequest(CWebSock &WebSock, const CString &sPageName)
For WebMods: Called before the list of registered SubPages will be checked.
bool RemSocket(CSocket *pSocket)
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)...
bool OnUnknownUserRaw(CClient *pClient, CString &sLine)
static double GetCoreVersion()
Definition: Modules.h:802
CString GetModNick() const
virtual bool PutStatus(const CString &sLine)
This function generates a query from *status.
bool OnPrivNotice(CNick &Nick, CString &sMessage)
Definition: Modules.h:180
bool OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
static CString ModuleTypeToString(EModuleType eType)
Definition: Modules.h:214
The base class for your own ZNC modules.
Definition: Modules.h:322
bool OnStatusCommand(CString &sCommand)
bool OnUserNotice(CString &sTarget, CString &sMessage)
CModInfo::EModuleType m_eType
Definition: Modules.h:1046
virtual EModRet OnUserJoin(CString &sChannel, CString &sKey)
This hooks is called when a user sends a JOIN message.
bool OnChanBufferEnding(CChan &Chan, CClient &Client)
static ModDirList GetModDirs()
bool OnModuleLoading(const CString &sModName, const CString &sArgs, CModInfo::EModuleType eType, bool &bSuccess, CString &sRetMsg)
const CString & GetModName() const
Definition: Modules.h:847
virtual EModRet OnChanAction(CNick &Nick, CChan &Channel, CString &sMessage)
Called when we receive a channel CTCP ACTION (&quot;/me&quot; in a channel) from IRC.
CUser * m_pUser
Definition: Modules.h:1052
bool RemTimer(CTimer *pTimer)
CClient * GetClient()
Definition: Modules.h:1076
virtual EModRet OnModuleUnloading(CModule *pModule, bool &bSuccess, CString &sRetMsg)
Called when a module is going to be unloaded.
bool OnPart(const CNick &Nick, CChan &Channel, const CString &sMessage)
void SetDescription(const CString &s)
Definition: Modules.h:237
virtual CString GetWebFilesPath()
void AddType(EModuleType eType)
Definition: Modules.h:210
virtual void ListTimers()
virtual void OnVoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
MCString::iterator EndNV()
Definition: Modules.h:914
virtual EModRet OnDeleteNetwork(CIRCNetwork &Network)
This module hook is called when a network is deleted.
bool OnUserPart(CString &sChannel, CString &sMessage)
bool OnVoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual void OnIRCConnected()
This module hook is called after a successful login to IRC.
CSockManager * GetManager()
Definition: Modules.h:947
void TModInfo(CModInfo &Info)
Definition: Modules.h:50
Definition: WebModules.h:111
const CString & GetArgsHelpText() const
Definition: Modules.h:228
void SetType(CModInfo::EModuleType eType)
Definition: Modules.h:924
virtual EModRet OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
Called when for each line during a channel&#39;s buffer play back.
bool OnIRCDisconnected()
this is the main cron job class
Definition: Csocket.h:369
bool OnCTCPReply(CNick &Nick, CString &sMessage)
virtual void ListSockets()
virtual VWebSubPages & GetSubPages()
Returns a list of all registered SubPages.
Definition: Modules.h:424
virtual EModRet OnChanBufferEnding(CChan &Chan, CClient &Client)
Called after a channel buffer was played back to a client.
Definition: Client.h:33
bool OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan * > &vChans)
bool OnUserCTCPReply(CString &sTarget, CString &sMessage)
virtual void OnIRCDisconnected()
This module hook is called when a user gets disconnected from IRC.
bool HandleCommand(const CString &sLine)
This function tries to dispatch the given command via the correct instance of CModCommand.
virtual EModRet OnCTCPReply(CNick &Nick, CString &sMessage)
Called when we receive a CTCP reply from IRC.
Definition: Modules.h:186
virtual EModRet OnUserMsg(CString &sTarget, CString &sMessage)
This module hook is called when a user sends a normal IRC message.
virtual bool OnLoad(const CString &sArgsi, CString &sMessage)
This module hook is called when a module is loaded.
virtual EModRet OnUserTopic(CString &sChannel, CString &sTopic)
This module hook is called when a user wants to change a channel topic.
void AddHelp(CTable &Table) const
Add this command to the CTable instance.
virtual EModRet OnRaw(CString &sLine)
Called on any raw IRC line received from the IRC server.
const CString & GetDescription() const
Definition: Modules.h:226
void SetWikiPage(const CString &s)
Definition: Modules.h:238
bool SupportsType(EModuleType eType)
Definition: Modules.h:206
virtual EModRet OnUserRaw(CString &sLine)
This module hook is called when a client sends a raw traffic line to ZNC.
CString m_sArgs
Definition: Modules.h:1058
CString m_sModPath
Definition: Modules.h:1059
virtual void OnMode(const CNick &OpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
CString m_sDataDir
Definition: Modules.h:1056
CString m_sName
Definition: Modules.h:248
bool operator<(const CModInfo &Info) const
Definition: Modules.h:202
A dictionary for strings.
Definition: ZNCString.h:538
bool OnModCommand(const CString &sCommand)
bool OnUserMsg(CString &sTarget, CString &sMessage)
void SetArgsHelpText(const CString &s)
Definition: Modules.h:239
bool OnPostRehash()
bool OnDevoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual void OnPreRehash()
Called just before znc.conf is rehashed.
bool OnDevoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnUserTopicRequest(CString &sChannel)
bool RemCommand(const CString &sCmd)
virtual EModRet OnUserCTCPReply(CString &sTarget, CString &sMessage)
This module hook is called when a client sends a CTCP reply.
virtual bool PutModNotice(const CString &sLine)
Send a notice from your module nick.
CTimer(CModule *pModule, unsigned int uInterval, unsigned int uCycles, const CString &sLabel, const CString &sDescription)
std::set< CTimer * >::const_iterator EndTimers() const
Definition: Modules.h:868
bool OnGetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType)
bool OnClientLogin()
bool OnMode(const CNick &OpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
bool OnClientCapRequest(CClient *pClient, const CString &sCap, bool bState)
CIRCNetwork * m_pNetwork
Definition: Modules.h:1053
const CString & GetDescription() const
Definition: Modules.h:932
CString m_sModName
Definition: Modules.h:1055
virtual void OnRawMode2(const CNick *pOpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
Called on any channel mode change.
bool OnInvite(const CNick &Nick, const CString &sChan)
virtual bool PutIRC(const CString &sLine)
This function sends a given raw IRC line to the IRC server, if we are connected to one...
bool OnOp2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
ModHandle GetDLL()
Definition: Modules.h:801
bool OnRawMode2(const CNick *pOpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
ModLoader GetLoader() const
Definition: Modules.h:230
const CString & GetName() const
Definition: Modules.h:224
std::set< CTimer * >::const_iterator BeginTimers() const
Definition: Modules.h:867
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.
virtual EModRet OnDeleteUser(CUser &User)
This module hook is called when a user is deleted.
CUser * GetUser()
Definition: Modules.h:1074
CFPTimer(CModule *pModule, unsigned int uInterval, unsigned int uCycles, const CString &sLabel, const CString &sDescription)
Definition: Modules.h:160
bool OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
virtual void AddSubPage(TWebSubPage spSubPage)
Registers a sub page for the sidebar.
Definition: Modules.h:417
virtual void OnNick(const CNick &Nick, const CString &sNewNick, const std::vector< CChan * > &vChans)
Called when a nickname change occurs.
virtual EModRet OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
Called when we receive a channel message from IRC.
CString m_sPath
Definition: Modules.h:249
bool OnUserCTCP(CString &sTarget, CString &sMessage)
virtual void ClearSubPages()
Removes all registered (AddSubPage&#39;d) SubPages.
Definition: Modules.h:420
bool OnUserAction(CString &sTarget, CString &sMessage)
const CString & GetDescription() const
bool OnDeleteUser(CUser &User)
bool OnChanBufferStarting(CChan &Chan, CClient &Client)
CModule * TModLoad(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath)
Definition: Modules.h:52
MCString::iterator BeginNV()
Definition: Modules.h:915
ModHandle m_pDLL
Definition: Modules.h:1050
bool OnFailedLogin(const CString &sUsername, const CString &sRemoteIP)
virtual void OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan * > &vChans)
Called when a nick quit from IRC.
virtual bool WebRequiresAdmin()
Return true if this module should only be usable for admins on the web.
Definition: Modules.h:388
bool OnModCTCP(const CString &sMessage)
virtual void OnDeop2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is deopped on a channel.
CIRCNetwork * GetNetwork()
Definition: Modules.h:945
bool ReloadModule(const CString &sModule, const CString &sArgs, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
CIRCNetwork * m_pNetwork
Definition: Modules.h:1201
void SetDefaultType(EModuleType eType)
Definition: Modules.h:242
virtual void RunJob()
this is the method you should override
Definition: Modules.h:170
void SetUser(CUser *pUser)
virtual void OnVoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is voiced on a channel.
CModule * m_pModule
Definition: Modules.h:152
bool OnAddUser(CUser &User, CString &sErrorRet)
bool OnPrivAction(CNick &Nick, CString &sMessage)
bool OnNick(const CNick &Nick, const CString &sNewNick, const std::vector< CChan * > &vChans)
virtual EModRet OnPrivAction(CNick &Nick, CString &sMessage)
Called when we receive a private CTCP ACTION (&quot;/me&quot; in query) from IRC.
static bool GetModInfo(CModInfo &ModInfo, const CString &sModule, CString &sRetMsg)
Your module can throw this enum at any given time.
Definition: Modules.h:356
CString m_sDescription
Definition: Modules.h:250
const CString & GetSavePath() const
bool SetNV(const CString &sName, const CString &sValue, bool bWriteToDisk=true)
std::set< CSocket * >::const_iterator EndSockets() const
Definition: Modules.h:879
virtual CString GetWebMenuTitle()
Return the title of the module&#39;s section in the web interface&#39;s side bar.
Definition: Modules.h:392
virtual void OnChanPermission2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
This module hook is called when a user mode on a channel changes.
A helper class for handling commands in modules.
Definition: Modules.h:258
virtual void OnJoin(const CNick &Nick, CChan &Channel)
Called when a nick joins a channel.
virtual EModRet OnPrivNotice(CNick &Nick, CString &sMessage)
Called when we receive a private notice.
void SetClient(CClient *pClient)
Definition: Modules.h:1073
bool OnRaw(CString &sLine)
virtual EModRet OnPrivMsg(CNick &Nick, CString &sMessage)
Called when we receive a private message from IRC.
const CString & GetDescription() const
Definition: Modules.h:298
Stop sending this even to other modules which were not called yet.
Definition: Modules.h:344
Definition: IRCSock.h:33
virtual EModRet OnPrivBufferPlayLine(CClient &Client, CString &sLine)
Called when a line from the query buffer is played back.
const CModCommand * FindCommand(const CString &sCmd) const
CModule(ModHandle pDLL, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sDataDir)
ModLoader m_fLoader
Definition: Modules.h:254
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&#39;s listening sockets...
Definition: Chan.h:34
virtual EModRet OnStatusCommand(CString &sCommand)
Called when a command to *status is sent.
Generate a grid-like output from a given input.
Definition: Utils.h:139
bool OnDeleteNetwork(CIRCNetwork &Network)
static bool FindModPath(const CString &sModule, CString &sModPath, CString &sDataPath)
bool OnClientConnect(CZNCSock *pSock, const CString &sHost, unsigned short uPort)
CSocket * FindSocket(const CString &sSockName)
const CString & GetModDataDir() const
Get the module&#39;s data dir.
Definition: Modules.h:858
virtual EModRet OnChanBufferStarting(CChan &Chan, CClient &Client)
Called before a channel buffer is played back to a client.
bool OnChanPermission2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
virtual EModRet OnIRCRegistration(CString &sPass, CString &sNick, CString &sIdent, CString &sRealName)
This module hook is called before loging in to the IRC server.
CString m_sDescription
Definition: Modules.h:1047