ZNC  trunk
Modules.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2021 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:
239  const CString m_sDescription;
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) {}
265  ~CModInfo() {}
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 
277  static CString ModuleTypeToString(EModuleType eType) {
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; }
298  EModuleType GetDefaultType() const { return m_eDefaultType; }
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>
331 CModule* TModLoad(ModHandle p, CUser* pUser, CIRCNetwork* pNetwork,
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 : private CCoreTranslationMixin {
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,
440  HALTCORE = 4
441  } EModRet;
442 
443  typedef enum {
447  UNLOAD
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);
1053  ModHandle GetDLL() { return m_pDLL; }
1054 
1060  virtual bool PutIRC(const CString& sLine);
1066  virtual bool PutIRC(const CMessage& Message);
1074  virtual bool PutUser(const CString& sLine);
1081  virtual bool PutStatus(const CString& sLine);
1088  virtual bool PutModule(const CString& sLine);
1094  virtual unsigned int PutModule(const CTable& table);
1101  virtual bool PutModNotice(const CString& sLine);
1102 
1104  const CString& GetModName() const { return m_sModName; }
1105 
1109  CString GetModNick() const;
1110 
1115  const CString& GetModDataDir() const { return m_sDataDir; }
1116 
1117  // Timer stuff
1118  bool AddTimer(CTimer* pTimer);
1119  bool AddTimer(FPTimer_t pFBCallback, const CString& sLabel, u_int uInterval,
1120  u_int uCycles = 0, const CString& sDescription = "");
1121  bool RemTimer(CTimer* pTimer);
1122  bool RemTimer(const CString& sLabel);
1123  bool UnlinkTimer(CTimer* pTimer);
1124  CTimer* FindTimer(const CString& sLabel);
1125  std::set<CTimer*>::const_iterator BeginTimers() const {
1126  return m_sTimers.begin();
1127  }
1128  std::set<CTimer*>::const_iterator EndTimers() const {
1129  return m_sTimers.end();
1130  }
1131  virtual void ListTimers();
1132  // !Timer stuff
1133 
1134  // Socket stuff
1135  bool AddSocket(CSocket* pSocket);
1136  bool RemSocket(CSocket* pSocket);
1137  bool RemSocket(const CString& sSockName);
1138  bool UnlinkSocket(CSocket* pSocket);
1139  CSocket* FindSocket(const CString& sSockName);
1140  std::set<CSocket*>::const_iterator BeginSockets() const {
1141  return m_sSockets.begin();
1142  }
1143  std::set<CSocket*>::const_iterator EndSockets() const {
1144  return m_sSockets.end();
1145  }
1146  virtual void ListSockets();
1147 // !Socket stuff
1148 
1149 #ifdef HAVE_PTHREAD
1150  // Job stuff
1151  void AddJob(CModuleJob* pJob);
1152  void CancelJob(CModuleJob* pJob);
1153  bool CancelJob(const CString& sJobName);
1154  void CancelJobs(const std::set<CModuleJob*>& sJobs);
1155  bool UnlinkJob(CModuleJob* pJob);
1156 // !Job stuff
1157 #endif
1158 
1159  // Command stuff
1161  void AddHelpCommand();
1163  bool AddCommand(const CModCommand& Command);
1166  bool AddCommand(const CString& sCmd, CModCommand::ModCmdFunc func,
1167  const CString& sArgs = "", const CString& sDesc = "");
1170  bool AddCommand(const CString& sCmd, const COptionalTranslation& Args,
1171  const COptionalTranslation& Desc,
1172  std::function<void(const CString& sLine)> func);
1174  bool RemCommand(const CString& sCmd);
1176  const CModCommand* FindCommand(const CString& sCmd) const;
1184  bool HandleCommand(const CString& sLine);
1188  void HandleHelpCommand(const CString& sLine = "");
1189  // !Command stuff
1190 
1191  bool LoadRegistry();
1192  bool SaveRegistry() const;
1193  bool MoveRegistry(const CString& sPath);
1194  bool SetNV(const CString& sName, const CString& sValue,
1195  bool bWriteToDisk = true);
1196  CString GetNV(const CString& sName) const;
1197  bool HasNV(const CString& sName) const {
1198  return m_mssRegistry.find(sName) != m_mssRegistry.end();
1199  }
1200  bool DelNV(const CString& sName, bool bWriteToDisk = true);
1201  MCString::iterator FindNV(const CString& sName) {
1202  return m_mssRegistry.find(sName);
1203  }
1204  MCString::iterator EndNV() { return m_mssRegistry.end(); }
1205  MCString::iterator BeginNV() { return m_mssRegistry.begin(); }
1206  void DelNV(MCString::iterator it) { m_mssRegistry.erase(it); }
1207  bool ClearNV(bool bWriteToDisk = true);
1208 
1209  const CString& GetSavePath() const;
1210  CString ExpandString(const CString& sStr) const;
1211  CString& ExpandString(const CString& sStr, CString& sRet) const;
1212 
1213  // Setters
1214  void SetType(CModInfo::EModuleType eType) { m_eType = eType; }
1215  void SetDescription(const CString& s) { m_sDescription = s; }
1216  void SetModPath(const CString& s) { m_sModPath = s; }
1217  void SetArgs(const CString& s) { m_sArgs = s; }
1218  // !Setters
1219 
1220  // Getters
1222  const CString& GetDescription() const { return m_sDescription; }
1223  const CString& GetArgs() const { return m_sArgs; }
1224  const CString& GetModPath() const { return m_sModPath; }
1225 
1231  CUser* GetUser() const { return m_pUser; }
1235  CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1239  CClient* GetClient() const { return m_pClient; }
1240  CSockManager* GetManager() const { return m_pManager; }
1241  // !Getters
1242 
1243  // Global Modules
1250  virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
1255  virtual EModRet OnDeleteUser(CUser& User);
1262  virtual void OnClientConnect(CZNCSock* pSock, const CString& sHost,
1263  unsigned short uPort);
1270  virtual EModRet OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1275  virtual void OnFailedLogin(const CString& sUsername,
1276  const CString& sRemoteIP);
1283  virtual EModRet OnUnknownUserRaw(CClient* pClient, CString& sLine);
1284  virtual EModRet OnUnknownUserRawMessage(CMessage& Message);
1285 
1291  virtual void OnClientCapLs(CClient* pClient, SCString& ssCaps);
1298  virtual bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1299  bool bState);
1309  virtual void OnClientCapRequest(CClient* pClient, const CString& sCap,
1310  bool bState);
1311 
1321  virtual EModRet OnModuleLoading(const CString& sModName,
1322  const CString& sArgs,
1323  CModInfo::EModuleType eType, bool& bSuccess,
1324  CString& sRetMsg);
1332  virtual EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess,
1333  CString& sRetMsg);
1341  virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
1342  bool& bSuccess, CString& sRetMsg);
1347  virtual void OnGetAvailableMods(std::set<CModInfo>& ssMods,
1348  CModInfo::EModuleType eType);
1349  // !Global Modules
1350 
1351 #ifndef SWIG
1352  // Translation
1353  CString t_s(const CString& sEnglish, const CString& sContext = "") const;
1354  CInlineFormatMessage t_f(const CString& sEnglish,
1355  const CString& sContext = "") const;
1356  CInlineFormatMessage t_p(const CString& sEnglish, const CString& sEnglishes,
1357  int iNum, const CString& sContext = "") const;
1358  CDelayedTranslation t_d(const CString& sEnglish,
1359  const CString& sContext = "") const;
1360 #endif
1361 
1362  protected:
1365  std::set<CTimer*> m_sTimers;
1366  std::set<CSocket*> m_sSockets;
1367 #ifdef HAVE_PTHREAD
1368  std::set<CModuleJob*> m_sJobs;
1369 #endif
1381 
1382  private:
1383  MCString
1384  m_mssRegistry;
1385  VWebSubPages m_vSubPages;
1386  std::map<CString, CModCommand> m_mCommands;
1387 };
1389 class CModules : public std::vector<CModule*>, private CCoreTranslationMixin {
1390  public:
1391  CModules();
1392  ~CModules();
1393 
1394  CModules(const CModules&) = default;
1395  CModules& operator=(const CModules&) = default;
1397  void SetUser(CUser* pUser) { m_pUser = pUser; }
1398  void SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
1399  void SetClient(CClient* pClient) { m_pClient = pClient; }
1400  CUser* GetUser() const { return m_pUser; }
1401  CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1402  CClient* GetClient() const { return m_pClient; }
1403 
1404  void UnloadAll();
1405 
1406  bool OnBoot();
1407  bool OnPreRehash();
1408  bool OnPostRehash();
1409  bool OnIRCDisconnected();
1410  bool OnIRCConnected();
1411  bool OnIRCConnecting(CIRCSock* pIRCSock);
1412  bool OnIRCConnectionError(CIRCSock* pIRCSock);
1413  bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent,
1414  CString& sRealName);
1415  bool OnBroadcast(CString& sMessage);
1416 
1417  bool OnChanPermission3(const CNick* pOpNick, const CNick& Nick,
1418  CChan& Channel, char cMode, bool bAdded,
1419  bool bNoChange);
1420  bool OnChanPermission2(const CNick* pOpNick, const CNick& Nick,
1421  CChan& Channel, unsigned char uMode, bool bAdded,
1422  bool bNoChange);
1423  bool OnChanPermission(const CNick& OpNick, const CNick& Nick,
1424  CChan& Channel, unsigned char uMode, bool bAdded,
1425  bool bNoChange);
1426  bool OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1427  bool bNoChange);
1428  bool OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1429  bool bNoChange);
1430  bool OnDeop2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1431  bool bNoChange);
1432  bool OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1433  bool bNoChange);
1434  bool OnVoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1435  bool bNoChange);
1436  bool OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1437  bool bNoChange);
1438  bool OnDevoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1439  bool bNoChange);
1440  bool OnDevoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1441  bool bNoChange);
1442  bool OnRawMode2(const CNick* pOpNick, CChan& Channel, const CString& sModes,
1443  const CString& sArgs);
1444  bool OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes,
1445  const CString& sArgs);
1446  bool OnMode2(const CNick* pOpNick, CChan& Channel, char uMode,
1447  const CString& sArg, bool bAdded, bool bNoChange);
1448  bool OnMode(const CNick& OpNick, CChan& Channel, char uMode,
1449  const CString& sArg, bool bAdded, bool bNoChange);
1450 
1451  bool OnRaw(CString& sLine);
1452  bool OnRawMessage(CMessage& Message);
1453  bool OnNumericMessage(CNumericMessage& Message);
1454 
1455  bool OnStatusCommand(CString& sCommand);
1456  bool OnModCommand(const CString& sCommand);
1457  bool OnModNotice(const CString& sMessage);
1458  bool OnModCTCP(const CString& sMessage);
1459 
1460  bool OnQuit(const CNick& Nick, const CString& sMessage,
1461  const std::vector<CChan*>& vChans);
1462  bool OnQuitMessage(CQuitMessage& Message,
1463  const std::vector<CChan*>& vChans);
1464  bool OnNick(const CNick& Nick, const CString& sNewNick,
1465  const std::vector<CChan*>& vChans);
1466  bool OnNickMessage(CNickMessage& Message,
1467  const std::vector<CChan*>& vChans);
1468  bool OnKick(const CNick& Nick, const CString& sOpNick, CChan& Channel,
1469  const CString& sMessage);
1470  bool OnKickMessage(CKickMessage& Message);
1471  bool OnJoining(CChan& Channel);
1472  bool OnJoin(const CNick& Nick, CChan& Channel);
1473  bool OnJoinMessage(CJoinMessage& Message);
1474  bool OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage);
1475  bool OnPartMessage(CPartMessage& Message);
1476  bool OnInvite(const CNick& Nick, const CString& sChan);
1477 
1478  bool OnChanBufferStarting(CChan& Chan, CClient& Client);
1479  bool OnChanBufferEnding(CChan& Chan, CClient& Client);
1480  bool OnChanBufferPlayLine2(CChan& Chan, CClient& Client, CString& sLine,
1481  const timeval& tv);
1482  bool OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
1483  bool OnPrivBufferStarting(CQuery& Query, CClient& Client);
1484  bool OnPrivBufferEnding(CQuery& Query, CClient& Client);
1485  bool OnPrivBufferPlayLine2(CClient& Client, CString& sLine,
1486  const timeval& tv);
1487  bool OnPrivBufferPlayLine(CClient& Client, CString& sLine);
1488  bool OnChanBufferPlayMessage(CMessage& Message);
1489  bool OnPrivBufferPlayMessage(CMessage& Message);
1490 
1491  bool OnClientLogin();
1492  bool OnClientDisconnect();
1493  bool OnUserRaw(CString& sLine);
1494  bool OnUserRawMessage(CMessage& Message);
1495  bool OnUserCTCPReply(CString& sTarget, CString& sMessage);
1496  bool OnUserCTCPReplyMessage(CCTCPMessage& Message);
1497  bool OnUserCTCP(CString& sTarget, CString& sMessage);
1498  bool OnUserCTCPMessage(CCTCPMessage& Message);
1499  bool OnUserAction(CString& sTarget, CString& sMessage);
1500  bool OnUserActionMessage(CActionMessage& Message);
1501  bool OnUserMsg(CString& sTarget, CString& sMessage);
1502  bool OnUserTextMessage(CTextMessage& Message);
1503  bool OnUserNotice(CString& sTarget, CString& sMessage);
1504  bool OnUserNoticeMessage(CNoticeMessage& Message);
1505  bool OnUserJoin(CString& sChannel, CString& sKey);
1506  bool OnUserJoinMessage(CJoinMessage& Message);
1507  bool OnUserPart(CString& sChannel, CString& sMessage);
1508  bool OnUserPartMessage(CPartMessage& Message);
1509  bool OnUserTopic(CString& sChannel, CString& sTopic);
1510  bool OnUserTopicMessage(CTopicMessage& Message);
1511  bool OnUserTopicRequest(CString& sChannel);
1512  bool OnUserQuit(CString& sMessage);
1513  bool OnUserQuitMessage(CQuitMessage& Message);
1514 
1515  bool OnCTCPReply(CNick& Nick, CString& sMessage);
1516  bool OnCTCPReplyMessage(CCTCPMessage& Message);
1517  bool OnPrivCTCP(CNick& Nick, CString& sMessage);
1518  bool OnPrivCTCPMessage(CCTCPMessage& Message);
1519  bool OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
1520  bool OnChanCTCPMessage(CCTCPMessage& Message);
1521  bool OnPrivAction(CNick& Nick, CString& sMessage);
1522  bool OnPrivActionMessage(CActionMessage& Message);
1523  bool OnChanAction(CNick& Nick, CChan& Channel, CString& sMessage);
1524  bool OnChanActionMessage(CActionMessage& Message);
1525  bool OnPrivMsg(CNick& Nick, CString& sMessage);
1526  bool OnPrivTextMessage(CTextMessage& Message);
1527  bool OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
1528  bool OnChanTextMessage(CTextMessage& Message);
1529  bool OnPrivNotice(CNick& Nick, CString& sMessage);
1530  bool OnPrivNoticeMessage(CNoticeMessage& Message);
1531  bool OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage);
1532  bool OnChanNoticeMessage(CNoticeMessage& Message);
1533  bool OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
1534  bool OnTopicMessage(CTopicMessage& Message);
1535  bool OnTimerAutoJoin(CChan& Channel);
1536 
1537  bool OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1538  bool OnDeleteNetwork(CIRCNetwork& Network);
1539 
1540  bool OnSendToClient(CString& sLine, CClient& Client);
1541  bool OnSendToClientMessage(CMessage& Message);
1542  bool OnSendToIRC(CString& sLine);
1543  bool OnSendToIRCMessage(CMessage& Message);
1544 
1545  bool OnServerCapAvailable(const CString& sCap);
1546  bool OnServerCapResult(const CString& sCap, bool bSuccess);
1547 
1548  CModule* FindModule(const CString& sModule) const;
1549  bool LoadModule(const CString& sModule, const CString& sArgs,
1550  CModInfo::EModuleType eType, CUser* pUser,
1551  CIRCNetwork* pNetwork, CString& sRetMsg);
1552  bool UnloadModule(const CString& sModule);
1553  bool UnloadModule(const CString& sModule, CString& sRetMsg);
1554  bool ReloadModule(const CString& sModule, const CString& sArgs,
1555  CUser* pUser, CIRCNetwork* pNetwork, CString& sRetMsg);
1556 
1557  static bool GetModInfo(CModInfo& ModInfo, const CString& sModule,
1558  CString& sRetMsg);
1559  static bool GetModPathInfo(CModInfo& ModInfo, const CString& sModule,
1560  const CString& sModPath, CString& sRetMsg);
1561  static void GetAvailableMods(
1562  std::set<CModInfo>& ssMods,
1564  static void GetDefaultMods(
1565  std::set<CModInfo>& ssMods,
1567 
1568  // This returns the path to the .so and to the data dir
1569  // which is where static data (webadmin skins) are saved
1570  static bool FindModPath(const CString& sModule, CString& sModPath,
1571  CString& sDataPath);
1572  // Return a list of <module dir, data dir> pairs for directories in
1573  // which modules can be found.
1574  typedef std::queue<std::pair<CString, CString>> ModDirList;
1575  static ModDirList GetModDirs();
1576 
1577  // Global Modules
1578  bool OnAddUser(CUser& User, CString& sErrorRet);
1579  bool OnDeleteUser(CUser& User);
1580  bool OnClientConnect(CZNCSock* pSock, const CString& sHost,
1581  unsigned short uPort);
1582  bool OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1583  bool OnFailedLogin(const CString& sUsername, const CString& sRemoteIP);
1584  bool OnUnknownUserRaw(CClient* pClient, CString& sLine);
1585  bool OnUnknownUserRawMessage(CMessage& Message);
1586  bool OnClientCapLs(CClient* pClient, SCString& ssCaps);
1587  bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1588  bool bState);
1589  bool OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState);
1590  bool OnModuleLoading(const CString& sModName, const CString& sArgs,
1591  CModInfo::EModuleType eType, bool& bSuccess,
1592  CString& sRetMsg);
1593  bool OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
1594  bool OnGetModInfo(CModInfo& ModInfo, const CString& sModule, bool& bSuccess,
1595  CString& sRetMsg);
1596  bool OnGetAvailableMods(std::set<CModInfo>& ssMods,
1597  CModInfo::EModuleType eType);
1598  // !Global Modules
1599 
1600  private:
1601  static ModHandle OpenModule(const CString& sModule, const CString& sModPath,
1602  CModInfo& Info, CString& sRetMsg);
1603  static bool ValidateModuleName(const CString& sModule, CString& sRetMsg);
1604 
1605  protected:
1608  CClient* m_pClient;
1609 };
1610 
1611 #endif // !ZNC_MODULES_H
CModules::OnModCommand
bool OnModCommand(const CString &sCommand)
CModules::UnloadModule
bool UnloadModule(const CString &sModule)
CModule::OnBroadcast
virtual EModRet OnBroadcast(CString &sMessage)
This module hook is called when a message is broadcasted to all users.
CModule::GetArgs
const CString & GetArgs() const
Definition: Modules.h:1222
CModule::OnUserJoinMessage
virtual EModRet OnUserJoinMessage(CJoinMessage &Message)
This hooks is called when a user sends a JOIN message.
CModInfo
Definition: Modules.h:244
CModule::OnStatusCommand
virtual EModRet OnStatusCommand(CString &sCommand)
Called when a command to *status is sent.
CModules::OnUserTopicMessage
bool OnUserTopicMessage(CTopicMessage &Message)
CModule::OnRawMode
virtual void OnRawMode(const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
CModule::~CModule
virtual ~CModule()
CModules::OnGetModInfo
bool OnGetModInfo(CModInfo &ModInfo, const CString &sModule, bool &bSuccess, CString &sRetMsg)
CModCommand::CmdFunc
std::function< void(const CString &sLine)> CmdFunc
Definition: Modules.h:341
CModule::FindNV
MCString::iterator FindNV(const CString &sName)
Definition: Modules.h:1200
CModules::OnClientLogin
bool OnClientLogin()
CModules::OnChanBufferEnding
bool OnChanBufferEnding(CChan &Chan, CClient &Client)
CModule::OnPrivNotice
virtual EModRet OnPrivNotice(CNick &Nick, CString &sMessage)
CModules::GetDefaultMods
static void GetDefaultMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType=CModInfo::UserModule)
CModules::OnRawMode
bool OnRawMode(const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
CModInfo::GetHasArgs
bool GetHasArgs() const
Definition: Modules.h:295
CModules::OnIRCConnected
bool OnIRCConnected()
CModule::OnClientLogin
virtual void OnClientLogin()
Called when a client successfully logged in to ZNC.
CModule::GetNV
CString GetNV(const CString &sName) const
CModule::OnPrivBufferPlayLine
virtual EModRet OnPrivBufferPlayLine(CClient &Client, CString &sLine)
CModules::ReloadModule
bool ReloadModule(const CString &sModule, const CString &sArgs, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
CModInfo::m_sDescription
CString m_sDescription
Definition: Modules.h:319
CModules::CModules
CModules()
CModule::OnChanCTCP
virtual EModRet OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
Threads.h
CModule::OnUserAction
virtual EModRet OnUserAction(CString &sTarget, CString &sMessage)
CModule::OnUnknownUserRaw
virtual EModRet OnUnknownUserRaw(CClient *pClient, CString &sLine)
This function behaves like CModule::OnUserRaw(), but is also called before the client successfully lo...
CModule::EndNV
MCString::iterator EndNV()
Definition: Modules.h:1203
CModule::OnDeleteNetwork
virtual EModRet OnDeleteNetwork(CIRCNetwork &Network)
This module hook is called when a network is deleted.
CModule::OnDevoice2
virtual void OnDevoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is devoiced on a channel.
CModuleJob::GetModule
CModule * GetModule() const
Definition: Modules.h:230
CModules::OnUserCTCP
bool OnUserCTCP(CString &sTarget, CString &sMessage)
CClient
Definition: Client.h:99
CModuleJob::CModuleJob
CModuleJob(CModule *pModule, const CString &sName, const CString &sDesc)
Definition: Modules.h:222
CModInfo::m_seType
std::set< EModuleType > m_seType
Definition: Modules.h:315
CModules::OnJoining
bool OnJoining(CChan &Channel)
CModule::OnPrivNoticeMessage
virtual EModRet OnPrivNoticeMessage(CNoticeMessage &Message)
Called when we receive a private NOTICE message from IRC.
CModules::OnTimerAutoJoin
bool OnTimerAutoJoin(CChan &Channel)
CModule::GetType
CModInfo::EModuleType GetType() const
Definition: Modules.h:1220
CModules::OnChanPermission2
bool OnChanPermission2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
CModule::t_f
CInlineFormatMessage t_f(const CString &sEnglish, const CString &sContext="") const
CModule::OnClientConnect
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.
CWebSock
Definition: WebModules.h:127
CModInfo::ModLoader
CModule *(* ModLoader)(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, EModuleType eType)
Definition: Modules.h:248
CModCommand::CModCommand
CModCommand()
Default constructor, needed so that this can be saved in a std::map.
CModule::OnPrivBufferEnding
virtual EModRet OnPrivBufferEnding(CQuery &Query, CClient &Client)
Called after a query buffer was played back to a client.
CModule::m_pUser
CUser * m_pUser
Definition: Modules.h:1371
CModule::PutModule
virtual bool PutModule(const CString &sLine)
This function sends a query from your module nick.
CModule::m_sModName
CString m_sModName
Definition: Modules.h:1374
CModules::OnSendToIRCMessage
bool OnSendToIRCMessage(CMessage &Message)
CModules::OnBoot
bool OnBoot()
CModule::IsClientCapSupported
virtual bool IsClientCapSupported(CClient *pClient, const CString &sCap, bool bState)
Called only to check if your module supports turning on/off named capability.
CModule::WebRequiresLogin
virtual bool WebRequiresLogin()
Modules which can only be used with an active user session have to return true here.
Definition: Modules.h:473
CQuery
Definition: Query.h:29
CModule::OnChanBufferStarting
virtual EModRet OnChanBufferStarting(CChan &Chan, CClient &Client)
Called before a channel buffer is played back to a client.
CModule::EModException
EModException
Definition: Modules.h:442
CModule::GetDescription
const CString & GetDescription() const
Definition: Modules.h:1221
CModule::OnVoice2
virtual void OnVoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is voiced on a channel.
CTopicMessage
Definition: Message.h:340
CModules::OnPrivNoticeMessage
bool OnPrivNoticeMessage(CNoticeMessage &Message)
CModuleJob::~CModuleJob
virtual ~CModuleJob()
CModules::OnPrivNotice
bool OnPrivNotice(CNick &Nick, CString &sMessage)
CModInfo::GetArgsHelpText
const CString & GetArgsHelpText() const
Definition: Modules.h:294
CCron
this is the main cron job class
Definition: Csocket.h:393
CModule::m_pClient
CClient * m_pClient
Definition: Modules.h:1373
CModule::ExpandString
CString ExpandString(const CString &sStr) const
CModule::GetUser
CUser * GetUser() const
Definition: Modules.h:1230
CModules::LoadModule
bool LoadModule(const CString &sModule, const CString &sArgs, CModInfo::EModuleType eType, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
CTimer::GetDescription
const CString & GetDescription() const
CModules::OnRawMode2
bool OnRawMode2(const CNick *pOpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
CModule::t_d
CDelayedTranslation t_d(const CString &sEnglish, const CString &sContext="") const
MCString
A dictionary for strings.
Definition: ZNCString.h:595
CActionMessage
Definition: Message.h:242
CModInfo::GetName
const CString & GetName() const
Definition: Modules.h:290
CQuitMessage
Definition: Message.h:324
CFPTimer::CFPTimer
CFPTimer(CModule *pModule, unsigned int uInterval, unsigned int uCycles, const CString &sLabel, const CString &sDescription)
Definition: Modules.h:197
CModule::BeginNV
MCString::iterator BeginNV()
Definition: Modules.h:1204
CModules::OnClientCapRequest
bool OnClientCapRequest(CClient *pClient, const CString &sCap, bool bState)
CModules::OnDevoice
bool OnDevoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CModules::OnModCTCP
bool OnModCTCP(const CString &sMessage)
CModules::OnPrivMsg
bool OnPrivMsg(CNick &Nick, CString &sMessage)
CModule::OnUserQuit
virtual EModRet OnUserQuit(CString &sMessage)
CModule::OnQuit
virtual void OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan * > &vChans)
VWebSubPages
std::vector< TWebSubPage > VWebSubPages
Definition: WebModules.h:33
CModules::SetNetwork
void SetNetwork(CIRCNetwork *pNetwork)
Definition: Modules.h:1397
CModules::OnJoinMessage
bool OnJoinMessage(CJoinMessage &Message)
CModule::AddJob
void AddJob(CModuleJob *pJob)
CModInfo::SetName
void SetName(const CString &s)
Definition: Modules.h:301
CModule::OnUserPartMessage
virtual EModRet OnUserPartMessage(CPartMessage &Message)
This hooks is called when a user sends a PART message.
CModule::OnChanTextMessage
virtual EModRet OnChanTextMessage(CTextMessage &Message)
Called when we receive a channel PRIVMSG message from IRC.
CModules::OnSendToClientMessage
bool OnSendToClientMessage(CMessage &Message)
CModules::OnUserQuitMessage
bool OnUserQuitMessage(CQuitMessage &Message)
CModCommand
A helper class for handling commands in modules.
Definition: Modules.h:337
CModules::OnStatusCommand
bool OnStatusCommand(CString &sCommand)
CModule::HALTMODS
@ HALTMODS
Stop sending this even to other modules which were not called yet.
Definition: Modules.h:434
CModule::OnUnknownModCommand
virtual void OnUnknownModCommand(const CString &sCommand)
This is similar to OnModCommand(), but it is only called if HandleCommand didn't find any that wants ...
CModule::m_sSavePath
CString m_sSavePath
Definition: Modules.h:1376
CModules::OnUserCTCPReply
bool OnUserCTCPReply(CString &sTarget, CString &sMessage)
CModules::OnPrivBufferPlayMessage
bool OnPrivBufferPlayMessage(CMessage &Message)
CModuleJob::m_sName
const CString m_sName
Definition: Modules.h:237
CModule::OnServerCapResult
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).
CModules::OnClientDisconnect
bool OnClientDisconnect()
CModCommand::ModCmdFunc
void(CModule::* ModCmdFunc)(const CString &sLine)
Type for the callback function that handles the actual command.
Definition: Modules.h:340
CModules::OnPrivBufferStarting
bool OnPrivBufferStarting(CQuery &Query, CClient &Client)
CModules::OnKickMessage
bool OnKickMessage(CKickMessage &Message)
CModuleJob::GetName
const CString & GetName() const
Definition: Modules.h:231
CSockManager
Definition: Socket.h:79
CModules::OnIRCConnectionError
bool OnIRCConnectionError(CIRCSock *pIRCSock)
CCTCPMessage
Definition: Message.h:253
CModules::OnPrivBufferPlayLine2
bool OnPrivBufferPlayLine2(CClient &Client, CString &sLine, const timeval &tv)
CModCommand::operator=
CModCommand & operator=(const CModCommand &other)=default
Assignment operator, needed so that this can be saved in a std::map.
CModules::UnloadAll
void UnloadAll()
CModule::BeginTimers
std::set< CTimer * >::const_iterator BeginTimers() const
Definition: Modules.h:1124
CModule::SetNetwork
void SetNetwork(CIRCNetwork *pNetwork)
CModCommand::InitHelp
static void InitHelp(CTable &Table)
Initialize a CTable so that it can be used with AddHelp().
CModules::OnServerCapAvailable
bool OnServerCapAvailable(const CString &sCap)
CDelayedTranslation
Definition: Translation.h:70
CModule::HALTCORE
@ HALTCORE
Continue calling other modules.
Definition: Modules.h:439
CModule::OnUserNoticeMessage
virtual EModRet OnUserNoticeMessage(CNoticeMessage &Message)
This module hook is called when a user sends a NOTICE message.
CModuleEntry::pcVersionExtra
const char * pcVersionExtra
Definition: Modules.h:82
CModule::OnSendToClientMessage
virtual EModRet OnSendToClientMessage(CMessage &Message)
Called immediately before ZNC sends a raw traffic line to a client.
CModules::OnPostRehash
bool OnPostRehash()
CModules::OnDeop
bool OnDeop(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CModInfo::ModuleTypeToString
static CString ModuleTypeToString(EModuleType eType)
Definition: Modules.h:276
CModule::OnOp2
virtual void OnOp2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is opped on a channel.
CModule::MoveRegistry
bool MoveRegistry(const CString &sPath)
CModInfo::m_sWikiPage
CString m_sWikiPage
Definition: Modules.h:320
CModules::m_pClient
CClient * m_pClient
Definition: Modules.h:1607
TWebSubPage
std::shared_ptr< CWebSubPage > TWebSubPage
Definition: WebModules.h:30
CModules::OnChanTextMessage
bool OnChanTextMessage(CTextMessage &Message)
CTemplate
Definition: Template.h:129
CModule::OnModCTCP
virtual void OnModCTCP(const CString &sMessage)
Called when your module nick was sent a CTCP message.
SCString
std::set< CString > SCString
Definition: ZNCString.h:35
CModule::OnCTCPReplyMessage
virtual EModRet OnCTCPReplyMessage(CCTCPMessage &Message)
Called when we receive a CTCP reply from IRC.
CModule::RemSocket
bool RemSocket(CSocket *pSocket)
CModule::OnPartMessage
virtual void OnPartMessage(CPartMessage &Message)
Called when a nick parts a channel.
CModule::DelNV
bool DelNV(const CString &sName, bool bWriteToDisk=true)
CModule::OnDeop
virtual void OnDeop(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CTimer::operator=
CTimer & operator=(const CTimer &)=delete
CModule::PutStatus
virtual bool PutStatus(const CString &sLine)
This function generates a query from *status.
CModInfo::GetDefaultType
EModuleType GetDefaultType() const
Definition: Modules.h:297
CModule::GetSubPages
virtual VWebSubPages & GetSubPages()
Returns a list of all registered SubPages.
Definition: Modules.h:522
CModuleEntry::pcVersion
const char * pcVersion
Definition: Modules.h:81
CModules::OnQuitMessage
bool OnQuitMessage(CQuitMessage &Message, const std::vector< CChan * > &vChans)
CModInfo::t_s
CString t_s(const CString &sEnglish, const CString &sContext="") const
CModuleJob::m_pModule
CModule * m_pModule
Definition: Modules.h:236
CModules::OnUserCTCPMessage
bool OnUserCTCPMessage(CCTCPMessage &Message)
CModInfo::SetHasArgs
void SetHasArgs(bool b=false)
Definition: Modules.h:306
CModules::GetNetwork
CIRCNetwork * GetNetwork() const
Definition: Modules.h:1400
CModule::HandleHelpCommand
void HandleHelpCommand(const CString &sLine="")
Send a description of all registered commands via PutModule().
CModule::AddHelpCommand
void AddHelpCommand()
Register the "Help" command.
CModInfo::m_eDefaultType
EModuleType m_eDefaultType
Definition: Modules.h:316
CModules::m_pNetwork
CIRCNetwork * m_pNetwork
Definition: Modules.h:1606
CModules::SetClient
void SetClient(CClient *pClient)
Definition: Modules.h:1398
CModules::OnUserTopic
bool OnUserTopic(CString &sChannel, CString &sTopic)
CModInfo::GetDescription
const CString & GetDescription() const
Definition: Modules.h:292
CModule::GetNetwork
CIRCNetwork * GetNetwork() const
Definition: Modules.h:1234
CModules::operator=
CModules & operator=(const CModules &)=default
CModInfo::SupportsType
bool SupportsType(EModuleType eType) const
Definition: Modules.h:270
CMessage
Here is a small explanation of how messages on IRC work, and how you can use this class to get useful...
Definition: Message.h:70
CModInfo::CModInfo
CModInfo()
Definition: Modules.h:253
CModules::OnMode
bool OnMode(const CNick &OpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
CModule::OnUserTopic
virtual EModRet OnUserTopic(CString &sChannel, CString &sTopic)
CModules::OnChanAction
bool OnChanAction(CNick &Nick, CChan &Channel, CString &sMessage)
CModule::AddTimer
bool AddTimer(CTimer *pTimer)
CModInfo::GetWikiPage
const CString & GetWikiPage() const
Definition: Modules.h:293
CModules::OnPartMessage
bool OnPartMessage(CPartMessage &Message)
CModules::OnPrivCTCPMessage
bool OnPrivCTCPMessage(CCTCPMessage &Message)
CModule::UnlinkSocket
bool UnlinkSocket(CSocket *pSocket)
CModule::OnMode
virtual void OnMode(const CNick &OpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
CModule::OnLoginAttempt
virtual EModRet OnLoginAttempt(std::shared_ptr< CAuthBase > Auth)
This module hook is called when a client tries to login.
CModule::SetUser
void SetUser(CUser *pUser)
CModules::OnQuit
bool OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan * > &vChans)
CModule::LoadRegistry
bool LoadRegistry()
CModule::OnEmbeddedWebRequest
virtual bool OnEmbeddedWebRequest(CWebSock &WebSock, const CString &sPageName, CTemplate &Tmpl)
Using this hook, module can embed web stuff directly to different places.
CModule::BeginSockets
std::set< CSocket * >::const_iterator BeginSockets() const
Definition: Modules.h:1139
CModules::OnTopic
bool OnTopic(CNick &Nick, CChan &Channel, CString &sTopic)
CModules::OnChanBufferPlayMessage
bool OnChanBufferPlayMessage(CMessage &Message)
CModules::ModDirList
std::queue< std::pair< CString, CString > > ModDirList
Definition: Modules.h:1573
CString
String class that is used inside ZNC.
Definition: ZNCString.h:68
CModules::OnUserNoticeMessage
bool OnUserNoticeMessage(CNoticeMessage &Message)
CModule::GetModName
const CString & GetModName() const
Definition: Modules.h:1103
CNickMessage
Definition: Message.h:283
CModInfo::m_sPath
CString m_sPath
Definition: Modules.h:318
CModules::OnUnknownUserRawMessage
bool OnUnknownUserRawMessage(CMessage &Message)
CModule::OnSendToClient
virtual EModRet OnSendToClient(CString &sLine, CClient &Client)
CModule::OnChanPermission3
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.
CModule::OnChanCTCPMessage
virtual EModRet OnChanCTCPMessage(CCTCPMessage &Message)
Called when we receive a channel CTCP request from IRC.
CModules::OnUserActionMessage
bool OnUserActionMessage(CActionMessage &Message)
CModules::OnTopicMessage
bool OnTopicMessage(CTopicMessage &Message)
CModules::OnChanNotice
bool OnChanNotice(CNick &Nick, CChan &Channel, CString &sMessage)
CModule::ListSockets
virtual void ListSockets()
CModule::OnTopicMessage
virtual EModRet OnTopicMessage(CTopicMessage &Message)
Called when we receive a channel topic change from IRC.
CModules::OnKick
bool OnKick(const CNick &Nick, const CString &sOpNick, CChan &Channel, const CString &sMessage)
CModules::OnUserRaw
bool OnUserRaw(CString &sLine)
Utils.h
CModInfo::UserModule
@ UserModule
Definition: Modules.h:246
CModule::OnKickMessage
virtual void OnKickMessage(CKickMessage &Message)
Called when a nick is kicked from a channel.
CModInfo::~CModInfo
~CModInfo()
Definition: Modules.h:264
CModule::GetModDataDir
const CString & GetModDataDir() const
Get the module's data dir.
Definition: Modules.h:1114
CModules::~CModules
~CModules()
CModule::OnChanBufferPlayMessage
virtual EModRet OnChanBufferPlayMessage(CMessage &Message)
Called for each message during a channel's buffer play back.
CModule::GetWebPath
virtual CString GetWebPath()
CTextMessage
Definition: Message.h:333
CModule::operator=
CModule & operator=(const CModule &)=delete
CModule::OnSendToIRC
virtual EModRet OnSendToIRC(CString &sLine)
CModules::OnUserRawMessage
bool OnUserRawMessage(CMessage &Message)
CModule::OnUserRaw
virtual EModRet OnUserRaw(CString &sLine)
This module hook is called when a client sends a raw traffic line to ZNC.
CModule::ClearNV
bool ClearNV(bool bWriteToDisk=true)
CTimer::SetDescription
void SetDescription(const CString &s)
CTimer::SetModule
void SetModule(CModule *p)
CTimer::m_pModule
CModule * m_pModule
Definition: Modules.h:189
CModule::GetManager
CSockManager * GetManager() const
Definition: Modules.h:1239
CModule::OnUnknownUserRawMessage
virtual EModRet OnUnknownUserRawMessage(CMessage &Message)
CModule::OnVoice
virtual void OnVoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CModules::OnSendToClient
bool OnSendToClient(CString &sLine, CClient &Client)
CChan
Definition: Chan.h:35
CModule::AddCommand
bool AddCommand(const CModCommand &Command)
CModule::OnPrivBufferStarting
virtual EModRet OnPrivBufferStarting(CQuery &Query, CClient &Client)
Called before a query buffer is played back to a client.
CModule::OnPreRehash
virtual void OnPreRehash()
Called just before znc.conf is rehashed.
CModule::OnClientCapRequest
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.
CModule::OnDeleteUser
virtual EModRet OnDeleteUser(CUser &User)
This module hook is called when a user is deleted.
TModInfo
void TModInfo(CModInfo &Info)
Definition: Modules.h:327
CModule::OnNickMessage
virtual void OnNickMessage(CNickMessage &Message, const std::vector< CChan * > &vChans)
Called when a nickname change occurs.
CModule::OnIRCRegistration
virtual EModRet OnIRCRegistration(CString &sPass, CString &sNick, CString &sIdent, CString &sRealName)
This module hook is called before loging in to the IRC server.
CModule::OnPrivCTCP
virtual EModRet OnPrivCTCP(CNick &Nick, CString &sMessage)
CModules::OnClientCapLs
bool OnClientCapLs(CClient *pClient, SCString &ssCaps)
CModule::OnModuleLoading
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.
CModInfo::SetWikiPage
void SetWikiPage(const CString &s)
Definition: Modules.h:304
CIRCSock
Definition: IRCSock.h:35
CModCommand::Call
void Call(const CString &sLine) const
Definition: Modules.h:384
CModule::PutUser
virtual bool PutUser(const CString &sLine)
This function sends a given raw IRC line to a client.
CModule::OnUserCTCPReplyMessage
virtual EModRet OnUserCTCPReplyMessage(CCTCPMessage &Message)
This module hook is called when a client sends a CTCP reply.
CModule::OnPrivBufferPlayMessage
virtual EModRet OnPrivBufferPlayMessage(CMessage &Message)
Called for each message during a query's buffer play back.
CModule::OnChanBufferPlayLine
virtual EModRet OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
CModule::OnIRCConnecting
virtual EModRet OnIRCConnecting(CIRCSock *pIRCSock)
This module hook is called just before ZNC tries to establish a connection to an IRC server.
CModules::OnChanPermission
bool OnChanPermission(const CNick &OpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
CModule::m_eType
CModInfo::EModuleType m_eType
Definition: Modules.h:1362
CModCommand::GetCommand
const CString & GetCommand() const
Definition: Modules.h:379
CModule::OnPostRehash
virtual void OnPostRehash()
This module hook is called after a successful rehash.
CModule::m_pNetwork
CIRCNetwork * m_pNetwork
Definition: Modules.h:1372
CModInfo::SetLoader
void SetLoader(ModLoader fLoader)
Definition: Modules.h:307
CModInfo::NetworkModule
@ NetworkModule
Definition: Modules.h:246
CModules::OnMode2
bool OnMode2(const CNick *pOpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
CModule::OnWebRequest
virtual bool OnWebRequest(CWebSock &WebSock, const CString &sPageName, CTemplate &Tmpl)
If OnWebPreRequest returned false, and the RequiresAdmin/IsAdmin check has been passed,...
CModule::CModule
CModule(ModHandle pDLL, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sDataDir, CModInfo::EModuleType eType=CModInfo::NetworkModule)
CModules::OnUserAction
bool OnUserAction(CString &sTarget, CString &sMessage)
CModCommand::AddHelp
void AddHelp(CTable &Table) const
Add this command to the CTable instance.
CModules::OnPreRehash
bool OnPreRehash()
CModule::m_pDLL
ModHandle m_pDLL
Definition: Modules.h:1369
CModInfo::SetDefaultType
void SetDefaultType(EModuleType eType)
Definition: Modules.h:308
CJoinMessage
Definition: Message.h:263
CModule::OnSendToIRCMessage
virtual EModRet OnSendToIRCMessage(CMessage &Message)
Called immediately before ZNC sends a raw traffic line to the IRC server.
CModuleJob::operator=
CModuleJob & operator=(const CModuleJob &)=delete
CModule::OnRawMode2
virtual void OnRawMode2(const CNick *pOpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
Called on any channel mode change.
CModule::OnAddNetwork
virtual EModRet OnAddNetwork(CIRCNetwork &Network, CString &sErrorRet)
This module hook is called when a network is being added.
CModInfo::AddType
void AddType(EModuleType eType)
Definition: Modules.h:274
CModule::OnTimerAutoJoin
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...
CModule::m_sArgs
CString m_sArgs
Definition: Modules.h:1377
CModule::m_sTimers
std::set< CTimer * > m_sTimers
Definition: Modules.h:1364
CModule::SetArgs
void SetArgs(const CString &s)
Definition: Modules.h:1216
CModule::ListTimers
virtual void ListTimers()
CModInfo::m_sArgsHelpText
CString m_sArgsHelpText
Definition: Modules.h:321
CModules::OnUserNotice
bool OnUserNotice(CString &sTarget, CString &sMessage)
CTimer
Definition: Modules.h:168
CModule::GetWebMenuTitle
virtual CString GetWebMenuTitle()
Return the title of the module's section in the web interface's side bar.
Definition: Modules.h:481
CModule::UnlinkTimer
bool UnlinkTimer(CTimer *pTimer)
CModInfo::GetPath
const CString & GetPath() const
Definition: Modules.h:291
CModules::OnFailedLogin
bool OnFailedLogin(const CString &sUsername, const CString &sRemoteIP)
CModules::OnChanBufferPlayLine
bool OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
CModules::OnDevoice2
bool OnDevoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
ModHandle
void * ModHandle
Definition: Modules.h:242
CModule::OnUserTopicRequest
virtual EModRet OnUserTopicRequest(CString &sChannel)
This hook is called when a user requests a channel's topic.
CModules::OnNickMessage
bool OnNickMessage(CNickMessage &Message, const std::vector< CChan * > &vChans)
CModule::OnChanPermission2
virtual void OnChanPermission2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
CModule::OnPrivTextMessage
virtual EModRet OnPrivTextMessage(CTextMessage &Message)
Called when we receive a private PRIVMSG message from IRC.
CModules::OnUserTopicRequest
bool OnUserTopicRequest(CString &sChannel)
CModules::OnOp
bool OnOp(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CTimer::m_sDescription
CString m_sDescription
Definition: Modules.h:190
CModule::OnPart
virtual void OnPart(const CNick &Nick, CChan &Channel, const CString &sMessage)
CModuleJob::m_sDescription
const CString m_sDescription
Definition: Modules.h:238
COptionalTranslation::Resolve
CString Resolve() const
Definition: Translation.h:91
CModules::OnChanMsg
bool OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
CModule::OnChanBufferEnding
virtual EModRet OnChanBufferEnding(CChan &Chan, CClient &Client)
Called after a channel buffer was played back to a client.
CModule::Unload
void Unload()
This function throws CModule::UNLOAD which causes this module to be unloaded.
Definition: Modules.h:455
CModules::IsClientCapSupported
bool IsClientCapSupported(CClient *pClient, const CString &sCap, bool bState)
CModule::OnKick
virtual void OnKick(const CNick &OpNick, const CString &sKickedNick, CChan &Channel, const CString &sMessage)
CModule::GetModNick
CString GetModNick() const
CFPTimer::SetFPCallback
void SetFPCallback(FPTimer_t p)
Definition: Modules.h:204
CModules::OnUserJoinMessage
bool OnUserJoinMessage(CJoinMessage &Message)
CModule::OnCTCPReply
virtual EModRet OnCTCPReply(CNick &Nick, CString &sMessage)
CModules::OnVoice2
bool OnVoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CAuthBase
Definition: Client.h:38
CModule::OnUserCTCPMessage
virtual EModRet OnUserCTCPMessage(CCTCPMessage &Message)
This module hook is called when a client sends a CTCP request.
CModules::OnDeop2
bool OnDeop2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CKickMessage
Definition: Message.h:304
CTimer::~CTimer
virtual ~CTimer()
CModule::OnWebPreRequest
virtual bool OnWebPreRequest(CWebSock &WebSock, const CString &sPageName)
For WebMods: Called before the list of registered SubPages will be checked.
CModule::SetClient
void SetClient(CClient *pClient)
CModule::HALT
@ HALT
This is the same as both CModule::HALTMODS and CModule::HALTCORE together.
Definition: Modules.h:430
CModule::OnRaw
virtual EModRet OnRaw(CString &sLine)
Called on any raw IRC line received from the IRC server.
CModule::t_s
CString t_s(const CString &sEnglish, const CString &sContext="") const
CModule::OnDeop2
virtual void OnDeop2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is deopped on a channel.
CModule::GetSavePath
const CString & GetSavePath() const
CInlineFormatMessage
Definition: ZNCString.h:673
CModule::OnModCommand
virtual void OnModCommand(const CString &sCommand)
Called when a command to your module is sent, e.g.
CModules::OnPrivCTCP
bool OnPrivCTCP(CNick &Nick, CString &sMessage)
CModules::SetUser
void SetUser(CUser *pUser)
Definition: Modules.h:1396
CModule::OnClientDisconnect
virtual void OnClientDisconnect()
Called when a client disconnected from ZNC.
CModule::OnRawMessage
virtual EModRet OnRawMessage(CMessage &Message)
Called on any raw message received from the IRC server.
CModule::m_sDataDir
CString m_sDataDir
Definition: Modules.h:1375
CModInfo::m_fLoader
ModLoader m_fLoader
Definition: Modules.h:323
CModule::RemTimer
bool RemTimer(CTimer *pTimer)
CModule::UNLOAD
@ UNLOAD
Your module can throw this enum at any given time.
Definition: Modules.h:446
CModule::GetClient
CClient * GetClient() const
Definition: Modules.h:1238
CModule::OnPrivActionMessage
virtual EModRet OnPrivActionMessage(CActionMessage &Message)
Called when we receive a private CTCP ACTION ("/me" in query) from IRC.
CModules::OnChanBufferStarting
bool OnChanBufferStarting(CChan &Chan, CClient &Client)
CModule::PutIRC
virtual bool PutIRC(const CString &sLine)
This function sends a given IRC line to the IRC server, if we are connected to one.
CModule::CancelJobs
void CancelJobs(const std::set< CModuleJob * > &sJobs)
CModules::OnUserPartMessage
bool OnUserPartMessage(CPartMessage &Message)
CModCommand::GetArgs
CString GetArgs() const
Definition: Modules.h:381
CModules::OnAddNetwork
bool OnAddNetwork(CIRCNetwork &Network, CString &sErrorRet)
CModules::FindModule
CModule * FindModule(const CString &sModule) const
CModule::m_Translation
CTranslationDomainRefHolder m_Translation
Definition: Modules.h:1379
CModules::OnChanCTCPMessage
bool OnChanCTCPMessage(CCTCPMessage &Message)
CModule::m_sDescription
CString m_sDescription
Definition: Modules.h:1363
TModLoad
CModule * TModLoad(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, CModInfo::EModuleType eType)
Definition: Modules.h:330
CModule::HasNV
bool HasNV(const CString &sName) const
Definition: Modules.h:1196
CJob
A job is a task which should run without blocking the main thread.
Definition: Threads.h:67
CModule::EndTimers
std::set< CTimer * >::const_iterator EndTimers() const
Definition: Modules.h:1127
CModule::CancelJob
void CancelJob(CModuleJob *pJob)
CModule::OnUserCTCPReply
virtual EModRet OnUserCTCPReply(CString &sTarget, CString &sMessage)
CSocket
Base Csock implementation to be used by modules.
Definition: Socket.h:247
CModule::t_p
CInlineFormatMessage t_p(const CString &sEnglish, const CString &sEnglishes, int iNum, const CString &sContext="") const
CModule::OnFailedLogin
virtual void OnFailedLogin(const CString &sUsername, const CString &sRemoteIP)
Called after a client login was rejected.
CModules::GetModPathInfo
static bool GetModPathInfo(CModInfo &ModInfo, const CString &sModule, const CString &sModPath, CString &sRetMsg)
CModInfo::EModuleType
EModuleType
Definition: Modules.h:246
CModule::OnChanPermission
virtual void OnChanPermission(const CNick &OpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
CModule::OnUserCTCP
virtual EModRet OnUserCTCP(CString &sTarget, CString &sMessage)
CModule::OnPrivCTCPMessage
virtual EModRet OnPrivCTCPMessage(CCTCPMessage &Message)
Called when we receive a private CTCP request from IRC.
CModule::OnUserJoin
virtual EModRet OnUserJoin(CString &sChannel, CString &sKey)
CModInfo::GlobalModule
@ GlobalModule
Definition: Modules.h:246
Translation.h
WebModules.h
CModule::OnChanAction
virtual EModRet OnChanAction(CNick &Nick, CChan &Channel, CString &sMessage)
CModule::OnUserTopicMessage
virtual EModRet OnUserTopicMessage(CTopicMessage &Message)
This module hook is called when a user wants to change a channel topic.
CModules::GetAvailableMods
static void GetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType=CModInfo::UserModule)
CModule::OnJoining
virtual EModRet OnJoining(CChan &Channel)
This module hook is called just before ZNC tries to join an IRC channel.
CUser
Definition: User.h:38
CFPTimer::RunJob
void RunJob() override
this is the method you should override
Definition: Modules.h:207
CTranslationDomainRefHolder
Definition: Translation.h:61
CModules
Definition: Modules.h:1388
CModCommand::GetDescription
CString GetDescription() const
Definition: Modules.h:382
CModules::OnClientConnect
bool OnClientConnect(CZNCSock *pSock, const CString &sHost, unsigned short uPort)
CModInfo::m_sName
CString m_sName
Definition: Modules.h:317
CModule::HandleCommand
bool HandleCommand(const CString &sLine)
This function tries to dispatch the given command via the correct instance of CModCommand.
CModule::GetWebFilesPath
virtual CString GetWebFilesPath()
CModule::OnPrivBufferPlayLine2
virtual EModRet OnPrivBufferPlayLine2(CClient &Client, CString &sLine, const timeval &tv)
main.h
CModule::OnClientCapLs
virtual void OnClientCapLs(CClient *pClient, SCString &ssCaps)
Called when a client told us CAP LS.
CModule::OnLoad
virtual bool OnLoad(const CString &sArgsi, CString &sMessage)
This module hook is called when a module is loaded.
CModule::m_sSockets
std::set< CSocket * > m_sSockets
Definition: Modules.h:1365
CModules::OnChanBufferPlayLine2
bool OnChanBufferPlayLine2(CChan &Chan, CClient &Client, CString &sLine, const timeval &tv)
CModInfo::GetLoader
ModLoader GetLoader() const
Definition: Modules.h:296
CModule::SaveRegistry
bool SaveRegistry() const
CModules::OnUserPart
bool OnUserPart(CString &sChannel, CString &sMessage)
CModule::GetModPath
const CString & GetModPath() const
Definition: Modules.h:1223
CModule::SetNV
bool SetNV(const CString &sName, const CString &sValue, bool bWriteToDisk=true)
CModules::OnNick
bool OnNick(const CNick &Nick, const CString &sNewNick, const std::vector< CChan * > &vChans)
CModules::OnChanNoticeMessage
bool OnChanNoticeMessage(CNoticeMessage &Message)
CModules::OnJoin
bool OnJoin(const CNick &Nick, CChan &Channel)
CModule::AddSubPage
virtual void AddSubPage(TWebSubPage spSubPage)
Registers a sub page for the sidebar.
Definition: Modules.h:513
CIRCNetwork
Definition: IRCNetwork.h:40
CModule::OnIRCConnected
virtual void OnIRCConnected()
This module hook is called after a successful login to IRC.
CModule::OnUserRawMessage
virtual EModRet OnUserRawMessage(CMessage &Message)
This module hook is called when a client sends any message to ZNC.
CModule::OnInvite
virtual EModRet OnInvite(const CNick &Nick, const CString &sChan)
Called when user is invited into a channel.
CModule::OnPrivMsg
virtual EModRet OnPrivMsg(CNick &Nick, CString &sMessage)
CModule::m_pManager
CSockManager * m_pManager
Definition: Modules.h:1370
CModules::FindModPath
static bool FindModPath(const CString &sModule, CString &sModPath, CString &sDataPath)
CModule::OnChanMsg
virtual EModRet OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
CModules::OnPrivBufferEnding
bool OnPrivBufferEnding(CQuery &Query, CClient &Client)
CModule::CONTINUE
@ CONTINUE
ZNC will continue event processing normally.
Definition: Modules.h:426
CModules::OnUserCTCPReplyMessage
bool OnUserCTCPReplyMessage(CCTCPMessage &Message)
CModules::OnModuleLoading
bool OnModuleLoading(const CString &sModName, const CString &sArgs, CModInfo::EModuleType eType, bool &bSuccess, CString &sRetMsg)
CModule::OnChanActionMessage
virtual EModRet OnChanActionMessage(CActionMessage &Message)
Called when we receive a channel CTCP ACTION ("/me" in a channel) from IRC.
COptionalTranslation
Definition: Translation.h:84
CModule::SetType
void SetType(CModInfo::EModuleType eType)
Definition: Modules.h:1213
CModule::OnUserPart
virtual EModRet OnUserPart(CString &sChannel, CString &sMessage)
CModules::OnBroadcast
bool OnBroadcast(CString &sMessage)
CModule::RemCommand
bool RemCommand(const CString &sCmd)
CModules::OnAddUser
bool OnAddUser(CUser &User, CString &sErrorRet)
CModule::OnIRCDisconnected
virtual void OnIRCDisconnected()
This module hook is called when a user gets disconnected from IRC.
CModules::OnIRCRegistration
bool OnIRCRegistration(CString &sPass, CString &sNick, CString &sIdent, CString &sRealName)
CModules::OnPrivAction
bool OnPrivAction(CNick &Nick, CString &sMessage)
CModInfo::operator<
bool operator<(const CModInfo &Info) const
Definition: Modules.h:266
CModules::m_pUser
CUser * m_pUser
Definition: Modules.h:1605
CModules::OnUserJoin
bool OnUserJoin(CString &sChannel, CString &sKey)
CModule::PutModNotice
virtual bool PutModNotice(const CString &sLine)
Send a notice from your module nick.
CModule::OnChanNoticeMessage
virtual EModRet OnChanNoticeMessage(CNoticeMessage &Message)
Called when we receive a channel NOTICE message from IRC.
CNick
Definition: Nick.h:29
CModules::OnOp2
bool OnOp2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CModules::OnCTCPReplyMessage
bool OnCTCPReplyMessage(CCTCPMessage &Message)
CModules::OnNumericMessage
bool OnNumericMessage(CNumericMessage &Message)
CModuleEntry::fpFillModInfo
void(* fpFillModInfo)(CModInfo &)
Definition: Modules.h:84
CModule::OnUserNotice
virtual EModRet OnUserNotice(CString &sTarget, CString &sMessage)
CModule::OnDevoice
virtual void OnDevoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CModule::OnPrivAction
virtual EModRet OnPrivAction(CNick &Nick, CString &sMessage)
CFPTimer
Definition: Modules.h:195
CModules::OnUserQuit
bool OnUserQuit(CString &sMessage)
CTimer::GetModule
CModule * GetModule() const
CZNCSock
Definition: Socket.h:27
CModuleEntry::pcCompileOptions
const char * pcCompileOptions
Definition: Modules.h:83
CModule
The base class for your own ZNC modules.
Definition: Modules.h:406
CModules::OnDeleteNetwork
bool OnDeleteNetwork(CIRCNetwork &Network)
CModCommand::GetFunction
CmdFunc GetFunction() const
Definition: Modules.h:380
CModules::GetModDirs
static ModDirList GetModDirs()
CModule::OnJoin
virtual void OnJoin(const CNick &Nick, CChan &Channel)
CModInfo::m_bHasArgs
bool m_bHasArgs
Definition: Modules.h:322
CModules::OnModuleUnloading
bool OnModuleUnloading(CModule *pModule, bool &bSuccess, CString &sRetMsg)
CModule::m_sModPath
CString m_sModPath
Definition: Modules.h:1378
CModule::GetDLL
ModHandle GetDLL()
Definition: Modules.h:1052
CTable
Generate a grid-like or list-like output from a given input.
Definition: Utils.h:171
CModule::OnNumericMessage
virtual EModRet OnNumericMessage(CNumericMessage &Message)
Called when a numeric message is received from the IRC server.
CModules::OnServerCapResult
bool OnServerCapResult(const CString &sCap, bool bSuccess)
CCoreTranslationMixin
Definition: Translation.h:104
CModules::GetClient
CClient * GetClient() const
Definition: Modules.h:1401
CModule::OnUserActionMessage
virtual EModRet OnUserActionMessage(CActionMessage &Message)
Called when a client sends a CTCP ACTION request ("/me").
CModule::AddSocket
bool AddSocket(CSocket *pSocket)
CModules::OnUserTextMessage
bool OnUserTextMessage(CTextMessage &Message)
CModule::ValidateWebRequestCSRFCheck
virtual bool ValidateWebRequestCSRFCheck(CWebSock &WebSock, const CString &sPageName)
If ValidateWebRequestCSRFCheck returned false, a CSRF error will be printed.
CModules::GetUser
CUser * GetUser() const
Definition: Modules.h:1399
CModules::OnDeleteUser
bool OnDeleteUser(CUser &User)
CModule::EModRet
EModRet
This enum is just used for return from module hooks.
Definition: Modules.h:422
CModules::OnChanCTCP
bool OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
CModule::OnOp
virtual void OnOp(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CModuleJob::GetDescription
const CString & GetDescription() const
Definition: Modules.h:232
CModule::OnMode2
virtual void OnMode2(const CNick *pOpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
Called on an individual channel mode change.
CModule::SetModPath
void SetModPath(const CString &s)
Definition: Modules.h:1215
CModule::OnGetAvailableMods
virtual void OnGetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType)
Called when list of available mods is requested.
CModInfo::SetDescription
void SetDescription(const CString &s)
Definition: Modules.h:303
CModule::EndSockets
std::set< CSocket * >::const_iterator EndSockets() const
Definition: Modules.h:1142
CModuleEntry
C-style entry point to the module.
Definition: Modules.h:80
CModules::OnIRCDisconnected
bool OnIRCDisconnected()
CModules::OnPrivActionMessage
bool OnPrivActionMessage(CActionMessage &Message)
CModule::OnGetModInfo
virtual EModRet OnGetModInfo(CModInfo &ModInfo, const CString &sModule, bool &bSuccess, CString &sRetMsg)
Called when info about a module is needed.
CModule::FindCommand
const CModCommand * FindCommand(const CString &sCmd) const
CFPTimer::~CFPTimer
virtual ~CFPTimer()
Definition: Modules.h:202
CModules::OnPart
bool OnPart(const CNick &Nick, CChan &Channel, const CString &sMessage)
CModule::OnNick
virtual void OnNick(const CNick &Nick, const CString &sNewNick, const std::vector< CChan * > &vChans)
CNoticeMessage
Definition: Message.h:291
CModule::OnModNotice
virtual void OnModNotice(const CString &sMessage)
Called when a your module nick was sent a notice.
CModInfo::SetPath
void SetPath(const CString &s)
Definition: Modules.h:302
CModuleJob
A CJob version which can be safely used in modules.
Definition: Modules.h:220
FPTimer_t
void(* FPTimer_t)(CModule *, CFPTimer *)
Definition: Modules.h:193
CModules::OnRawMessage
bool OnRawMessage(CMessage &Message)
CModule::ClearSubPages
virtual void ClearSubPages()
Removes all registered (AddSubPage'd) SubPages.
Definition: Modules.h:518
CModule::OnChanNotice
virtual EModRet OnChanNotice(CNick &Nick, CChan &Channel, CString &sMessage)
CModules::OnGetAvailableMods
bool OnGetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType)
CModules::OnPrivBufferPlayLine
bool OnPrivBufferPlayLine(CClient &Client, CString &sLine)
CModules::GetModInfo
static bool GetModInfo(CModInfo &ModInfo, const CString &sModule, CString &sRetMsg)
CModules::OnUserMsg
bool OnUserMsg(CString &sTarget, CString &sMessage)
CModule::OnIRCConnectionError
virtual void OnIRCConnectionError(CIRCSock *pIRCSock)
This module hook is called when a CIRCSock fails to connect or a module returned HALTCORE from OnIRCC...
CModules::OnChanActionMessage
bool OnChanActionMessage(CActionMessage &Message)
CZNC
Definition: znc.h:38
CModules::OnChanPermission3
bool OnChanPermission3(const CNick *pOpNick, const CNick &Nick, CChan &Channel, char cMode, bool bAdded, bool bNoChange)
CModInfo::CModInfo
CModInfo(const CString &sName, const CString &sPath, EModuleType eType)
Definition: Modules.h:254
CModules::OnPrivTextMessage
bool OnPrivTextMessage(CTextMessage &Message)
CModules::OnVoice
bool OnVoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
CModule::OnModuleUnloading
virtual EModRet OnModuleUnloading(CModule *pModule, bool &bSuccess, CString &sRetMsg)
Called when a module is going to be unloaded.
CModule::FindSocket
CSocket * FindSocket(const CString &sSockName)
CModule::m_sJobs
std::set< CModuleJob * > m_sJobs
Definition: Modules.h:1367
CModules::OnRaw
bool OnRaw(CString &sLine)
CModule::OnAddUser
virtual EModRet OnAddUser(CUser &User, CString &sErrorRet)
This module hook is called when a user is being added.
CModules::OnCTCPReply
bool OnCTCPReply(CNick &Nick, CString &sMessage)
CModule::FindTimer
CTimer * FindTimer(const CString &sLabel)
CModule::UnlinkJob
bool UnlinkJob(CModuleJob *pJob)
CModule::OnUserQuitMessage
virtual EModRet OnUserQuitMessage(CQuitMessage &Message)
This module hook is called when a client quits ZNC.
CModules::OnSendToIRC
bool OnSendToIRC(CString &sLine)
CTimer::CTimer
CTimer(CModule *pModule, unsigned int uInterval, unsigned int uCycles, const CString &sLabel, const CString &sDescription)
CModInfo::SetArgsHelpText
void SetArgsHelpText(const CString &s)
Definition: Modules.h:305
CModule::OnBoot
virtual bool OnBoot()
This module hook is called during ZNC startup.
CNumericMessage
Definition: Message.h:298
CModules::OnIRCConnecting
bool OnIRCConnecting(CIRCSock *pIRCSock)
CModules::OnUnknownUserRaw
bool OnUnknownUserRaw(CClient *pClient, CString &sLine)
CModules::OnLoginAttempt
bool OnLoginAttempt(std::shared_ptr< CAuthBase > Auth)
CModule::SetDescription
void SetDescription(const CString &s)
Definition: Modules.h:1214
CModules::OnInvite
bool OnInvite(const CNick &Nick, const CString &sChan)
CPartMessage
Definition: Message.h:315
CModule::OnJoinMessage
virtual void OnJoinMessage(CJoinMessage &Message)
Called when a nick joins a channel.
CModule::OnServerCapAvailable
virtual bool OnServerCapAvailable(const CString &sCap)
Called for every CAP received via CAP LS from server.
CModule::OnUserMsg
virtual EModRet OnUserMsg(CString &sTarget, CString &sMessage)
CModule::OnChanBufferPlayLine2
virtual EModRet OnChanBufferPlayLine2(CChan &Chan, CClient &Client, CString &sLine, const timeval &tv)
Message.h
CModule::OnUserTextMessage
virtual EModRet OnUserTextMessage(CTextMessage &Message)
This module hook is called when a user sends a PRIVMSG message.
CModule::WebRequiresAdmin
virtual bool WebRequiresAdmin()
Return true if this module should only be usable for admins on the web.
Definition: Modules.h:477
CModules::OnModNotice
bool OnModNotice(const CString &sMessage)
CModule::OnTopic
virtual EModRet OnTopic(CNick &Nick, CChan &Channel, CString &sTopic)
CModule::OnQuitMessage
virtual void OnQuitMessage(CQuitMessage &Message, const std::vector< CChan * > &vChans)
Called when a nick quit from IRC.