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-2018 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 ZNC_MODULES_H
18 #define ZNC_MODULES_H
19 
20 #include <znc/zncconfig.h>
21 #include <znc/WebModules.h>
22 #include <znc/Utils.h>
23 #include <znc/Threads.h>
24 #include <znc/Message.h>
25 #include <znc/main.h>
26 #include <znc/Translation.h>
27 #include <functional>
28 #include <set>
29 #include <queue>
30 #include <sys/time.h>
31 
32 // Forward Declarations
33 class CAuthBase;
34 class CChan;
35 class CQuery;
36 class CIRCNetwork;
37 class CClient;
38 class CWebSock;
39 class CTemplate;
40 class CIRCSock;
41 class CModule;
42 class CModInfo;
43 // !Forward Declarations
44 
45 #ifdef REQUIRESSL
46 #ifndef HAVE_LIBSSL
47 #error -
48 #error -
49 #error This module only works when ZNC is compiled with OpenSSL support
50 #error -
51 #error -
52 #endif
53 #endif
54 
55 #ifdef BUILD_WITH_CMAKE
56 #include <znc/znc_export_lib_export.h>
57 #elif HAVE_VISIBILITY
58 #define ZNC_EXPORT_LIB_EXPORT __attribute__((__visibility__("default")))
59 #else
60 #define ZNC_EXPORT_LIB_EXPORT
61 #endif
62 
80 struct CModuleEntry {
81  const char* pcVersion;
82  const char* pcVersionExtra;
83  const char* pcCompileOptions;
85 };
86 
87 #define MODCOMMONDEFS(CLASS, DESCRIPTION, TYPE) \
88  static void FillModInfo(CModInfo& Info) { \
89  auto t_s = [&](const CString& sEnglish, \
90  const CString& sContext = "") { \
91  return sEnglish.empty() ? "" : Info.t_s(sEnglish, sContext); \
92  }; \
93  t_s(CString()); /* Don't warn about unused t_s */ \
94  Info.SetDescription(DESCRIPTION); \
95  Info.SetDefaultType(TYPE); \
96  Info.AddType(TYPE); \
97  Info.SetLoader(TModLoad<CLASS>); \
98  TModInfo<CLASS>(Info); \
99  } \
100  extern "C" { \
101  /* A global variable leads to ODR violation when several modules are \
102  * loaded. But a static variable inside a function works. */ \
103  ZNC_EXPORT_LIB_EXPORT const CModuleEntry* ZNCModuleEntry(); \
104  ZNC_EXPORT_LIB_EXPORT const CModuleEntry* ZNCModuleEntry() { \
105  static const CModuleEntry ThisModule = {VERSION_STR, VERSION_EXTRA, \
106  ZNC_COMPILE_OPTIONS_STRING, \
107  FillModInfo}; \
108  return &ThisModule; \
109  } \
110  }
111 
127 #define MODCONSTRUCTOR(CLASS) \
128  CLASS(ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork, \
129  const CString& sModName, const CString& sModPath, \
130  CModInfo::EModuleType eType) \
131  : CModule(pDLL, pUser, pNetwork, sModName, sModPath, eType)
132 
133 // User Module Macros
135 #define USERMODULEDEFS(CLASS, DESCRIPTION) \
136  MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::UserModule)
137 // !User Module Macros
138 
139 // Global Module Macros
141 #define GLOBALMODULEDEFS(CLASS, DESCRIPTION) \
142  MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::GlobalModule)
143 // !Global Module Macros
144 
145 // Network Module Macros
147 #define NETWORKMODULEDEFS(CLASS, DESCRIPTION) \
148  MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::NetworkModule)
149 // !Network Module Macros
150 
157 #define MODULEDEFS(CLASS, DESCRIPTION) NETWORKMODULEDEFS(CLASS, DESCRIPTION)
158 
159 // Forward Declarations
160 class CZNC;
161 class CUser;
162 class CNick;
163 class CChan;
164 class CModule;
165 class CFPTimer;
166 class CSockManager;
167 // !Forward Declarations
168 
169 class CTimer : public CCron {
170  public:
171  CTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles,
172  const CString& sLabel, const CString& sDescription);
173 
174  virtual ~CTimer();
175 
176  CTimer(const CTimer&) = delete;
177  CTimer& operator=(const CTimer&) = delete;
178 
179  // Setters
180  void SetModule(CModule* p);
181  void SetDescription(const CString& s);
182  // !Setters
183 
184  // Getters
185  CModule* GetModule() const;
186  const CString& GetDescription() const;
187  // !Getters
188  private:
189  protected:
192 };
193 
194 typedef void (*FPTimer_t)(CModule*, CFPTimer*);
195 
196 class CFPTimer : public CTimer {
197  public:
198  CFPTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles,
199  const CString& sLabel, const CString& sDescription)
200  : CTimer(pModule, uInterval, uCycles, sLabel, sDescription),
201  m_pFBCallback(nullptr) {}
202 
203  virtual ~CFPTimer() {}
204 
205  void SetFPCallback(FPTimer_t p) { m_pFBCallback = p; }
206 
207  protected:
208  void RunJob() override {
209  if (m_pFBCallback) {
210  m_pFBCallback(m_pModule, this);
211  }
212  }
213 
214  private:
215  FPTimer_t m_pFBCallback;
216 };
217 
218 #ifdef HAVE_PTHREAD
219 class CModuleJob : public CJob {
222  public:
223  CModuleJob(CModule* pModule, const CString& sName, const CString& sDesc)
224  : CJob(), m_pModule(pModule), m_sName(sName), m_sDescription(sDesc) {}
225  virtual ~CModuleJob();
226 
227  CModuleJob(const CModuleJob&) = delete;
228  CModuleJob& operator=(const CModuleJob&) = delete;
229 
230  // Getters
231  CModule* GetModule() const { return m_pModule; }
232  const CString& GetName() const { return m_sName; }
233  const CString& GetDescription() const { return m_sDescription; }
234  // !Getters
235 
236  protected:
240 };
241 #endif
242 
243 typedef void* ModHandle;
244 
245 class CModInfo {
246  public:
248 
249  typedef CModule* (*ModLoader)(ModHandle p, CUser* pUser,
250  CIRCNetwork* pNetwork,
251  const CString& sModName,
252  const CString& sModPath, EModuleType eType);
253 
255  CModInfo(const CString& sName, const CString& sPath, EModuleType eType)
256  : m_seType(),
257  m_eDefaultType(eType),
258  m_sName(sName),
259  m_sPath(sPath),
260  m_sDescription(""),
261  m_sWikiPage(""),
262  m_sArgsHelpText(""),
263  m_bHasArgs(false),
264  m_fLoader(nullptr) {}
266 
267  bool operator<(const CModInfo& Info) const {
268  return (GetName() < Info.GetName());
269  }
270 
271  bool SupportsType(EModuleType eType) const {
272  return m_seType.find(eType) != m_seType.end();
273  }
274 
275  void AddType(EModuleType eType) { m_seType.insert(eType); }
276 
278  switch (eType) {
279  case GlobalModule:
280  return "Global";
281  case UserModule:
282  return "User";
283  case NetworkModule:
284  return "Network";
285  default:
286  return "UNKNOWN";
287  }
288  }
289 
290  // Getters
291  const CString& GetName() const { return m_sName; }
292  const CString& GetPath() const { return m_sPath; }
293  const CString& GetDescription() const { return m_sDescription; }
294  const CString& GetWikiPage() const { return m_sWikiPage; }
295  const CString& GetArgsHelpText() const { return m_sArgsHelpText; }
296  bool GetHasArgs() const { return m_bHasArgs; }
297  ModLoader GetLoader() const { return m_fLoader; }
299  // !Getters
300 
301  // Setters
302  void SetName(const CString& s) { m_sName = s; }
303  void SetPath(const CString& s) { m_sPath = s; }
304  void SetDescription(const CString& s) { m_sDescription = s; }
305  void SetWikiPage(const CString& s) { m_sWikiPage = s; }
306  void SetArgsHelpText(const CString& s) { m_sArgsHelpText = s; }
307  void SetHasArgs(bool b = false) { m_bHasArgs = b; }
308  void SetLoader(ModLoader fLoader) { m_fLoader = fLoader; }
309  void SetDefaultType(EModuleType eType) { m_eDefaultType = eType; }
310  // !Setters
311 
312  CString t_s(const CString& sEnglish, const CString& sContext = "") const;
313 
314  private:
315  protected:
316  std::set<EModuleType> m_seType;
325 };
326 
327 template <class M>
328 void TModInfo(CModInfo& Info) {}
329 
330 template <class M>
332  const CString& sModName, const CString& sModPath,
333  CModInfo::EModuleType eType) {
334  return new M(p, pUser, pNetwork, sModName, sModPath, eType);
335 }
336 
338 class CModCommand {
339  public:
341  typedef void (CModule::*ModCmdFunc)(const CString& sLine);
342  typedef std::function<void(const CString& sLine)> CmdFunc;
343 
345  CModCommand();
346 
353  CModCommand(const CString& sCmd, CModule* pMod, ModCmdFunc func,
354  const CString& sArgs, const CString& sDesc);
355  CModCommand(const CString& sCmd, CmdFunc func,
356  const COptionalTranslation& Args,
357  const COptionalTranslation& Desc);
358 
362  CModCommand(const CModCommand& other) = default;
363 
367  CModCommand& operator=(const CModCommand& other) = default;
368 
372  static void InitHelp(CTable& Table);
373 
378  void AddHelp(CTable& Table) const;
379 
380  const CString& GetCommand() const { return m_sCmd; }
381  CmdFunc GetFunction() const { return m_pFunc; }
382  CString GetArgs() const { return m_Args.Resolve(); }
383  CString GetDescription() const { return m_Desc.Resolve(); }
384 
385  void Call(const CString& sLine) const { m_pFunc(sLine); }
386 
387  private:
388  CString m_sCmd;
389  CmdFunc m_pFunc;
390  COptionalTranslation m_Args;
391  COptionalTranslation m_Desc;
392 };
393 
407 class CModule {
408  public:
409  CModule(
410  ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork,
411  const CString& sModName, const CString& sDataDir,
412  CModInfo::EModuleType eType =
413  CModInfo::NetworkModule); // TODO: remove default value in ZNC 2.x
414  virtual ~CModule();
415 
416  CModule(const CModule&) = delete;
417  CModule& operator=(const CModule&) = delete;
418 
423  typedef enum {
427  CONTINUE = 1,
431  HALT = 2,
435  HALTMODS = 3,
441  } EModRet;
442 
443  typedef enum {
448  } EModException;
449 
450  void SetUser(CUser* pUser);
451  void SetNetwork(CIRCNetwork* pNetwork);
452  void SetClient(CClient* pClient);
453 
456  void Unload() { throw UNLOAD; }
457 
464  virtual bool OnLoad(const CString& sArgsi, CString& sMessage);
469  virtual bool OnBoot();
470 
474  virtual bool WebRequiresLogin() { return true; }
478  virtual bool WebRequiresAdmin() { return false; }
482  virtual CString GetWebMenuTitle() { return ""; }
483  virtual CString GetWebPath();
484  virtual CString GetWebFilesPath();
493  virtual bool OnWebPreRequest(CWebSock& WebSock, const CString& sPageName);
503  virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName,
504  CTemplate& Tmpl);
510  virtual bool ValidateWebRequestCSRFCheck(CWebSock& WebSock, const CString& sPageName);
514  virtual void AddSubPage(TWebSubPage spSubPage) {
515  m_vSubPages.push_back(spSubPage);
516  }
519  virtual void ClearSubPages() { m_vSubPages.clear(); }
523  virtual VWebSubPages& GetSubPages() { return m_vSubPages; }
533  virtual bool OnEmbeddedWebRequest(CWebSock& WebSock,
534  const CString& sPageName,
535  CTemplate& Tmpl);
536 
538  virtual void OnPreRehash();
540  virtual void OnPostRehash();
542  virtual void OnIRCDisconnected();
544  virtual void OnIRCConnected();
550  virtual EModRet OnIRCConnecting(CIRCSock* pIRCSock);
555  virtual void OnIRCConnectionError(CIRCSock* pIRCSock);
566  virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick,
567  CString& sIdent, CString& sRealName);
572  virtual EModRet OnBroadcast(CString& sMessage);
573 
585  virtual void OnChanPermission3(const CNick* pOpNick, const CNick& Nick,
586  CChan& Channel, char cMode,
587  bool bAdded, bool bNoChange);
589  virtual void OnChanPermission2(const CNick* pOpNick, const CNick& Nick,
590  CChan& Channel, unsigned char uMode,
591  bool bAdded, bool bNoChange);
593  virtual void OnChanPermission(const CNick& OpNick, const CNick& Nick,
594  CChan& Channel, unsigned char uMode,
595  bool bAdded, bool bNoChange);
597  virtual void OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
598  bool bNoChange);
599  virtual void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel,
600  bool bNoChange);
602  virtual void OnDeop2(const CNick* pOpNick, const CNick& Nick,
603  CChan& Channel, bool bNoChange);
604  virtual void OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel,
605  bool bNoChange);
607  virtual void OnVoice2(const CNick* pOpNick, const CNick& Nick,
608  CChan& Channel, bool bNoChange);
609  virtual void OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
610  bool bNoChange);
612  virtual void OnDevoice2(const CNick* pOpNick, const CNick& Nick,
613  CChan& Channel, bool bNoChange);
614  virtual void OnDevoice(const CNick& OpNick, const CNick& Nick,
615  CChan& Channel, bool bNoChange);
624  virtual void OnMode2(const CNick* pOpNick, CChan& Channel, char uMode,
625  const CString& sArg, bool bAdded, bool bNoChange);
626  virtual void OnMode(const CNick& OpNick, CChan& Channel, char uMode,
627  const CString& sArg, bool bAdded, bool bNoChange);
635  virtual void OnRawMode2(const CNick* pOpNick, CChan& Channel,
636  const CString& sModes, const CString& sArgs);
637  virtual void OnRawMode(const CNick& OpNick, CChan& Channel,
638  const CString& sModes, const CString& sArgs);
639 
645  virtual EModRet OnRaw(CString& sLine);
651  virtual EModRet OnRawMessage(CMessage& Message);
652 
658  virtual EModRet OnNumericMessage(CNumericMessage& Message);
659 
664  virtual EModRet OnStatusCommand(CString& sCommand);
668  virtual void OnModCommand(const CString& sCommand);
675  virtual void OnUnknownModCommand(const CString& sCommand);
679  virtual void OnModNotice(const CString& sMessage);
684  virtual void OnModCTCP(const CString& sMessage);
685 
691  virtual void OnQuitMessage(CQuitMessage& Message,
692  const std::vector<CChan*>& vChans);
694  virtual void OnQuit(const CNick& Nick, const CString& sMessage,
695  const std::vector<CChan*>& vChans);
696 
702  virtual void OnNickMessage(CNickMessage& Message,
703  const std::vector<CChan*>& vChans);
705  virtual void OnNick(const CNick& Nick, const CString& sNewNick,
706  const std::vector<CChan*>& vChans);
707 
712  virtual void OnKickMessage(CKickMessage& Message);
714  virtual void OnKick(const CNick& OpNick, const CString& sKickedNick,
715  CChan& Channel, const CString& sMessage);
716 
721  virtual EModRet OnJoining(CChan& Channel);
722 
727  virtual void OnJoinMessage(CJoinMessage& Message);
729  virtual void OnJoin(const CNick& Nick, CChan& Channel);
730 
735  virtual void OnPartMessage(CPartMessage& Message);
737  virtual void OnPart(const CNick& Nick, CChan& Channel,
738  const CString& sMessage);
739 
746  virtual EModRet OnInvite(const CNick& Nick, const CString& sChan);
747 
753  virtual EModRet OnChanBufferStarting(CChan& Chan, CClient& Client);
759  virtual EModRet OnChanBufferEnding(CChan& Chan, CClient& Client);
760 
766  virtual EModRet OnChanBufferPlayMessage(CMessage& Message);
768  virtual EModRet OnChanBufferPlayLine2(CChan& Chan, CClient& Client,
769  CString& sLine, const timeval& tv);
771  virtual EModRet OnChanBufferPlayLine(CChan& Chan, CClient& Client,
772  CString& sLine);
773 
780  virtual EModRet OnPrivBufferStarting(CQuery& Query, CClient& Client);
787  virtual EModRet OnPrivBufferEnding(CQuery& Query, CClient& Client);
788 
794  virtual EModRet OnPrivBufferPlayMessage(CMessage& Message);
796  virtual EModRet OnPrivBufferPlayLine2(CClient& Client, CString& sLine,
797  const timeval& tv);
799  virtual EModRet OnPrivBufferPlayLine(CClient& Client, CString& sLine);
800 
802  virtual void OnClientLogin();
804  virtual void OnClientDisconnect();
805 
810  virtual EModRet OnUserRaw(CString& sLine);
816  virtual EModRet OnUserRawMessage(CMessage& Message);
817 
823  virtual EModRet OnUserCTCPReplyMessage(CCTCPMessage& Message);
825  virtual EModRet OnUserCTCPReply(CString& sTarget, CString& sMessage);
826 
834  virtual EModRet OnUserCTCPMessage(CCTCPMessage& Message);
836  virtual EModRet OnUserCTCP(CString& sTarget, CString& sMessage);
837 
844  virtual EModRet OnUserActionMessage(CActionMessage& Message);
846  virtual EModRet OnUserAction(CString& sTarget, CString& sMessage);
847 
853  virtual EModRet OnUserTextMessage(CTextMessage& Message);
855  virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage);
856 
862  virtual EModRet OnUserNoticeMessage(CNoticeMessage& Message);
864  virtual EModRet OnUserNotice(CString& sTarget, CString& sMessage);
865 
871  virtual EModRet OnUserJoinMessage(CJoinMessage& Message);
873  virtual EModRet OnUserJoin(CString& sChannel, CString& sKey);
874 
880  virtual EModRet OnUserPartMessage(CPartMessage& Message);
882  virtual EModRet OnUserPart(CString& sChannel, CString& sMessage);
883 
889  virtual EModRet OnUserTopicMessage(CTopicMessage& Message);
891  virtual EModRet OnUserTopic(CString& sChannel, CString& sTopic);
892 
897  virtual EModRet OnUserTopicRequest(CString& sChannel);
898 
904  virtual EModRet OnUserQuitMessage(CQuitMessage& Message);
906  virtual EModRet OnUserQuit(CString& sMessage);
907 
913  virtual EModRet OnCTCPReplyMessage(CCTCPMessage& Message);
915  virtual EModRet OnCTCPReply(CNick& Nick, CString& sMessage);
916 
922  virtual EModRet OnPrivCTCPMessage(CCTCPMessage& Message);
924  virtual EModRet OnPrivCTCP(CNick& Nick, CString& sMessage);
925 
931  virtual EModRet OnChanCTCPMessage(CCTCPMessage& Message);
933  virtual EModRet OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
934 
940  virtual EModRet OnPrivActionMessage(CActionMessage& Message);
942  virtual EModRet OnPrivAction(CNick& Nick, CString& sMessage);
943 
949  virtual EModRet OnChanActionMessage(CActionMessage& Message);
951  virtual EModRet OnChanAction(CNick& Nick, CChan& Channel,
952  CString& sMessage);
953 
959  virtual EModRet OnPrivTextMessage(CTextMessage& Message);
961  virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage);
962 
968  virtual EModRet OnChanTextMessage(CTextMessage& Message);
970  virtual EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
971 
977  virtual EModRet OnPrivNoticeMessage(CNoticeMessage& Message);
979  virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage);
980 
986  virtual EModRet OnChanNoticeMessage(CNoticeMessage& Message);
988  virtual EModRet OnChanNotice(CNick& Nick, CChan& Channel,
989  CString& sMessage);
990 
996  virtual EModRet OnTopicMessage(CTopicMessage& Message);
998  virtual EModRet OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
999 
1005  virtual bool OnServerCapAvailable(const CString& sCap);
1011  virtual void OnServerCapResult(const CString& sCap, bool bSuccess);
1012 
1018  virtual EModRet OnTimerAutoJoin(CChan& Channel);
1019 
1026  virtual EModRet OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1031  virtual EModRet OnDeleteNetwork(CIRCNetwork& Network);
1032 
1039  virtual EModRet OnSendToClientMessage(CMessage& Message);
1041  virtual EModRet OnSendToClient(CString& sLine, CClient& Client);
1042 
1049  virtual EModRet OnSendToIRCMessage(CMessage& Message);
1051  virtual EModRet OnSendToIRC(CString& sLine);
1052 
1053  ModHandle GetDLL() { return m_pDLL; }
1054 
1060  virtual bool PutIRC(const CString& sLine);
1068  virtual bool PutUser(const CString& sLine);
1075  virtual bool PutStatus(const CString& sLine);
1082  virtual bool PutModule(const CString& sLine);
1088  virtual unsigned int PutModule(const CTable& table);
1095  virtual bool PutModNotice(const CString& sLine);
1096 
1098  const CString& GetModName() const { return m_sModName; }
1099 
1103  CString GetModNick() const;
1104 
1109  const CString& GetModDataDir() const { return m_sDataDir; }
1110 
1111  // Timer stuff
1112  bool AddTimer(CTimer* pTimer);
1113  bool AddTimer(FPTimer_t pFBCallback, const CString& sLabel, u_int uInterval,
1114  u_int uCycles = 0, const CString& sDescription = "");
1115  bool RemTimer(CTimer* pTimer);
1116  bool RemTimer(const CString& sLabel);
1117  bool UnlinkTimer(CTimer* pTimer);
1118  CTimer* FindTimer(const CString& sLabel);
1119  std::set<CTimer*>::const_iterator BeginTimers() const {
1120  return m_sTimers.begin();
1121  }
1122  std::set<CTimer*>::const_iterator EndTimers() const {
1123  return m_sTimers.end();
1124  }
1125  virtual void ListTimers();
1126  // !Timer stuff
1127 
1128  // Socket stuff
1129  bool AddSocket(CSocket* pSocket);
1130  bool RemSocket(CSocket* pSocket);
1131  bool RemSocket(const CString& sSockName);
1132  bool UnlinkSocket(CSocket* pSocket);
1133  CSocket* FindSocket(const CString& sSockName);
1134  std::set<CSocket*>::const_iterator BeginSockets() const {
1135  return m_sSockets.begin();
1136  }
1137  std::set<CSocket*>::const_iterator EndSockets() const {
1138  return m_sSockets.end();
1139  }
1140  virtual void ListSockets();
1141 // !Socket stuff
1142 
1143 #ifdef HAVE_PTHREAD
1144  // Job stuff
1145  void AddJob(CModuleJob* pJob);
1146  void CancelJob(CModuleJob* pJob);
1147  bool CancelJob(const CString& sJobName);
1148  void CancelJobs(const std::set<CModuleJob*>& sJobs);
1149  bool UnlinkJob(CModuleJob* pJob);
1150 // !Job stuff
1151 #endif
1152 
1153  // Command stuff
1155  void AddHelpCommand();
1157  bool AddCommand(const CModCommand& Command);
1160  bool AddCommand(const CString& sCmd, CModCommand::ModCmdFunc func,
1161  const CString& sArgs = "", const CString& sDesc = "");
1164  bool AddCommand(const CString& sCmd, const COptionalTranslation& Args,
1165  const COptionalTranslation& Desc,
1166  std::function<void(const CString& sLine)> func);
1168  bool RemCommand(const CString& sCmd);
1170  const CModCommand* FindCommand(const CString& sCmd) const;
1178  bool HandleCommand(const CString& sLine);
1182  void HandleHelpCommand(const CString& sLine = "");
1183  // !Command stuff
1184 
1185  bool LoadRegistry();
1186  bool SaveRegistry() const;
1187  bool MoveRegistry(const CString& sPath);
1188  bool SetNV(const CString& sName, const CString& sValue,
1189  bool bWriteToDisk = true);
1190  CString GetNV(const CString& sName) const;
1191  bool HasNV(const CString& sName) const {
1192  return m_mssRegistry.find(sName) != m_mssRegistry.end();
1193  }
1194  bool DelNV(const CString& sName, bool bWriteToDisk = true);
1195  MCString::iterator FindNV(const CString& sName) {
1196  return m_mssRegistry.find(sName);
1197  }
1198  MCString::iterator EndNV() { return m_mssRegistry.end(); }
1199  MCString::iterator BeginNV() { return m_mssRegistry.begin(); }
1200  void DelNV(MCString::iterator it) { m_mssRegistry.erase(it); }
1201  bool ClearNV(bool bWriteToDisk = true);
1202 
1203  const CString& GetSavePath() const;
1204  CString ExpandString(const CString& sStr) const;
1205  CString& ExpandString(const CString& sStr, CString& sRet) const;
1206 
1207  // Setters
1208  void SetType(CModInfo::EModuleType eType) { m_eType = eType; }
1209  void SetDescription(const CString& s) { m_sDescription = s; }
1210  void SetModPath(const CString& s) { m_sModPath = s; }
1211  void SetArgs(const CString& s) { m_sArgs = s; }
1212  // !Setters
1213 
1214  // Getters
1216  const CString& GetDescription() const { return m_sDescription; }
1217  const CString& GetArgs() const { return m_sArgs; }
1218  const CString& GetModPath() const { return m_sModPath; }
1219 
1225  CUser* GetUser() const { return m_pUser; }
1229  CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1233  CClient* GetClient() const { return m_pClient; }
1234  CSockManager* GetManager() const { return m_pManager; }
1235  // !Getters
1236 
1237  // Global Modules
1244  virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
1249  virtual EModRet OnDeleteUser(CUser& User);
1256  virtual void OnClientConnect(CZNCSock* pSock, const CString& sHost,
1257  unsigned short uPort);
1264  virtual EModRet OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1269  virtual void OnFailedLogin(const CString& sUsername,
1270  const CString& sRemoteIP);
1277  virtual EModRet OnUnknownUserRaw(CClient* pClient, CString& sLine);
1278  virtual EModRet OnUnknownUserRawMessage(CMessage& Message);
1279 
1285  virtual void OnClientCapLs(CClient* pClient, SCString& ssCaps);
1292  virtual bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1293  bool bState);
1303  virtual void OnClientCapRequest(CClient* pClient, const CString& sCap,
1304  bool bState);
1305 
1315  virtual EModRet OnModuleLoading(const CString& sModName,
1316  const CString& sArgs,
1317  CModInfo::EModuleType eType, bool& bSuccess,
1318  CString& sRetMsg);
1326  virtual EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess,
1327  CString& sRetMsg);
1335  virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
1336  bool& bSuccess, CString& sRetMsg);
1341  virtual void OnGetAvailableMods(std::set<CModInfo>& ssMods,
1342  CModInfo::EModuleType eType);
1343  // !Global Modules
1344 
1345 #ifndef SWIG
1346  // Translation
1347  CString t_s(const CString& sEnglish, const CString& sContext = "") const;
1348  CInlineFormatMessage t_f(const CString& sEnglish,
1349  const CString& sContext = "") const;
1350  CInlineFormatMessage t_p(const CString& sEnglish, const CString& sEnglishes,
1351  int iNum, const CString& sContext = "") const;
1352  CDelayedTranslation t_d(const CString& sEnglish,
1353  const CString& sContext = "") const;
1354 #endif
1355 
1356  protected:
1359  std::set<CTimer*> m_sTimers;
1360  std::set<CSocket*> m_sSockets;
1361 #ifdef HAVE_PTHREAD
1362  std::set<CModuleJob*> m_sJobs;
1363 #endif
1375 
1376  private:
1377  MCString
1378  m_mssRegistry;
1379  VWebSubPages m_vSubPages;
1380  std::map<CString, CModCommand> m_mCommands;
1381 };
1382 
1383 class CModules : public std::vector<CModule*> {
1384  public:
1385  CModules();
1386  ~CModules();
1387 
1388  CModules(const CModules&) = default;
1389  CModules& operator=(const CModules&) = default;
1390 
1391  void SetUser(CUser* pUser) { m_pUser = pUser; }
1392  void SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
1393  void SetClient(CClient* pClient) { m_pClient = pClient; }
1394  CUser* GetUser() const { return m_pUser; }
1395  CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1396  CClient* GetClient() const { return m_pClient; }
1397 
1398  void UnloadAll();
1399 
1400  bool OnBoot();
1401  bool OnPreRehash();
1402  bool OnPostRehash();
1403  bool OnIRCDisconnected();
1404  bool OnIRCConnected();
1405  bool OnIRCConnecting(CIRCSock* pIRCSock);
1406  bool OnIRCConnectionError(CIRCSock* pIRCSock);
1407  bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent,
1408  CString& sRealName);
1409  bool OnBroadcast(CString& sMessage);
1410 
1411  bool OnChanPermission3(const CNick* pOpNick, const CNick& Nick,
1412  CChan& Channel, char cMode, bool bAdded,
1413  bool bNoChange);
1414  bool OnChanPermission2(const CNick* pOpNick, const CNick& Nick,
1415  CChan& Channel, unsigned char uMode, bool bAdded,
1416  bool bNoChange);
1417  bool OnChanPermission(const CNick& OpNick, const CNick& Nick,
1418  CChan& Channel, unsigned char uMode, bool bAdded,
1419  bool bNoChange);
1420  bool OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1421  bool bNoChange);
1422  bool OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1423  bool bNoChange);
1424  bool OnDeop2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1425  bool bNoChange);
1426  bool OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1427  bool bNoChange);
1428  bool OnVoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1429  bool bNoChange);
1430  bool OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1431  bool bNoChange);
1432  bool OnDevoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1433  bool bNoChange);
1434  bool OnDevoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1435  bool bNoChange);
1436  bool OnRawMode2(const CNick* pOpNick, CChan& Channel, const CString& sModes,
1437  const CString& sArgs);
1438  bool OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes,
1439  const CString& sArgs);
1440  bool OnMode2(const CNick* pOpNick, CChan& Channel, char uMode,
1441  const CString& sArg, bool bAdded, bool bNoChange);
1442  bool OnMode(const CNick& OpNick, CChan& Channel, char uMode,
1443  const CString& sArg, bool bAdded, bool bNoChange);
1444 
1445  bool OnRaw(CString& sLine);
1446  bool OnRawMessage(CMessage& Message);
1447  bool OnNumericMessage(CNumericMessage& Message);
1448 
1449  bool OnStatusCommand(CString& sCommand);
1450  bool OnModCommand(const CString& sCommand);
1451  bool OnModNotice(const CString& sMessage);
1452  bool OnModCTCP(const CString& sMessage);
1453 
1454  bool OnQuit(const CNick& Nick, const CString& sMessage,
1455  const std::vector<CChan*>& vChans);
1456  bool OnQuitMessage(CQuitMessage& Message,
1457  const std::vector<CChan*>& vChans);
1458  bool OnNick(const CNick& Nick, const CString& sNewNick,
1459  const std::vector<CChan*>& vChans);
1460  bool OnNickMessage(CNickMessage& Message,
1461  const std::vector<CChan*>& vChans);
1462  bool OnKick(const CNick& Nick, const CString& sOpNick, CChan& Channel,
1463  const CString& sMessage);
1464  bool OnKickMessage(CKickMessage& Message);
1465  bool OnJoining(CChan& Channel);
1466  bool OnJoin(const CNick& Nick, CChan& Channel);
1467  bool OnJoinMessage(CJoinMessage& Message);
1468  bool OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage);
1469  bool OnPartMessage(CPartMessage& Message);
1470  bool OnInvite(const CNick& Nick, const CString& sChan);
1471 
1472  bool OnChanBufferStarting(CChan& Chan, CClient& Client);
1473  bool OnChanBufferEnding(CChan& Chan, CClient& Client);
1474  bool OnChanBufferPlayLine2(CChan& Chan, CClient& Client, CString& sLine,
1475  const timeval& tv);
1476  bool OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
1477  bool OnPrivBufferStarting(CQuery& Query, CClient& Client);
1478  bool OnPrivBufferEnding(CQuery& Query, CClient& Client);
1479  bool OnPrivBufferPlayLine2(CClient& Client, CString& sLine,
1480  const timeval& tv);
1481  bool OnPrivBufferPlayLine(CClient& Client, CString& sLine);
1482  bool OnChanBufferPlayMessage(CMessage& Message);
1483  bool OnPrivBufferPlayMessage(CMessage& Message);
1484 
1485  bool OnClientLogin();
1486  bool OnClientDisconnect();
1487  bool OnUserRaw(CString& sLine);
1488  bool OnUserRawMessage(CMessage& Message);
1489  bool OnUserCTCPReply(CString& sTarget, CString& sMessage);
1490  bool OnUserCTCPReplyMessage(CCTCPMessage& Message);
1491  bool OnUserCTCP(CString& sTarget, CString& sMessage);
1492  bool OnUserCTCPMessage(CCTCPMessage& Message);
1493  bool OnUserAction(CString& sTarget, CString& sMessage);
1494  bool OnUserActionMessage(CActionMessage& Message);
1495  bool OnUserMsg(CString& sTarget, CString& sMessage);
1496  bool OnUserTextMessage(CTextMessage& Message);
1497  bool OnUserNotice(CString& sTarget, CString& sMessage);
1498  bool OnUserNoticeMessage(CNoticeMessage& Message);
1499  bool OnUserJoin(CString& sChannel, CString& sKey);
1500  bool OnUserJoinMessage(CJoinMessage& Message);
1501  bool OnUserPart(CString& sChannel, CString& sMessage);
1502  bool OnUserPartMessage(CPartMessage& Message);
1503  bool OnUserTopic(CString& sChannel, CString& sTopic);
1504  bool OnUserTopicMessage(CTopicMessage& Message);
1505  bool OnUserTopicRequest(CString& sChannel);
1506  bool OnUserQuit(CString& sMessage);
1507  bool OnUserQuitMessage(CQuitMessage& Message);
1508 
1509  bool OnCTCPReply(CNick& Nick, CString& sMessage);
1510  bool OnCTCPReplyMessage(CCTCPMessage& Message);
1511  bool OnPrivCTCP(CNick& Nick, CString& sMessage);
1512  bool OnPrivCTCPMessage(CCTCPMessage& Message);
1513  bool OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
1514  bool OnChanCTCPMessage(CCTCPMessage& Message);
1515  bool OnPrivAction(CNick& Nick, CString& sMessage);
1516  bool OnPrivActionMessage(CActionMessage& Message);
1517  bool OnChanAction(CNick& Nick, CChan& Channel, CString& sMessage);
1518  bool OnChanActionMessage(CActionMessage& Message);
1519  bool OnPrivMsg(CNick& Nick, CString& sMessage);
1520  bool OnPrivTextMessage(CTextMessage& Message);
1521  bool OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
1522  bool OnChanTextMessage(CTextMessage& Message);
1523  bool OnPrivNotice(CNick& Nick, CString& sMessage);
1524  bool OnPrivNoticeMessage(CNoticeMessage& Message);
1525  bool OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage);
1526  bool OnChanNoticeMessage(CNoticeMessage& Message);
1527  bool OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
1528  bool OnTopicMessage(CTopicMessage& Message);
1529  bool OnTimerAutoJoin(CChan& Channel);
1530 
1531  bool OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1532  bool OnDeleteNetwork(CIRCNetwork& Network);
1533 
1534  bool OnSendToClient(CString& sLine, CClient& Client);
1535  bool OnSendToClientMessage(CMessage& Message);
1536  bool OnSendToIRC(CString& sLine);
1537  bool OnSendToIRCMessage(CMessage& Message);
1538 
1539  bool OnServerCapAvailable(const CString& sCap);
1540  bool OnServerCapResult(const CString& sCap, bool bSuccess);
1541 
1542  CModule* FindModule(const CString& sModule) const;
1543  bool LoadModule(const CString& sModule, const CString& sArgs,
1544  CModInfo::EModuleType eType, CUser* pUser,
1545  CIRCNetwork* pNetwork, CString& sRetMsg);
1546  bool UnloadModule(const CString& sModule);
1547  bool UnloadModule(const CString& sModule, CString& sRetMsg);
1548  bool ReloadModule(const CString& sModule, const CString& sArgs,
1549  CUser* pUser, CIRCNetwork* pNetwork, CString& sRetMsg);
1550 
1551  static bool GetModInfo(CModInfo& ModInfo, const CString& sModule,
1552  CString& sRetMsg);
1553  static bool GetModPathInfo(CModInfo& ModInfo, const CString& sModule,
1554  const CString& sModPath, CString& sRetMsg);
1555  static void GetAvailableMods(
1556  std::set<CModInfo>& ssMods,
1558  static void GetDefaultMods(
1559  std::set<CModInfo>& ssMods,
1561 
1562  // This returns the path to the .so and to the data dir
1563  // which is where static data (webadmin skins) are saved
1564  static bool FindModPath(const CString& sModule, CString& sModPath,
1565  CString& sDataPath);
1566  // Return a list of <module dir, data dir> pairs for directories in
1567  // which modules can be found.
1568  typedef std::queue<std::pair<CString, CString>> ModDirList;
1569  static ModDirList GetModDirs();
1570 
1571  // Global Modules
1572  bool OnAddUser(CUser& User, CString& sErrorRet);
1573  bool OnDeleteUser(CUser& User);
1574  bool OnClientConnect(CZNCSock* pSock, const CString& sHost,
1575  unsigned short uPort);
1576  bool OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1577  bool OnFailedLogin(const CString& sUsername, const CString& sRemoteIP);
1578  bool OnUnknownUserRaw(CClient* pClient, CString& sLine);
1579  bool OnUnknownUserRawMessage(CMessage& Message);
1580  bool OnClientCapLs(CClient* pClient, SCString& ssCaps);
1581  bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1582  bool bState);
1583  bool OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState);
1584  bool OnModuleLoading(const CString& sModName, const CString& sArgs,
1585  CModInfo::EModuleType eType, bool& bSuccess,
1586  CString& sRetMsg);
1587  bool OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
1588  bool OnGetModInfo(CModInfo& ModInfo, const CString& sModule, bool& bSuccess,
1589  CString& sRetMsg);
1590  bool OnGetAvailableMods(std::set<CModInfo>& ssMods,
1591  CModInfo::EModuleType eType);
1592  // !Global Modules
1593 
1594  private:
1595  static ModHandle OpenModule(const CString& sModule, const CString& sModPath,
1596  CModInfo& Info, CString& sRetMsg);
1597 
1598  protected:
1602 };
1603 
1604 #endif // !ZNC_MODULES_H
virtual EModRet OnAddUser(CUser &User, CString &sErrorRet)
This module hook is called when a user is being added.
Definition: Message.h:266
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:341
void(* FPTimer_t)(CModule *, CFPTimer *)
Definition: Modules.h:194
bool UnlinkSocket(CSocket *pSocket)
Definition: Message.h:308
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:1211
virtual EModRet OnChanActionMessage(CActionMessage &Message)
Called when we receive a channel CTCP ACTION ("/me" in a channel) from IRC.
virtual EModRet OnUserCTCP(CString &sTarget, CString &sMessage)
Definition: User.h:37
CModInfo()
Definition: Modules.h:254
bool OnBoot()
bool OnPrivNoticeMessage(CNoticeMessage &Message)
CModule(ModHandle pDLL, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sDataDir, CModInfo::EModuleType eType=CModInfo::NetworkModule)
virtual EModRet OnPrivNoticeMessage(CNoticeMessage &Message)
Called when we receive a private NOTICE message from IRC.
virtual EModRet OnChanCTCPMessage(CCTCPMessage &Message)
Called when we receive a channel CTCP request from IRC.
bool OnChanAction(CNick &Nick, CChan &Channel, CString &sMessage)
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.
bool OnChanNoticeMessage(CNoticeMessage &Message)
static bool GetModPathInfo(CModInfo &ModInfo, const CString &sModule, const CString &sModPath, CString &sRetMsg)
virtual EModRet OnTopic(CNick &Nick, CChan &Channel, CString &sTopic)
bool OnUserRawMessage(CMessage &Message)
bool OnAddNetwork(CIRCNetwork &Network, CString &sErrorRet)
const CString & GetArgs() const
Definition: Modules.h:1217
void SetHasArgs(bool b=false)
Definition: Modules.h:307
CModCommand & operator=(const CModCommand &other)=default
Assignment operator, needed so that this can be saved in a std::map.
static void InitHelp(CTable &Table)
Initialize a CTable so that it can be used with AddHelp().
virtual ~CModule()
bool UnlinkJob(CModuleJob *pJob)
CModule * GetModule() const
virtual CString GetWebPath()
CString m_sDescription
Definition: Modules.h:191
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.
bool AddSocket(CSocket *pSocket)
const char * pcVersionExtra
Definition: Modules.h:82
bool OnPrivBufferPlayLine(CClient &Client, CString &sLine)
void SetNetwork(CIRCNetwork *pNetwork)
Definition: Modules.h:1392
bool OnDeop(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnIRCConnecting(CIRCSock *pIRCSock)
virtual EModRet OnUserQuit(CString &sMessage)
CString GetNV(const CString &sName) const
virtual EModRet OnChanNoticeMessage(CNoticeMessage &Message)
Called when we receive a channel NOTICE message from IRC.
CInlineFormatMessage t_p(const CString &sEnglish, const CString &sEnglishes, int iNum, const CString &sContext="") const
CModInfo(const CString &sName, const CString &sPath, EModuleType eType)
Definition: Modules.h:255
virtual void OnModNotice(const CString &sMessage)
Called when a your module nick was sent a notice.
bool OnUserActionMessage(CActionMessage &Message)
CString m_sSavePath
Definition: Modules.h:1371
ZNC will continue event processing normally.
Definition: Modules.h:427
A job is a task which should run without blocking the main thread.
Definition: Threads.h:67
bool GetHasArgs() const
Definition: Modules.h:296
virtual EModRet OnUnknownUserRaw(CClient *pClient, CString &sLine)
This function behaves like CModule::OnUserRaw(), but is also called before the client successfully lo...
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:317
virtual EModRet OnChanNotice(CNick &Nick, CChan &Channel, CString &sMessage)
virtual void OnNickMessage(CNickMessage &Message, const std::vector< CChan * > &vChans)
Called when a nickname change occurs.
EModuleType
Definition: Modules.h:247
virtual void OnUnknownModCommand(const CString &sCommand)
This is similar to OnModCommand(), but it is only called if HandleCommand didn't find any that wants ...
A CJob version which can be safely used in modules.
Definition: Modules.h:221
virtual bool PutUser(const CString &sLine)
This function sends a given raw IRC line to a client.
void SetUser(CUser *pUser)
Definition: Modules.h:1391
bool OnIRCConnected()
virtual void OnDeop(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CModuleJob & operator=(const CModuleJob &)=delete
virtual EModRet OnTopicMessage(CTopicMessage &Message)
Called when we receive a channel topic change from IRC.
CString m_sWikiPage
Definition: Modules.h:321
virtual EModRet OnUserCTCPReplyMessage(CCTCPMessage &Message)
This module hook is called when a client sends a CTCP reply.
bool OnGetModInfo(CModInfo &ModInfo, const CString &sModule, bool &bSuccess, CString &sRetMsg)
virtual EModRet OnPrivBufferPlayMessage(CMessage &Message)
Called for each message during a query's buffer play back.
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:1568
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 "Help" command.
MCString::iterator FindNV(const CString &sName)
Definition: Modules.h:1195
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)
bool HasNV(const CString &sName) const
Definition: Modules.h:1191
virtual EModRet OnUserActionMessage(CActionMessage &Message)
Called when a client sends a CTCP ACTION request ("/me").
void SetModPath(const CString &s)
Definition: Modules.h:1210
std::function< void(const CString &sLine)> CmdFunc
Definition: Modules.h:342
bool OnTopicMessage(CTopicMessage &Message)
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's in the conf...
void SetFPCallback(FPTimer_t p)
Definition: Modules.h:205
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:1359
Definition: Client.h:99
bool OnQuitMessage(CQuitMessage &Message, const std::vector< CChan * > &vChans)
bool OnPrivCTCP(CNick &Nick, CString &sMessage)
CModInfo::EModuleType GetType() const
Definition: Modules.h:1215
bool LoadRegistry()
bool OnUserRaw(CString &sLine)
const CString m_sDescription
Definition: Modules.h:239
CSockManager * GetManager() const
Definition: Modules.h:1234
bool OnUserTopicMessage(CTopicMessage &Message)
bool OnNumericMessage(CNumericMessage &Message)
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:1134
bool MoveRegistry(const CString &sPath)
bool OnPreRehash()
bool OnClientDisconnect()
Definition: Message.h:283
bool OnKickMessage(CKickMessage &Message)
Definition: Message.h:259
void SetModule(CModule *p)
bool OnClientCapLs(CClient *pClient, SCString &ssCaps)
CmdFunc GetFunction() const
Definition: Modules.h:381
virtual void OnPartMessage(CPartMessage &Message)
Called when a nick parts a channel.
CSockManager * m_pManager
Definition: Modules.h:1365
bool OnPrivActionMessage(CActionMessage &Message)
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:431
std::set< CSocket * > m_sSockets
Definition: Modules.h:1360
CModule * FindModule(const CString &sModule) const
bool OnUserTextMessage(CTextMessage &Message)
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)
bool OnUserQuitMessage(CQuitMessage &Message)
std::set< CModuleJob * > m_sJobs
Definition: Modules.h:1362
CClient * GetClient() const
Definition: Modules.h:1233
virtual EModRet OnUserCTCPMessage(CCTCPMessage &Message)
This module hook is called when a client sends a CTCP request.
CString m_sArgsHelpText
Definition: Modules.h:322
CString t_s(const CString &sEnglish, const CString &sContext="") const
Definition: Modules.h:1383
bool OnUserJoinMessage(CJoinMessage &Message)
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:1209
CClient * m_pClient
Definition: Modules.h:1368
C-style entry point to the module.
Definition: Modules.h:80
CModule & operator=(const CModule &)=delete
Definition: Nick.h:29
virtual EModRet OnUserNotice(CString &sTarget, CString &sMessage)
virtual void OnDevoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
void SetPath(const CString &s)
Definition: Modules.h:303
Definition: Socket.h:75
virtual void OnClientLogin()
Called when a client successfully logged in to ZNC.
bool OnPrivMsg(CNick &Nick, CString &sMessage)
bool OnNickMessage(CNickMessage &Message, const std::vector< CChan * > &vChans)
bool ClearNV(bool bWriteToDisk=true)
Definition: Translation.h:84
const CString & GetCommand() const
Definition: Modules.h:380
bool OnSendToClientMessage(CMessage &Message)
bool m_bHasArgs
Definition: Modules.h:323
CString Resolve() const
Definition: Translation.h:91
void AddJob(CModuleJob *pJob)
CUser * GetUser() const
Definition: Modules.h:1225
std::vector< TWebSubPage > VWebSubPages
Definition: WebModules.h:33
virtual EModRet OnPrivBufferStarting(CQuery &Query, CClient &Client)
Called before a query buffer is played back to a client.
virtual void OnKick(const CNick &OpNick, const CString &sKickedNick, CChan &Channel, const CString &sMessage)
CTranslationDomainRefHolder m_Translation
Definition: Modules.h:1374
std::set< CString > SCString
Definition: ZNCString.h:35
Definition: Modules.h:247
virtual EModRet OnGetModInfo(CModInfo &ModInfo, const CString &sModule, bool &bSuccess, CString &sRetMsg)
Called when info about a module is needed.
virtual EModRet OnUserJoinMessage(CJoinMessage &Message)
This hooks is called when a user sends a JOIN message.
CClient * m_pClient
Definition: Modules.h:1601
void SetClient(CClient *pClient)
const CString & GetPath() const
Definition: Modules.h:292
bool OnIRCConnectionError(CIRCSock *pIRCSock)
std::set< EModuleType > m_seType
Definition: Modules.h:316
Definition: Socket.h:27
bool OnRawMessage(CMessage &Message)
EModuleType GetDefaultType() const
Definition: Modules.h:298
void RunJob() override
this is the method you should override
Definition: Modules.h:208
bool OnPrivCTCPMessage(CCTCPMessage &Message)
Base Csock implementation to be used by modules.
Definition: Socket.h:242
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)
CString GetDescription() const
Definition: Modules.h:383
Definition: Modules.h:196
Definition: Message.h:228
CInlineFormatMessage t_f(const CString &sEnglish, const CString &sContext="") const
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.
bool OnChanBufferPlayLine2(CChan &Chan, CClient &Client, CString &sLine, const timeval &tv)
Definition: Modules.h:169
bool SaveRegistry() const
void SetLoader(ModLoader fLoader)
Definition: Modules.h:308
virtual EModRet OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
const CString & GetModPath() const
Definition: Modules.h:1218
bool AddCommand(const CModCommand &Command)
virtual ~CTimer()
virtual EModRet OnUserAction(CString &sTarget, CString &sMessage)
virtual EModRet OnUnknownUserRawMessage(CMessage &Message)
bool OnRawMode(const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
virtual EModRet OnSendToClientMessage(CMessage &Message)
Called immediately before ZNC sends a raw traffic line to a client.
virtual void OnDevoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is devoiced on a channel.
void CancelJobs(const std::set< CModuleJob * > &sJobs)
void * ModHandle
Definition: Modules.h:243
bool AddTimer(CTimer *pTimer)
bool OnIRCRegistration(CString &sPass, CString &sNick, CString &sIdent, CString &sRealName)
CModule * GetModule() const
Definition: Modules.h:231
virtual EModRet OnUserTopicRequest(CString &sChannel)
This hook is called when a user requests a channel's topic.
Definition: Message.h:292
virtual EModRet OnPrivCTCP(CNick &Nick, CString &sMessage)
bool OnSendToIRCMessage(CMessage &Message)
virtual bool PutModule(const CString &sLine)
This function sends a query from your module nick.
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:38
Definition: Message.h:217
bool OnPrivBufferPlayMessage(CMessage &Message)
Definition: Translation.h:70
bool OnTimerAutoJoin(CChan &Channel)
std::shared_ptr< CWebSubPage > TWebSubPage
Definition: WebModules.h:30
Definition: Template.h:129
bool OnChanPermission3(const CNick *pOpNick, const CNick &Nick, CChan &Channel, char cMode, bool bAdded, bool bNoChange)
bool OnModNotice(const CString &sMessage)
virtual EModRet OnUserPart(CString &sChannel, CString &sMessage)
virtual bool IsClientCapSupported(CClient *pClient, const CString &sCap, bool bState)
Called only to check if your module supports turning on/off named capability.
CIRCNetwork * GetNetwork() const
Definition: Modules.h:1395
Definition: Translation.h:61
Definition: IRCNetwork.h:40
virtual bool WebRequiresLogin()
Modules which can only be used with an active user session have to return true here.
Definition: Modules.h:474
bool OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
bool OnVoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
EModException
Definition: Modules.h:443
bool OnChanActionMessage(CActionMessage &Message)
bool OnUserCTCPMessage(CCTCPMessage &Message)
const char * pcVersion
Definition: Modules.h:81
const CString & GetWikiPage() const
Definition: Modules.h:294
bool LoadModule(const CString &sModule, const CString &sArgs, CModInfo::EModuleType eType, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
~CModInfo()
Definition: Modules.h:265
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:302
CUser * m_pUser
Definition: Modules.h:1599
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:203
String class that is used inside ZNC.
Definition: ZNCString.h:68
virtual EModRet OnBroadcast(CString &sMessage)
This module hook is called when a message is broadcasted to all users.
CModules & operator=(const CModules &)=default
static void GetDefaultMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType=CModInfo::UserModule)
bool OnDeop2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual EModRet OnSendToIRC(CString &sLine)
virtual void OnRawMode(const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
Continue calling other modules.
Definition: Modules.h:440
virtual bool OnServerCapAvailable(const CString &sCap)
Called for every CAP received via CAP LS from server.
bool OnPrivBufferStarting(CQuery &Query, CClient &Client)
virtual EModRet OnSendToClient(CString &sLine, CClient &Client)
CTimer & operator=(const CTimer &)=delete
virtual void OnPart(const CNick &Nick, CChan &Channel, const CString &sMessage)
bool OnJoin(const CNick &Nick, CChan &Channel)
virtual EModRet OnUserRawMessage(CMessage &Message)
This module hook is called when a client sends any message to ZNC.
void Unload()
This function throws CModule::UNLOAD which causes this module to be unloaded.
Definition: Modules.h:456
virtual EModRet OnUserPartMessage(CPartMessage &Message)
This hooks is called when a user sends a PART message.
virtual void OnGetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType)
Called when list of available mods is requested.
bool OnUserQuit(CString &sMessage)
const CString & GetName() const
Definition: Modules.h:232
EModRet
This enum is just used for return from module hooks.
Definition: Modules.h:423
Definition: Modules.h:247
void DelNV(MCString::iterator it)
Definition: Modules.h:1200
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)...
const CString & GetDescription() const
Definition: Modules.h:233
bool OnUnknownUserRaw(CClient *pClient, CString &sLine)
CString GetModNick() const
virtual bool PutStatus(const CString &sLine)
This function generates a query from *status.
bool OnPrivNotice(CNick &Nick, CString &sMessage)
CString t_s(const CString &sEnglish, const CString &sContext="") const
Definition: Modules.h:245
bool OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
static CString ModuleTypeToString(EModuleType eType)
Definition: Modules.h:277
The base class for your own ZNC modules.
Definition: Modules.h:407
bool OnStatusCommand(CString &sCommand)
bool OnUserNotice(CString &sTarget, CString &sMessage)
CModInfo::EModuleType m_eType
Definition: Modules.h:1357
virtual EModRet OnUserJoin(CString &sChannel, CString &sKey)
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:1098
virtual ~CModuleJob()
virtual EModRet OnChanAction(CNick &Nick, CChan &Channel, CString &sMessage)
CUser * m_pUser
Definition: Modules.h:1366
bool RemTimer(CTimer *pTimer)
virtual EModRet OnModuleUnloading(CModule *pModule, bool &bSuccess, CString &sRetMsg)
Called when a module is going to be unloaded.
CUser * GetUser() const
Definition: Modules.h:1394
bool OnPart(const CNick &Nick, CChan &Channel, const CString &sMessage)
virtual EModRet OnSendToIRCMessage(CMessage &Message)
Called immediately before ZNC sends a raw traffic line to the IRC server.
void SetDescription(const CString &s)
Definition: Modules.h:304
virtual CString GetWebFilesPath()
void AddType(EModuleType eType)
Definition: Modules.h:275
virtual void ListTimers()
virtual void OnVoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
MCString::iterator EndNV()
Definition: Modules.h:1198
bool OnChanBufferPlayMessage(CMessage &Message)
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.
void CancelJob(CModuleJob *pJob)
CModule * TModLoad(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, CModInfo::EModuleType eType)
Definition: Modules.h:331
virtual EModRet OnPrivTextMessage(CTextMessage &Message)
Called when we receive a private PRIVMSG message from IRC.
bool OnPrivTextMessage(CTextMessage &Message)
void TModInfo(CModInfo &Info)
Definition: Modules.h:328
bool OnUserNoticeMessage(CNoticeMessage &Message)
virtual EModRet OnCTCPReplyMessage(CCTCPMessage &Message)
Called when we receive a CTCP reply from IRC.
Definition: WebModules.h:127
const CString & GetArgsHelpText() const
Definition: Modules.h:295
void SetType(CModInfo::EModuleType eType)
Definition: Modules.h:1208
virtual EModRet OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
bool OnIRCDisconnected()
this is the main cron job class
Definition: Csocket.h:393
bool OnChanTextMessage(CTextMessage &Message)
bool OnCTCPReply(CNick &Nick, CString &sMessage)
virtual void ListSockets()
virtual VWebSubPages & GetSubPages()
Returns a list of all registered SubPages.
Definition: Modules.h:523
virtual EModRet OnChanBufferEnding(CChan &Chan, CClient &Client)
Called after a channel buffer was played back to a client.
Definition: Client.h:38
bool OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan * > &vChans)
bool OnUserCTCPReply(CString &sTarget, CString &sMessage)
bool OnChanCTCPMessage(CCTCPMessage &Message)
virtual EModRet OnChanBufferPlayLine2(CChan &Chan, CClient &Client, CString &sLine, const timeval &tv)
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.
CModule * m_pModule
Definition: Modules.h:237
virtual EModRet OnCTCPReply(CNick &Nick, CString &sMessage)
virtual EModRet OnChanTextMessage(CTextMessage &Message)
Called when we receive a channel PRIVMSG message from IRC.
Definition: Modules.h:247
virtual EModRet OnUserMsg(CString &sTarget, CString &sMessage)
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)
bool OnCTCPReplyMessage(CCTCPMessage &Message)
virtual EModRet OnChanBufferPlayMessage(CMessage &Message)
Called for each message during a channel's buffer play back.
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:293
void SetWikiPage(const CString &s)
Definition: Modules.h:305
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:1372
Definition: Message.h:301
CString m_sModPath
Definition: Modules.h:1373
virtual void OnMode(const CNick &OpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
bool OnUserCTCPReplyMessage(CCTCPMessage &Message)
virtual EModRet OnNumericMessage(CNumericMessage &Message)
Called when a numeric message is received from the IRC server.
CString m_sDataDir
Definition: Modules.h:1370
CString m_sName
Definition: Modules.h:318
bool operator<(const CModInfo &Info) const
Definition: Modules.h:267
A dictionary for strings.
Definition: ZNCString.h:595
bool OnModCommand(const CString &sCommand)
bool OnUserMsg(CString &sTarget, CString &sMessage)
void SetArgsHelpText(const CString &s)
Definition: Modules.h:306
bool OnPostRehash()
bool OnDevoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual void OnPreRehash()
Called just before znc.conf is rehashed.
CString GetArgs() const
Definition: Modules.h:382
bool OnDevoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Definition: Message.h:251
CModuleJob(CModule *pModule, const CString &sName, const CString &sDesc)
Definition: Modules.h:223
bool OnUserTopicRequest(CString &sChannel)
bool RemCommand(const CString &sCmd)
virtual EModRet OnUserCTCPReply(CString &sTarget, CString &sMessage)
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:1122
virtual void OnKickMessage(CKickMessage &Message)
Called when a nick is kicked from a channel.
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)
void(* fpFillModInfo)(CModInfo &)
Definition: Modules.h:84
bool OnUserPartMessage(CPartMessage &Message)
bool OnClientCapRequest(CClient *pClient, const CString &sCap, bool bState)
CIRCNetwork * m_pNetwork
Definition: Modules.h:1367
const CString & GetDescription() const
Definition: Modules.h:1216
CString m_sModName
Definition: Modules.h:1369
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:1053
bool OnUnknownUserRawMessage(CMessage &Message)
bool OnRawMode2(const CNick *pOpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
ModLoader GetLoader() const
Definition: Modules.h:297
CIRCNetwork * GetNetwork() const
Definition: Modules.h:1229
const CString & GetName() const
Definition: Modules.h:291
std::set< CTimer * >::const_iterator BeginTimers() const
Definition: Modules.h:1119
bool OnPartMessage(CPartMessage &Message)
bool OnLoginAttempt(std::shared_ptr< CAuthBase > Auth)
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.
virtual EModRet OnUserQuitMessage(CQuitMessage &Message)
This module hook is called when a client quits ZNC.
CFPTimer(CModule *pModule, unsigned int uInterval, unsigned int uCycles, const CString &sLabel, const CString &sDescription)
Definition: Modules.h:198
bool OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
bool OnPrivBufferPlayLine2(CClient &Client, CString &sLine, const timeval &tv)
virtual void AddSubPage(TWebSubPage spSubPage)
Registers a sub page for the sidebar.
Definition: Modules.h:514
virtual void OnNick(const CNick &Nick, const CString &sNewNick, const std::vector< CChan * > &vChans)
CClient * GetClient() const
Definition: Modules.h:1396
virtual EModRet OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
CString m_sPath
Definition: Modules.h:319
bool OnUserCTCP(CString &sTarget, CString &sMessage)
virtual void ClearSubPages()
Removes all registered (AddSubPage'd) SubPages.
Definition: Modules.h:519
void Call(const CString &sLine) const
Definition: Modules.h:385
virtual EModRet OnLoginAttempt(std::shared_ptr< CAuthBase > Auth)
This module hook is called when a client tries to login.
bool OnUserAction(CString &sTarget, CString &sMessage)
const CString & GetDescription() const
bool OnDeleteUser(CUser &User)
bool OnChanBufferStarting(CChan &Chan, CClient &Client)
MCString::iterator BeginNV()
Definition: Modules.h:1199
ModHandle m_pDLL
Definition: Modules.h:1364
virtual void OnJoinMessage(CJoinMessage &Message)
Called when a nick joins a channel.
bool OnFailedLogin(const CString &sUsername, const CString &sRemoteIP)
bool OnPrivBufferEnding(CQuery &Query, CClient &Client)
const CString m_sName
Definition: Modules.h:238
virtual void OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan * > &vChans)
virtual bool WebRequiresAdmin()
Return true if this module should only be usable for admins on the web.
Definition: Modules.h:478
bool OnModCTCP(const CString &sMessage)
virtual EModRet OnJoining(CChan &Channel)
This module hook is called just before ZNC tries to join an IRC channel.
virtual void OnDeop2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is deopped on a channel.
bool OnJoinMessage(CJoinMessage &Message)
bool ReloadModule(const CString &sModule, const CString &sArgs, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
CIRCNetwork * m_pNetwork
Definition: Modules.h:1600
void SetDefaultType(EModuleType eType)
Definition: Modules.h:309
Definition: Message.h:238
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:190
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 OnPrivActionMessage(CActionMessage &Message)
Called when we receive a private CTCP ACTION ("/me" in query) from IRC.
virtual EModRet OnPrivAction(CNick &Nick, CString &sMessage)
static bool GetModInfo(CModInfo &ModInfo, const CString &sModule, CString &sRetMsg)
Your module can throw this enum at any given time.
Definition: Modules.h:447
CString m_sDescription
Definition: Modules.h:320
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:1137
virtual CString GetWebMenuTitle()
Return the title of the module's section in the web interface's side bar.
Definition: Modules.h:482
virtual void OnChanPermission2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
bool OnJoining(CChan &Channel)
A helper class for handling commands in modules.
Definition: Modules.h:338
virtual void OnJoin(const CNick &Nick, CChan &Channel)
virtual EModRet OnPrivNotice(CNick &Nick, CString &sMessage)
virtual EModRet OnUserNoticeMessage(CNoticeMessage &Message)
This module hook is called when a user sends a NOTICE message.
void SetClient(CClient *pClient)
Definition: Modules.h:1393
bool OnRaw(CString &sLine)
virtual EModRet OnPrivMsg(CNick &Nick, CString &sMessage)
bool SupportsType(EModuleType eType) const
Definition: Modules.h:271
virtual bool ValidateWebRequestCSRFCheck(CWebSock &WebSock, const CString &sPageName)
If ValidateWebRequestCSRFCheck returned false, a CSRF error will be printed.
Stop sending this even to other modules which were not called yet.
Definition: Modules.h:435
Definition: IRCSock.h:35
virtual EModRet OnPrivBufferPlayLine(CClient &Client, CString &sLine)
virtual void OnQuitMessage(CQuitMessage &Message, const std::vector< CChan * > &vChans)
Called when a nick quit from IRC.
const CModCommand * FindCommand(const CString &sCmd) const
virtual EModRet OnUserTextMessage(CTextMessage &Message)
This module hook is called when a user sends a PRIVMSG message.
ModLoader m_fLoader
Definition: Modules.h:324
virtual EModRet OnPrivCTCPMessage(CCTCPMessage &Message)
Called when we receive a private CTCP request from IRC.
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...
Definition: Chan.h:34
virtual EModRet OnStatusCommand(CString &sCommand)
Called when a command to *status is sent.
Definition: Message.h:272
virtual EModRet OnPrivBufferEnding(CQuery &Query, CClient &Client)
Called after a query buffer was played back to a client.
Generate a grid-like output from a given input.
Definition: Utils.h:156
virtual EModRet OnUserTopicMessage(CTopicMessage &Message)
This module hook is called when a user wants to change a channel topic.
CModule *(* ModLoader)(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, EModuleType eType)
Definition: Modules.h:249
bool OnDeleteNetwork(CIRCNetwork &Network)
Definition: Query.h:29
virtual EModRet OnRawMessage(CMessage &Message)
Called on any raw message received from the IRC server.
static bool FindModPath(const CString &sModule, CString &sModPath, CString &sDataPath)
virtual EModRet OnPrivBufferPlayLine2(CClient &Client, CString &sLine, const timeval &tv)
bool OnClientConnect(CZNCSock *pSock, const CString &sHost, unsigned short uPort)
CSocket * FindSocket(const CString &sSockName)
Here is a small explanation of how messages on IRC work, and how you can use this class to get useful...
Definition: Message.h:63
CDelayedTranslation t_d(const CString &sEnglish, const CString &sContext="") const
Definition: ZNCString.h:673
const CString & GetModDataDir() const
Get the module's data dir.
Definition: Modules.h:1109
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:1358
const char * pcCompileOptions
Definition: Modules.h:83