ZNC  trunk
Modules.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2024 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 <memory>
29 #include <set>
30 #include <queue>
31 #include <sys/time.h>
32 
33 // Forward Declarations
34 class CAuthBase;
35 class CChan;
36 class CQuery;
37 class CIRCNetwork;
38 class CClient;
39 class CWebSock;
40 class CTemplate;
41 class CIRCSock;
42 class CModule;
43 class CModInfo;
44 // !Forward Declarations
45 
46 #ifdef REQUIRESSL
47 #ifndef HAVE_LIBSSL
48 #error -
49 #error -
50 #error This module only works when ZNC is compiled with OpenSSL support
51 #error -
52 #error -
53 #endif
54 #endif
55 
56 #ifdef BUILD_WITH_CMAKE
57 #include <znc/znc_export_lib_export.h>
58 #elif HAVE_VISIBILITY
59 #define ZNC_EXPORT_LIB_EXPORT __attribute__((__visibility__("default")))
60 #else
61 #define ZNC_EXPORT_LIB_EXPORT
62 #endif
63 
81 struct CModuleEntry {
82  const char* pcVersion;
83  const char* pcVersionExtra;
84  const char* pcCompileOptions;
86 };
87 
88 #define MODCOMMONDEFS(CLASS, DESCRIPTION, TYPE) \
89  static void FillModInfo(CModInfo& Info) { \
90  auto t_s = [&](const CString& sEnglish, \
91  const CString& sContext = "") { \
92  return sEnglish.empty() ? "" : Info.t_s(sEnglish, sContext); \
93  }; \
94  t_s(CString()); /* Don't warn about unused t_s */ \
95  Info.SetDescription(DESCRIPTION); \
96  Info.SetDefaultType(TYPE); \
97  Info.AddType(TYPE); \
98  Info.SetLoader(TModLoad<CLASS>); \
99  TModInfo<CLASS>(Info); \
100  } \
101  extern "C" { \
102  /* A global variable leads to ODR violation when several modules are \
103  * loaded. But a static variable inside a function works. */ \
104  ZNC_EXPORT_LIB_EXPORT const CModuleEntry* ZNCModuleEntry(); \
105  ZNC_EXPORT_LIB_EXPORT const CModuleEntry* ZNCModuleEntry() { \
106  static const CModuleEntry ThisModule = {VERSION_STR, VERSION_EXTRA, \
107  ZNC_COMPILE_OPTIONS_STRING, \
108  FillModInfo}; \
109  return &ThisModule; \
110  } \
111  }
112 
128 #define MODCONSTRUCTOR(CLASS) \
129  CLASS(ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork, \
130  const CString& sModName, const CString& sModPath, \
131  CModInfo::EModuleType eType) \
132  : CModule(pDLL, pUser, pNetwork, sModName, sModPath, eType)
133 
134 // User Module Macros
136 #define USERMODULEDEFS(CLASS, DESCRIPTION) \
137  MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::UserModule)
138 // !User Module Macros
139 
140 // Global Module Macros
142 #define GLOBALMODULEDEFS(CLASS, DESCRIPTION) \
143  MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::GlobalModule)
144 // !Global Module Macros
145 
146 // Network Module Macros
148 #define NETWORKMODULEDEFS(CLASS, DESCRIPTION) \
149  MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::NetworkModule)
150 // !Network Module Macros
151 
158 #define MODULEDEFS(CLASS, DESCRIPTION) NETWORKMODULEDEFS(CLASS, DESCRIPTION)
159 
160 // Forward Declarations
161 class CZNC;
162 class CUser;
163 class CNick;
164 class CChan;
165 class CModule;
166 class CFPTimer;
167 class CSockManager;
168 // !Forward Declarations
169 
170 class CCapability {
171  public:
172  virtual ~CCapability() = default;
173  virtual void OnServerChangedSupport(CIRCNetwork* pNetwork, bool bState) {}
174  virtual void OnClientChangedSupport(CClient* pClient, bool bState) {}
175 
176  CModule* GetModule() { return m_pModule; }
177  void SetModule(CModule* p) { m_pModule = p; }
178 
179  protected:
180  CModule* m_pModule = nullptr;
181 };
182 
183 class CTimer : public CCron {
184  public:
185  CTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles,
186  const CString& sLabel, const CString& sDescription);
187 
188  virtual ~CTimer();
189 
190  CTimer(const CTimer&) = delete;
191  CTimer& operator=(const CTimer&) = delete;
192 
193  // Setters
194  void SetModule(CModule* p);
195  void SetDescription(const CString& s);
196  // !Setters
197 
198  // Getters
199  CModule* GetModule() const;
200  const CString& GetDescription() const;
201  // !Getters
202  private:
203  protected:
206 };
207 
208 typedef void (*FPTimer_t)(CModule*, CFPTimer*);
209 
210 class CFPTimer : public CTimer {
211  public:
212  CFPTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles,
213  const CString& sLabel, const CString& sDescription)
214  : CTimer(pModule, uInterval, uCycles, sLabel, sDescription),
215  m_pFBCallback(nullptr) {}
216 
217  virtual ~CFPTimer() {}
218 
219  void SetFPCallback(FPTimer_t p) { m_pFBCallback = p; }
220 
221  protected:
222  void RunJob() override {
223  if (m_pFBCallback) {
224  m_pFBCallback(m_pModule, this);
225  }
226  }
227 
228  private:
229  FPTimer_t m_pFBCallback;
230 };
231 
232 #ifdef HAVE_PTHREAD
233 class CModuleJob : public CJob {
236  public:
237  CModuleJob(CModule* pModule, const CString& sName, const CString& sDesc)
238  : CJob(), m_pModule(pModule), m_sName(sName), m_sDescription(sDesc) {}
239  virtual ~CModuleJob();
240 
241  CModuleJob(const CModuleJob&) = delete;
242  CModuleJob& operator=(const CModuleJob&) = delete;
243 
244  // Getters
245  CModule* GetModule() const { return m_pModule; }
246  const CString& GetName() const { return m_sName; }
247  const CString& GetDescription() const { return m_sDescription; }
248  // !Getters
249 
250  protected:
254 };
255 #endif
256 
257 typedef void* ModHandle;
258 
259 class CModInfo {
260  public:
262 
263  typedef CModule* (*ModLoader)(ModHandle p, CUser* pUser,
264  CIRCNetwork* pNetwork,
265  const CString& sModName,
266  const CString& sModPath, EModuleType eType);
267 
269  CModInfo(const CString& sName, const CString& sPath, EModuleType eType)
270  : m_seType(),
271  m_eDefaultType(eType),
272  m_sName(sName),
273  m_sPath(sPath),
274  m_sDescription(""),
275  m_sWikiPage(""),
276  m_sArgsHelpText(""),
277  m_bHasArgs(false),
278  m_fLoader(nullptr) {}
280 
281  bool operator<(const CModInfo& Info) const {
282  return (GetName() < Info.GetName());
283  }
284 
285  bool SupportsType(EModuleType eType) const {
286  return m_seType.find(eType) != m_seType.end();
287  }
288 
289  void AddType(EModuleType eType) { m_seType.insert(eType); }
290 
292  switch (eType) {
293  case GlobalModule:
294  return "Global";
295  case UserModule:
296  return "User";
297  case NetworkModule:
298  return "Network";
299  default:
300  return "UNKNOWN";
301  }
302  }
303 
304  // Getters
305  const CString& GetName() const { return m_sName; }
306  const CString& GetPath() const { return m_sPath; }
307  const CString& GetDescription() const { return m_sDescription; }
308  const CString& GetWikiPage() const { return m_sWikiPage; }
309  const CString& GetArgsHelpText() const { return m_sArgsHelpText; }
310  bool GetHasArgs() const { return m_bHasArgs; }
311  ModLoader GetLoader() const { return m_fLoader; }
313  // !Getters
314 
315  // Setters
316  void SetName(const CString& s) { m_sName = s; }
317  void SetPath(const CString& s) { m_sPath = s; }
318  void SetDescription(const CString& s) { m_sDescription = s; }
319  void SetWikiPage(const CString& s) { m_sWikiPage = s; }
320  void SetArgsHelpText(const CString& s) { m_sArgsHelpText = s; }
321  void SetHasArgs(bool b = false) { m_bHasArgs = b; }
322  void SetLoader(ModLoader fLoader) { m_fLoader = fLoader; }
323  void SetDefaultType(EModuleType eType) { m_eDefaultType = eType; }
324  // !Setters
325 
326  CString t_s(const CString& sEnglish, const CString& sContext = "") const;
327 
328  private:
329  protected:
330  std::set<EModuleType> m_seType;
339 };
340 
341 template <class M>
342 void TModInfo(CModInfo& Info) {}
343 
344 template <class M>
346  const CString& sModName, const CString& sModPath,
347  CModInfo::EModuleType eType) {
348  return new M(p, pUser, pNetwork, sModName, sModPath, eType);
349 }
350 
353  public:
355  typedef void (CModule::*ModCmdFunc)(const CString& sLine);
356  typedef std::function<void(const CString& sLine)> CmdFunc;
357 
359  CModCommand();
360 
367  CModCommand(const CString& sCmd, CModule* pMod, ModCmdFunc func,
368  const CString& sArgs, const CString& sDesc);
369  CModCommand(const CString& sCmd, CmdFunc func,
370  const COptionalTranslation& Args,
371  const COptionalTranslation& Desc);
372 
376  CModCommand(const CModCommand& other) = default;
377 
381  CModCommand& operator=(const CModCommand& other) = default;
382 
386  static void InitHelp(CTable& Table);
387 
392  void AddHelp(CTable& Table) const;
393 
394  const CString& GetCommand() const { return m_sCmd; }
395  CmdFunc GetFunction() const { return m_pFunc; }
396  CString GetArgs() const { return m_Args.Resolve(); }
397  CString GetDescription() const { return m_Desc.Resolve(); }
398 
399  void Call(const CString& sLine) const { m_pFunc(sLine); }
400 
401  private:
402  CString m_sCmd;
403  CmdFunc m_pFunc;
404  COptionalTranslation m_Args;
405  COptionalTranslation m_Desc;
406 };
407 
421 class CModule {
422  public:
423  CModule(
424  ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork,
425  const CString& sModName, const CString& sDataDir,
426  CModInfo::EModuleType eType =
427  CModInfo::NetworkModule); // TODO: remove default value in ZNC 2.x
428  virtual ~CModule();
429 
430  CModule(const CModule&) = delete;
431  CModule& operator=(const CModule&) = delete;
432 
437  typedef enum {
441  CONTINUE = 1,
445  HALT = 2,
449  HALTMODS = 3,
455  } EModRet;
456 
457  typedef enum {
462  } EModException;
463 
464  void SetUser(CUser* pUser);
465  void SetNetwork(CIRCNetwork* pNetwork);
466  void SetClient(CClient* pClient);
467 
470  void Unload() { throw UNLOAD; }
471 
478  virtual bool OnLoad(const CString& sArgsi, CString& sMessage);
483  virtual bool OnBoot();
484 
488  virtual bool WebRequiresLogin() { return true; }
492  virtual bool WebRequiresAdmin() { return false; }
496  virtual CString GetWebMenuTitle() { return ""; }
497  virtual CString GetWebPath();
498  virtual CString GetWebFilesPath();
507  virtual bool OnWebPreRequest(CWebSock& WebSock, const CString& sPageName);
517  virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName,
518  CTemplate& Tmpl);
524  virtual bool ValidateWebRequestCSRFCheck(CWebSock& WebSock, const CString& sPageName);
528  virtual void AddSubPage(TWebSubPage spSubPage) {
529  m_vSubPages.push_back(spSubPage);
530  }
533  virtual void ClearSubPages() { m_vSubPages.clear(); }
537  virtual VWebSubPages& GetSubPages() { return m_vSubPages; }
547  virtual bool OnEmbeddedWebRequest(CWebSock& WebSock,
548  const CString& sPageName,
549  CTemplate& Tmpl);
550 
552  virtual void OnPreRehash();
554  virtual void OnPostRehash();
556  virtual void OnIRCDisconnected();
558  virtual void OnIRCConnected();
564  virtual EModRet OnIRCConnecting(CIRCSock* pIRCSock);
569  virtual void OnIRCConnectionError(CIRCSock* pIRCSock);
580  virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick,
581  CString& sIdent, CString& sRealName);
586  virtual EModRet OnBroadcast(CString& sMessage);
587 
599  virtual void OnChanPermission3(const CNick* pOpNick, const CNick& Nick,
600  CChan& Channel, char cMode,
601  bool bAdded, bool bNoChange);
603  virtual void OnChanPermission2(const CNick* pOpNick, const CNick& Nick,
604  CChan& Channel, unsigned char uMode,
605  bool bAdded, bool bNoChange);
607  virtual void OnChanPermission(const CNick& OpNick, const CNick& Nick,
608  CChan& Channel, unsigned char uMode,
609  bool bAdded, bool bNoChange);
611  virtual void OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
612  bool bNoChange);
613  virtual void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel,
614  bool bNoChange);
616  virtual void OnDeop2(const CNick* pOpNick, const CNick& Nick,
617  CChan& Channel, bool bNoChange);
618  virtual void OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel,
619  bool bNoChange);
621  virtual void OnVoice2(const CNick* pOpNick, const CNick& Nick,
622  CChan& Channel, bool bNoChange);
623  virtual void OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
624  bool bNoChange);
626  virtual void OnDevoice2(const CNick* pOpNick, const CNick& Nick,
627  CChan& Channel, bool bNoChange);
628  virtual void OnDevoice(const CNick& OpNick, const CNick& Nick,
629  CChan& Channel, bool bNoChange);
638  virtual void OnMode2(const CNick* pOpNick, CChan& Channel, char uMode,
639  const CString& sArg, bool bAdded, bool bNoChange);
640  virtual void OnMode(const CNick& OpNick, CChan& Channel, char uMode,
641  const CString& sArg, bool bAdded, bool bNoChange);
649  virtual void OnRawMode2(const CNick* pOpNick, CChan& Channel,
650  const CString& sModes, const CString& sArgs);
651  virtual void OnRawMode(const CNick& OpNick, CChan& Channel,
652  const CString& sModes, const CString& sArgs);
653 
659  virtual EModRet OnRaw(CString& sLine);
665  virtual EModRet OnRawMessage(CMessage& Message);
666 
672  virtual EModRet OnNumericMessage(CNumericMessage& Message);
673 
678  virtual EModRet OnStatusCommand(CString& sCommand);
682  virtual void OnModCommand(const CString& sCommand);
689  virtual void OnUnknownModCommand(const CString& sCommand);
693  virtual void OnModNotice(const CString& sMessage);
698  virtual void OnModCTCP(const CString& sMessage);
699 
705  virtual void OnQuitMessage(CQuitMessage& Message,
706  const std::vector<CChan*>& vChans);
708  virtual void OnQuit(const CNick& Nick, const CString& sMessage,
709  const std::vector<CChan*>& vChans);
710 
716  virtual void OnNickMessage(CNickMessage& Message,
717  const std::vector<CChan*>& vChans);
719  virtual void OnNick(const CNick& Nick, const CString& sNewNick,
720  const std::vector<CChan*>& vChans);
721 
726  virtual void OnKickMessage(CKickMessage& Message);
728  virtual void OnKick(const CNick& OpNick, const CString& sKickedNick,
729  CChan& Channel, const CString& sMessage);
730 
735  virtual EModRet OnJoining(CChan& Channel);
736 
741  virtual void OnJoinMessage(CJoinMessage& Message);
743  virtual void OnJoin(const CNick& Nick, CChan& Channel);
744 
749  virtual void OnPartMessage(CPartMessage& Message);
751  virtual void OnPart(const CNick& Nick, CChan& Channel,
752  const CString& sMessage);
753 
760  virtual EModRet OnInvite(const CNick& Nick, const CString& sChan);
761 
767  virtual EModRet OnChanBufferStarting(CChan& Chan, CClient& Client);
773  virtual EModRet OnChanBufferEnding(CChan& Chan, CClient& Client);
774 
780  virtual EModRet OnChanBufferPlayMessage(CMessage& Message);
782  virtual EModRet OnChanBufferPlayLine2(CChan& Chan, CClient& Client,
783  CString& sLine, const timeval& tv);
785  virtual EModRet OnChanBufferPlayLine(CChan& Chan, CClient& Client,
786  CString& sLine);
787 
794  virtual EModRet OnPrivBufferStarting(CQuery& Query, CClient& Client);
801  virtual EModRet OnPrivBufferEnding(CQuery& Query, CClient& Client);
802 
808  virtual EModRet OnPrivBufferPlayMessage(CMessage& Message);
810  virtual EModRet OnPrivBufferPlayLine2(CClient& Client, CString& sLine,
811  const timeval& tv);
813  virtual EModRet OnPrivBufferPlayLine(CClient& Client, CString& sLine);
814 
816  virtual void OnClientLogin();
818  virtual void OnClientDisconnect();
819 
824  virtual EModRet OnUserRaw(CString& sLine);
830  virtual EModRet OnUserRawMessage(CMessage& Message);
831 
837  virtual EModRet OnUserCTCPReplyMessage(CCTCPMessage& Message);
839  virtual EModRet OnUserCTCPReply(CString& sTarget, CString& sMessage);
840 
848  virtual EModRet OnUserCTCPMessage(CCTCPMessage& Message);
850  virtual EModRet OnUserCTCP(CString& sTarget, CString& sMessage);
851 
858  virtual EModRet OnUserActionMessage(CActionMessage& Message);
860  virtual EModRet OnUserAction(CString& sTarget, CString& sMessage);
861 
867  virtual EModRet OnUserTextMessage(CTextMessage& Message);
869  virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage);
870 
876  virtual EModRet OnUserNoticeMessage(CNoticeMessage& Message);
878  virtual EModRet OnUserNotice(CString& sTarget, CString& sMessage);
879 
885  virtual EModRet OnUserJoinMessage(CJoinMessage& Message);
887  virtual EModRet OnUserJoin(CString& sChannel, CString& sKey);
888 
894  virtual EModRet OnUserPartMessage(CPartMessage& Message);
896  virtual EModRet OnUserPart(CString& sChannel, CString& sMessage);
897 
903  virtual EModRet OnUserTopicMessage(CTopicMessage& Message);
905  virtual EModRet OnUserTopic(CString& sChannel, CString& sTopic);
906 
911  virtual EModRet OnUserTopicRequest(CString& sChannel);
912 
918  virtual EModRet OnUserQuitMessage(CQuitMessage& Message);
920  virtual EModRet OnUserQuit(CString& sMessage);
921 
927  virtual EModRet OnCTCPReplyMessage(CCTCPMessage& Message);
929  virtual EModRet OnCTCPReply(CNick& Nick, CString& sMessage);
930 
936  virtual EModRet OnPrivCTCPMessage(CCTCPMessage& Message);
938  virtual EModRet OnPrivCTCP(CNick& Nick, CString& sMessage);
939 
945  virtual EModRet OnChanCTCPMessage(CCTCPMessage& Message);
947  virtual EModRet OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
948 
954  virtual EModRet OnPrivActionMessage(CActionMessage& Message);
956  virtual EModRet OnPrivAction(CNick& Nick, CString& sMessage);
957 
963  virtual EModRet OnChanActionMessage(CActionMessage& Message);
965  virtual EModRet OnChanAction(CNick& Nick, CChan& Channel,
966  CString& sMessage);
967 
973  virtual EModRet OnPrivTextMessage(CTextMessage& Message);
975  virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage);
976 
982  virtual EModRet OnChanTextMessage(CTextMessage& Message);
984  virtual EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
985 
991  virtual EModRet OnPrivNoticeMessage(CNoticeMessage& Message);
993  virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage);
994 
1000  virtual EModRet OnChanNoticeMessage(CNoticeMessage& Message);
1002  virtual EModRet OnChanNotice(CNick& Nick, CChan& Channel,
1003  CString& sMessage);
1004 
1010  virtual EModRet OnTopicMessage(CTopicMessage& Message);
1012  virtual EModRet OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
1013 
1021  virtual bool OnServerCapAvailable(const CString& sCap);
1032  virtual bool OnServerCap302Available(const CString& sCap, const CString& sValue);
1040  virtual void OnServerCapResult(const CString& sCap, bool bSuccess);
1041 
1047  virtual EModRet OnTimerAutoJoin(CChan& Channel);
1048 
1055  virtual EModRet OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1060  virtual EModRet OnDeleteNetwork(CIRCNetwork& Network);
1061 
1068  virtual EModRet OnSendToClientMessage(CMessage& Message);
1070  virtual EModRet OnSendToClient(CString& sLine, CClient& Client);
1071 
1078  virtual EModRet OnSendToIRCMessage(CMessage& Message);
1080  virtual EModRet OnSendToIRC(CString& sLine);
1081 
1082  ModHandle GetDLL() { return m_pDLL; }
1083 
1089  virtual bool PutIRC(const CString& sLine);
1095  virtual bool PutIRC(const CMessage& Message);
1103  virtual bool PutUser(const CString& sLine);
1110  virtual bool PutStatus(const CString& sLine);
1117  virtual bool PutModule(const CString& sLine);
1123  virtual unsigned int PutModule(const CTable& table);
1130  virtual bool PutModNotice(const CString& sLine);
1131 
1133  const CString& GetModName() const { return m_sModName; }
1134 
1138  CString GetModNick() const;
1139 
1144  const CString& GetModDataDir() const { return m_sDataDir; }
1145 
1146  // Timer stuff
1147  bool AddTimer(CTimer* pTimer);
1148  bool AddTimer(FPTimer_t pFBCallback, const CString& sLabel, u_int uInterval,
1149  u_int uCycles = 0, const CString& sDescription = "");
1150  bool RemTimer(CTimer* pTimer);
1151  bool RemTimer(const CString& sLabel);
1152  bool UnlinkTimer(CTimer* pTimer);
1153  CTimer* FindTimer(const CString& sLabel);
1154  std::set<CTimer*>::const_iterator BeginTimers() const {
1155  return m_sTimers.begin();
1156  }
1157  std::set<CTimer*>::const_iterator EndTimers() const {
1158  return m_sTimers.end();
1159  }
1160  virtual void ListTimers();
1161  // !Timer stuff
1162 
1163  // Socket stuff
1164  bool AddSocket(CSocket* pSocket);
1165  bool RemSocket(CSocket* pSocket);
1166  bool RemSocket(const CString& sSockName);
1167  bool UnlinkSocket(CSocket* pSocket);
1168  CSocket* FindSocket(const CString& sSockName);
1169  std::set<CSocket*>::const_iterator BeginSockets() const {
1170  return m_sSockets.begin();
1171  }
1172  std::set<CSocket*>::const_iterator EndSockets() const {
1173  return m_sSockets.end();
1174  }
1175  virtual void ListSockets();
1176 // !Socket stuff
1177 
1178 #ifdef HAVE_PTHREAD
1179  // Job stuff
1180  void AddJob(CModuleJob* pJob);
1181  void CancelJob(CModuleJob* pJob);
1182  bool CancelJob(const CString& sJobName);
1183  void CancelJobs(const std::set<CModuleJob*>& sJobs);
1184  bool UnlinkJob(CModuleJob* pJob);
1185 // !Job stuff
1186 #endif
1187 
1188  // Command stuff
1190  void AddHelpCommand();
1192  bool AddCommand(const CModCommand& Command);
1195  bool AddCommand(const CString& sCmd, CModCommand::ModCmdFunc func,
1196  const CString& sArgs = "", const CString& sDesc = "");
1199  bool AddCommand(const CString& sCmd, const COptionalTranslation& Args,
1200  const COptionalTranslation& Desc,
1201  std::function<void(const CString& sLine)> func);
1203  bool RemCommand(const CString& sCmd);
1205  const CModCommand* FindCommand(const CString& sCmd) const;
1213  bool HandleCommand(const CString& sLine);
1217  void HandleHelpCommand(const CString& sLine = "");
1218  // !Command stuff
1219 
1220  bool LoadRegistry();
1221  bool SaveRegistry() const;
1222  bool MoveRegistry(const CString& sPath);
1223  bool SetNV(const CString& sName, const CString& sValue,
1224  bool bWriteToDisk = true);
1225  CString GetNV(const CString& sName) const;
1226  bool HasNV(const CString& sName) const {
1227  return m_mssRegistry.find(sName) != m_mssRegistry.end();
1228  }
1229  bool DelNV(const CString& sName, bool bWriteToDisk = true);
1230  MCString::iterator FindNV(const CString& sName) {
1231  return m_mssRegistry.find(sName);
1232  }
1233  MCString::iterator EndNV() { return m_mssRegistry.end(); }
1234  MCString::iterator BeginNV() { return m_mssRegistry.begin(); }
1235  void DelNV(MCString::iterator it) { m_mssRegistry.erase(it); }
1236  bool ClearNV(bool bWriteToDisk = true);
1237 
1238  const CString& GetSavePath() const;
1239  CString ExpandString(const CString& sStr) const;
1240  CString& ExpandString(const CString& sStr, CString& sRet) const;
1241 
1242  // Setters
1243  void SetType(CModInfo::EModuleType eType) { m_eType = eType; }
1244  void SetDescription(const CString& s) { m_sDescription = s; }
1245  void SetModPath(const CString& s) { m_sModPath = s; }
1246  void SetArgs(const CString& s) { m_sArgs = s; }
1247  // !Setters
1248 
1249  // Getters
1251  const CString& GetDescription() const { return m_sDescription; }
1252  const CString& GetArgs() const { return m_sArgs; }
1253  const CString& GetModPath() const { return m_sModPath; }
1254 
1260  CUser* GetUser() const { return m_pUser; }
1264  CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1268  CClient* GetClient() const { return m_pClient; }
1269  CSockManager* GetManager() const { return m_pManager; }
1270  // !Getters
1271 
1272  // Global Modules
1279  virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
1284  virtual EModRet OnDeleteUser(CUser& User);
1291  virtual void OnClientConnect(CZNCSock* pSock, const CString& sHost,
1292  unsigned short uPort);
1299  virtual EModRet OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1304  virtual void OnFailedLogin(const CString& sUsername,
1305  const CString& sRemoteIP);
1312  virtual EModRet OnUnknownUserRaw(CClient* pClient, CString& sLine);
1313  virtual EModRet OnUnknownUserRawMessage(CMessage& Message);
1314 
1316  virtual void OnClientAttached();
1318  virtual void OnClientDetached();
1319 
1320 #ifndef SWIG
1321 
1334  void AddServerDependentCapability(const CString& sName, std::unique_ptr<CCapability> pCap);
1335 #endif
1336 
1344  virtual void OnClientCapLs(CClient* pClient, SCString& ssCaps);
1351  virtual bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1352  bool bState);
1364  virtual void OnClientCapRequest(CClient* pClient, const CString& sCap,
1365  bool bState);
1366 
1376  virtual EModRet OnModuleLoading(const CString& sModName,
1377  const CString& sArgs,
1378  CModInfo::EModuleType eType, bool& bSuccess,
1379  CString& sRetMsg);
1387  virtual EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess,
1388  CString& sRetMsg);
1396  virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
1397  bool& bSuccess, CString& sRetMsg);
1402  virtual void OnGetAvailableMods(std::set<CModInfo>& ssMods,
1403  CModInfo::EModuleType eType);
1404  // !Global Modules
1405 
1406 #ifndef SWIG
1407  // Translation
1408  CString t_s(const CString& sEnglish, const CString& sContext = "") const;
1409  CInlineFormatMessage t_f(const CString& sEnglish,
1410  const CString& sContext = "") const;
1411  CInlineFormatMessage t_p(const CString& sEnglish, const CString& sEnglishes,
1412  int iNum, const CString& sContext = "") const;
1413  CDelayedTranslation t_d(const CString& sEnglish,
1414  const CString& sContext = "") const;
1415 #endif
1416 
1417  // Default implementations of several callbacks to make
1418  // AddServerDependentCapability work in modpython/modperl.
1419  // Don't worry about existence of these functions.
1421  const CString& sCap, const CString& sValue);
1423  bool bSuccess);
1425  SCString& ssCaps);
1427  const CString& sCap,
1428  bool bState);
1430  const CString& sCap,
1431  bool bState);
1436 
1437  protected:
1440  std::set<CTimer*> m_sTimers;
1441  std::set<CSocket*> m_sSockets;
1442 #ifdef HAVE_PTHREAD
1443  std::set<CModuleJob*> m_sJobs;
1444 #endif
1456  std::map<CString, std::unique_ptr<CCapability>> m_mServerDependentCaps;
1457 
1458  private:
1459  MCString
1460  m_mssRegistry;
1461  VWebSubPages m_vSubPages;
1462  std::map<CString, CModCommand> m_mCommands;
1463 };
1464 
1465 class CModules : public std::vector<CModule*>, private CCoreTranslationMixin {
1466  public:
1467  CModules();
1468  ~CModules();
1469 
1470  CModules(const CModules&) = default;
1471  CModules& operator=(const CModules&) = default;
1472 
1473  void SetUser(CUser* pUser) { m_pUser = pUser; }
1474  void SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
1475  void SetClient(CClient* pClient) { m_pClient = pClient; }
1476  CUser* GetUser() const { return m_pUser; }
1477  CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1478  CClient* GetClient() const { return m_pClient; }
1479 
1480  void UnloadAll();
1481 
1482  bool OnBoot();
1483  bool OnPreRehash();
1484  bool OnPostRehash();
1485  bool OnIRCDisconnected();
1486  bool OnIRCConnected();
1487  bool OnIRCConnecting(CIRCSock* pIRCSock);
1488  bool OnIRCConnectionError(CIRCSock* pIRCSock);
1489  bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent,
1490  CString& sRealName);
1491  bool OnBroadcast(CString& sMessage);
1492 
1493  bool OnChanPermission3(const CNick* pOpNick, const CNick& Nick,
1494  CChan& Channel, char cMode, bool bAdded,
1495  bool bNoChange);
1496  bool OnChanPermission2(const CNick* pOpNick, const CNick& Nick,
1497  CChan& Channel, unsigned char uMode, bool bAdded,
1498  bool bNoChange);
1499  bool OnChanPermission(const CNick& OpNick, const CNick& Nick,
1500  CChan& Channel, unsigned char uMode, bool bAdded,
1501  bool bNoChange);
1502  bool OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1503  bool bNoChange);
1504  bool OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1505  bool bNoChange);
1506  bool OnDeop2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1507  bool bNoChange);
1508  bool OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1509  bool bNoChange);
1510  bool OnVoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1511  bool bNoChange);
1512  bool OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1513  bool bNoChange);
1514  bool OnDevoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1515  bool bNoChange);
1516  bool OnDevoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1517  bool bNoChange);
1518  bool OnRawMode2(const CNick* pOpNick, CChan& Channel, const CString& sModes,
1519  const CString& sArgs);
1520  bool OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes,
1521  const CString& sArgs);
1522  bool OnMode2(const CNick* pOpNick, CChan& Channel, char uMode,
1523  const CString& sArg, bool bAdded, bool bNoChange);
1524  bool OnMode(const CNick& OpNick, CChan& Channel, char uMode,
1525  const CString& sArg, bool bAdded, bool bNoChange);
1526 
1527  bool OnRaw(CString& sLine);
1528  bool OnRawMessage(CMessage& Message);
1529  bool OnNumericMessage(CNumericMessage& Message);
1530 
1531  bool OnStatusCommand(CString& sCommand);
1532  bool OnModCommand(const CString& sCommand);
1533  bool OnModNotice(const CString& sMessage);
1534  bool OnModCTCP(const CString& sMessage);
1535 
1536  bool OnQuit(const CNick& Nick, const CString& sMessage,
1537  const std::vector<CChan*>& vChans);
1538  bool OnQuitMessage(CQuitMessage& Message,
1539  const std::vector<CChan*>& vChans);
1540  bool OnNick(const CNick& Nick, const CString& sNewNick,
1541  const std::vector<CChan*>& vChans);
1542  bool OnNickMessage(CNickMessage& Message,
1543  const std::vector<CChan*>& vChans);
1544  bool OnKick(const CNick& Nick, const CString& sOpNick, CChan& Channel,
1545  const CString& sMessage);
1546  bool OnKickMessage(CKickMessage& Message);
1547  bool OnJoining(CChan& Channel);
1548  bool OnJoin(const CNick& Nick, CChan& Channel);
1549  bool OnJoinMessage(CJoinMessage& Message);
1550  bool OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage);
1551  bool OnPartMessage(CPartMessage& Message);
1552  bool OnInvite(const CNick& Nick, const CString& sChan);
1553 
1554  bool OnChanBufferStarting(CChan& Chan, CClient& Client);
1555  bool OnChanBufferEnding(CChan& Chan, CClient& Client);
1556  bool OnChanBufferPlayLine2(CChan& Chan, CClient& Client, CString& sLine,
1557  const timeval& tv);
1558  bool OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
1559  bool OnPrivBufferStarting(CQuery& Query, CClient& Client);
1560  bool OnPrivBufferEnding(CQuery& Query, CClient& Client);
1561  bool OnPrivBufferPlayLine2(CClient& Client, CString& sLine,
1562  const timeval& tv);
1563  bool OnPrivBufferPlayLine(CClient& Client, CString& sLine);
1564  bool OnChanBufferPlayMessage(CMessage& Message);
1565  bool OnPrivBufferPlayMessage(CMessage& Message);
1566 
1567  bool OnClientLogin();
1568  bool OnClientDisconnect();
1569  bool OnUserRaw(CString& sLine);
1570  bool OnUserRawMessage(CMessage& Message);
1571  bool OnUserCTCPReply(CString& sTarget, CString& sMessage);
1572  bool OnUserCTCPReplyMessage(CCTCPMessage& Message);
1573  bool OnUserCTCP(CString& sTarget, CString& sMessage);
1574  bool OnUserCTCPMessage(CCTCPMessage& Message);
1575  bool OnUserAction(CString& sTarget, CString& sMessage);
1576  bool OnUserActionMessage(CActionMessage& Message);
1577  bool OnUserMsg(CString& sTarget, CString& sMessage);
1578  bool OnUserTextMessage(CTextMessage& Message);
1579  bool OnUserNotice(CString& sTarget, CString& sMessage);
1580  bool OnUserNoticeMessage(CNoticeMessage& Message);
1581  bool OnUserJoin(CString& sChannel, CString& sKey);
1582  bool OnUserJoinMessage(CJoinMessage& Message);
1583  bool OnUserPart(CString& sChannel, CString& sMessage);
1584  bool OnUserPartMessage(CPartMessage& Message);
1585  bool OnUserTopic(CString& sChannel, CString& sTopic);
1586  bool OnUserTopicMessage(CTopicMessage& Message);
1587  bool OnUserTopicRequest(CString& sChannel);
1588  bool OnUserQuit(CString& sMessage);
1589  bool OnUserQuitMessage(CQuitMessage& Message);
1590 
1591  bool OnCTCPReply(CNick& Nick, CString& sMessage);
1592  bool OnCTCPReplyMessage(CCTCPMessage& Message);
1593  bool OnPrivCTCP(CNick& Nick, CString& sMessage);
1594  bool OnPrivCTCPMessage(CCTCPMessage& Message);
1595  bool OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
1596  bool OnChanCTCPMessage(CCTCPMessage& Message);
1597  bool OnPrivAction(CNick& Nick, CString& sMessage);
1598  bool OnPrivActionMessage(CActionMessage& Message);
1599  bool OnChanAction(CNick& Nick, CChan& Channel, CString& sMessage);
1600  bool OnChanActionMessage(CActionMessage& Message);
1601  bool OnPrivMsg(CNick& Nick, CString& sMessage);
1602  bool OnPrivTextMessage(CTextMessage& Message);
1603  bool OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
1604  bool OnChanTextMessage(CTextMessage& Message);
1605  bool OnPrivNotice(CNick& Nick, CString& sMessage);
1606  bool OnPrivNoticeMessage(CNoticeMessage& Message);
1607  bool OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage);
1608  bool OnChanNoticeMessage(CNoticeMessage& Message);
1609  bool OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
1610  bool OnTopicMessage(CTopicMessage& Message);
1611  bool OnTimerAutoJoin(CChan& Channel);
1612 
1613  bool OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1614  bool OnDeleteNetwork(CIRCNetwork& Network);
1615 
1616  bool OnSendToClient(CString& sLine, CClient& Client);
1617  bool OnSendToClientMessage(CMessage& Message);
1618  bool OnSendToIRC(CString& sLine);
1619  bool OnSendToIRCMessage(CMessage& Message);
1620  bool OnClientAttached();
1621  bool OnClientDetached();
1622 
1623  bool OnServerCapAvailable(const CString& sCap, const CString& sValue);
1624  bool OnServerCapResult(const CString& sCap, bool bSuccess);
1625 
1626  CModule* FindModule(const CString& sModule) const;
1627  bool LoadModule(const CString& sModule, const CString& sArgs,
1628  CModInfo::EModuleType eType, CUser* pUser,
1629  CIRCNetwork* pNetwork, CString& sRetMsg);
1630  bool UnloadModule(const CString& sModule);
1631  bool UnloadModule(const CString& sModule, CString& sRetMsg);
1632  bool ReloadModule(const CString& sModule, const CString& sArgs,
1633  CUser* pUser, CIRCNetwork* pNetwork, CString& sRetMsg);
1634 
1635  static bool GetModInfo(CModInfo& ModInfo, const CString& sModule,
1636  CString& sRetMsg);
1637  static bool GetModPathInfo(CModInfo& ModInfo, const CString& sModule,
1638  const CString& sModPath, CString& sRetMsg);
1639  static void GetAvailableMods(
1640  std::set<CModInfo>& ssMods,
1642  static void GetDefaultMods(
1643  std::set<CModInfo>& ssMods,
1645 
1646  // This returns the path to the .so and to the data dir
1647  // which is where static data (webadmin skins) are saved
1648  static bool FindModPath(const CString& sModule, CString& sModPath,
1649  CString& sDataPath);
1650  // Return a list of <module dir, data dir> pairs for directories in
1651  // which modules can be found.
1652  typedef std::queue<std::pair<CString, CString>> ModDirList;
1653  static ModDirList GetModDirs();
1654 
1655  // Global Modules
1656  bool OnAddUser(CUser& User, CString& sErrorRet);
1657  bool OnDeleteUser(CUser& User);
1658  bool OnClientConnect(CZNCSock* pSock, const CString& sHost,
1659  unsigned short uPort);
1660  bool OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1661  bool OnFailedLogin(const CString& sUsername, const CString& sRemoteIP);
1662  bool OnUnknownUserRaw(CClient* pClient, CString& sLine);
1663  bool OnUnknownUserRawMessage(CMessage& Message);
1664  bool OnClientCapLs(CClient* pClient, SCString& ssCaps);
1665  bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1666  bool bState);
1667  bool OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState);
1668  bool OnModuleLoading(const CString& sModName, const CString& sArgs,
1669  CModInfo::EModuleType eType, bool& bSuccess,
1670  CString& sRetMsg);
1671  bool OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
1672  bool OnGetModInfo(CModInfo& ModInfo, const CString& sModule, bool& bSuccess,
1673  CString& sRetMsg);
1674  bool OnGetAvailableMods(std::set<CModInfo>& ssMods,
1675  CModInfo::EModuleType eType);
1676  // !Global Modules
1677 
1678  private:
1679  static ModHandle OpenModule(const CString& sModule, const CString& sModPath,
1680  CModInfo& Info, CString& sRetMsg);
1681  static bool ValidateModuleName(const CString& sModule, CString& sRetMsg);
1682 
1683  protected:
1687 };
1688 
1689 #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:285
virtual void OnOp(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
const CModCommand * FindCommand(const CString &sCmd) const
bool UnlinkSocket(CSocket *pSocket)
bool HasNV(const CString &sName) const
Definition: Modules.h:1226
std::set< CSocket * >::const_iterator EndSockets() const
Definition: Modules.h:1172
Definition: Message.h:327
void SetDescription(const CString &s)
CDelayedTranslation t_d(const CString &sEnglish, const CString &sContext="") const
virtual bool OnBoot()
This module hook is called during ZNC startup.
void CancelJobs(const std::set< CModuleJob *> &sJobs)
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:1246
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:38
CModInfo()
Definition: Modules.h:268
CModule * GetModule() const
virtual void OnClientAttached()
Called after login, and also during JumpNetwork.
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)
void SetHasArgs(bool b=false)
Definition: Modules.h:321
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)
virtual CString GetWebPath()
virtual ~CCapability()=default
CString m_sDescription
Definition: Modules.h:205
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:83
bool OnPrivBufferPlayLine(CClient &Client, CString &sLine)
void SetNetwork(CIRCNetwork *pNetwork)
Definition: Modules.h:1474
std::set< CTimer * >::const_iterator BeginTimers() const
Definition: Modules.h:1154
CClient * GetClient() const
Definition: Modules.h:1478
bool OnDeop(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnClientDetached()
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.
CString t_s(const CString &sEnglish, const CString &sContext="") const
void AddServerDependentCapability(const CString &sName, std::unique_ptr< CCapability > pCap)
Simple API to support client capabilities which depend on server to support that capability.
CModInfo(const CString &sName, const CString &sPath, EModuleType eType)
Definition: Modules.h:269
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:1452
ZNC will continue event processing normally.
Definition: Modules.h:441
A job is a task which should run without blocking the main thread.
Definition: Threads.h:67
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:331
virtual EModRet OnChanNotice(CNick &Nick, CChan &Channel, CString &sMessage)
EModuleType
Definition: Modules.h:261
virtual void OnUnknownModCommand(const CString &sCommand)
This is similar to OnModCommand(), but it is only called if HandleCommand didn&#39;t find any that wants ...
A CJob version which can be safely used in modules.
Definition: Modules.h:235
bool OnServerCapAvailable(const CString &sCap, const CString &sValue)
virtual bool PutUser(const CString &sLine)
This function sends a given raw IRC line to a client.
void SetUser(CUser *pUser)
Definition: Modules.h:1473
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:335
void InternalServerDependentCapsOnClientAttached()
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&#39;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:1652
bool OnUserJoin(CString &sChannel, CString &sKey)
void InternalServerDependentCapsOnIRCDisconnected()
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:1230
virtual void OnPostRehash()
This module hook is called after a successful rehash.
static void GetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType=CModInfo::UserModule)
CIRCNetwork * GetNetwork() const
Definition: Modules.h:1264
CTimer * FindTimer(const CString &sLabel)
virtual EModRet OnUserActionMessage(CActionMessage &Message)
Called when a client sends a CTCP ACTION request ("/me").
void SetModPath(const CString &s)
Definition: Modules.h:1245
std::function< void(const CString &sLine)> CmdFunc
Definition: Modules.h:356
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&#39;s in the conf...
void SetFPCallback(FPTimer_t p)
Definition: Modules.h:219
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:1440
Definition: Client.h:99
EModuleType GetDefaultType() const
Definition: Modules.h:312
bool OnPrivCTCP(CNick &Nick, CString &sMessage)
bool LoadRegistry()
bool OnUserRaw(CString &sLine)
const CString m_sDescription
Definition: Modules.h:253
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.
const CString & GetModPath() const
Definition: Modules.h:1253
bool MoveRegistry(const CString &sPath)
bool OnPreRehash()
bool OnClientDisconnect()
Definition: Message.h:302
bool OnKickMessage(CKickMessage &Message)
Definition: Message.h:278
void SetModule(CModule *p)
const CString & GetModName() const
Definition: Modules.h:1133
bool OnClientCapLs(CClient *pClient, SCString &ssCaps)
virtual void OnPartMessage(CPartMessage &Message)
Called when a nick parts a channel.
bool OnNick(const CNick &Nick, const CString &sNewNick, const std::vector< CChan *> &vChans)
CSockManager * m_pManager
Definition: Modules.h:1446
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...
const CString & GetDescription() const
Definition: Modules.h:1251
bool OnServerCapResult(const CString &sCap, bool bSuccess)
This is the same as both CModule::HALTMODS and CModule::HALTCORE together.
Definition: Modules.h:445
void(CModule::* ModCmdFunc)(const CString &sLine)
Type for the callback function that handles the actual command.
Definition: Modules.h:355
std::set< CSocket * > m_sSockets
Definition: Modules.h:1441
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:1443
CString t_s(const CString &sEnglish, const CString &sContext="") const
const CString & GetSavePath() const
virtual EModRet OnUserCTCPMessage(CCTCPMessage &Message)
This module hook is called when a client sends a CTCP request.
CString m_sArgsHelpText
Definition: Modules.h:336
Definition: Modules.h:1465
bool OnUserJoinMessage(CJoinMessage &Message)
bool OnModuleUnloading(CModule *pModule, bool &bSuccess, CString &sRetMsg)
CModule * FindModule(const CString &sModule) const
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.
void SetDescription(const CString &s)
Definition: Modules.h:1244
CClient * m_pClient
Definition: Modules.h:1449
C-style entry point to the module.
Definition: Modules.h:81
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:317
Definition: Socket.h:79
bool OnQuitMessage(CQuitMessage &Message, const std::vector< CChan *> &vChans)
virtual void OnClientLogin()
Called when a client successfully logged in to ZNC.
virtual void OnClientChangedSupport(CClient *pClient, bool bState)
Definition: Modules.h:174
bool OnPrivMsg(CNick &Nick, CString &sMessage)
const CString & GetDescription() const
Definition: Modules.h:247
bool ClearNV(bool bWriteToDisk=true)
bool OnClientAttached()
Definition: Translation.h:85
bool OnSendToClientMessage(CMessage &Message)
bool m_bHasArgs
Definition: Modules.h:337
CString Resolve() const
Definition: Translation.h:90
void AddJob(CModuleJob *pJob)
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:1455
std::set< CString > SCString
Definition: ZNCString.h:35
const CString & GetWikiPage() const
Definition: Modules.h:308
bool InternalServerDependentCapsOnServerCap302Available(const CString &sCap, const CString &sValue)
Definition: Modules.h:261
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:1686
void SetClient(CClient *pClient)
CInlineFormatMessage t_p(const CString &sEnglish, const CString &sEnglishes, int iNum, const CString &sContext="") const
bool OnIRCConnectionError(CIRCSock *pIRCSock)
std::set< EModuleType > m_seType
Definition: Modules.h:330
Definition: Socket.h:27
bool OnRawMessage(CMessage &Message)
void RunJob() override
this is the method you should override
Definition: Modules.h:222
bool OnPrivCTCPMessage(CCTCPMessage &Message)
Base Csock implementation to be used by modules.
Definition: Socket.h:247
bool OnBroadcast(CString &sMessage)
void HandleHelpCommand(const CString &sLine="")
Send a description of all registered commands via PutModule().
bool OnOp(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual void OnClientDisconnect()
Called when a client disconnected from ZNC.
void SetNetwork(CIRCNetwork *pNetwork)
Definition: Modules.h:210
CModule * GetModule()
Definition: Modules.h:176
Definition: Message.h:240
virtual bool OnServerCap302Available(const CString &sCap, const CString &sValue)
Called for every CAP received via CAP LS from server.
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:183
void SetLoader(ModLoader fLoader)
Definition: Modules.h:322
virtual EModRet OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
bool AddCommand(const CModCommand &Command)
virtual ~CTimer()
virtual EModRet OnUserAction(CString &sTarget, CString &sMessage)
const CString & GetName() const
Definition: Modules.h:305
virtual EModRet OnUnknownUserRawMessage(CMessage &Message)
bool OnRawMode(const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
CUser * GetUser() const
Definition: Modules.h:1260
bool InternalServerDependentCapsIsClientCapSupported(CClient *pClient, const CString &sCap, bool bState)
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 * ModHandle
Definition: Modules.h:257
bool AddTimer(CTimer *pTimer)
bool OnIRCRegistration(CString &sPass, CString &sNick, CString &sIdent, CString &sRealName)
virtual EModRet OnUserTopicRequest(CString &sChannel)
This hook is called when a user requests a channel&#39;s topic.
bool SaveRegistry() const
void InternalServerDependentCapsOnClientCapRequest(CClient *pClient, const CString &sCap, bool bState)
Definition: Message.h:311
virtual EModRet OnPrivCTCP(CNick &Nick, CString &sMessage)
bool OnSendToIRCMessage(CMessage &Message)
std::set< CSocket * >::const_iterator BeginSockets() const
Definition: Modules.h:1169
std::set< CTimer * >::const_iterator EndTimers() const
Definition: Modules.h:1157
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:229
bool OnPrivBufferPlayMessage(CMessage &Message)
bool operator<(const CModInfo &Info) const
Definition: Modules.h:281
Definition: Translation.h:71
bool OnTimerAutoJoin(CChan &Channel)
std::shared_ptr< CWebSubPage > TWebSubPage
Definition: WebModules.h:30
Definition: Template.h:129
void InternalServerDependentCapsOnClientCapLs(CClient *pClient, SCString &ssCaps)
bool GetHasArgs() const
Definition: Modules.h:310
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.
Definition: Translation.h:62
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:488
bool OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
void(* fpFillModInfo)(CModInfo &)
Definition: Modules.h:85
virtual void OnNick(const CNick &Nick, const CString &sNewNick, const std::vector< CChan *> &vChans)
bool OnVoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
EModException
Definition: Modules.h:457
bool OnChanActionMessage(CActionMessage &Message)
virtual void OnQuitMessage(CQuitMessage &Message, const std::vector< CChan *> &vChans)
Called when a nick quit from IRC.
bool OnUserCTCPMessage(CCTCPMessage &Message)
const char * pcVersion
Definition: Modules.h:82
CIRCNetwork * GetNetwork() const
Definition: Modules.h:1477
bool LoadModule(const CString &sModule, const CString &sArgs, CModInfo::EModuleType eType, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
~CModInfo()
Definition: Modules.h:279
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:316
CUser * m_pUser
Definition: Modules.h:1684
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:217
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:454
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:470
CSockManager * GetManager() const
Definition: Modules.h:1269
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)
virtual void OnServerChangedSupport(CIRCNetwork *pNetwork, bool bState)
Definition: Modules.h:173
EModRet
This enum is just used for return from module hooks.
Definition: Modules.h:437
Definition: Modules.h:261
void DelNV(MCString::iterator it)
Definition: Modules.h:1235
virtual bool OnWebPreRequest(CWebSock &WebSock, const CString &sPageName)
For WebMods: Called before the list of registered SubPages will be checked.
void Call(const CString &sLine) const
Definition: Modules.h:399
bool RemSocket(CSocket *pSocket)
virtual void OnServerCapResult(const CString &sCap, bool bSuccess)
Called for every CAP accepted or rejected by server (with CAP ACK or CAP NAK after our CAP REQ)...
bool OnUnknownUserRaw(CClient *pClient, CString &sLine)
virtual bool PutStatus(const CString &sLine)
This function generates a query from *status.
bool OnPrivNotice(CNick &Nick, CString &sMessage)
Definition: Modules.h:259
bool OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
const CString & GetModDataDir() const
Get the module&#39;s data dir.
Definition: Modules.h:1144
static CString ModuleTypeToString(EModuleType eType)
Definition: Modules.h:291
The base class for your own ZNC modules.
Definition: Modules.h:421
bool OnStatusCommand(CString &sCommand)
bool OnUserNotice(CString &sTarget, CString &sMessage)
CModInfo::EModuleType m_eType
Definition: Modules.h:1438
const CString & GetPath() const
Definition: Modules.h:306
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)
virtual ~CModuleJob()
virtual EModRet OnChanAction(CNick &Nick, CChan &Channel, CString &sMessage)
CUser * m_pUser
Definition: Modules.h:1447
bool RemTimer(CTimer *pTimer)
virtual EModRet OnModuleUnloading(CModule *pModule, bool &bSuccess, CString &sRetMsg)
Called when a module is going to be unloaded.
bool OnPart(const CNick &Nick, CChan &Channel, const CString &sMessage)
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:318
virtual CString GetWebFilesPath()
void AddType(EModuleType eType)
Definition: Modules.h:289
virtual void ListTimers()
virtual void OnVoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual void OnClientDetached()
Called upon disconnect, and also during JumpNetwork.
MCString::iterator EndNV()
Definition: Modules.h:1233
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)
Definition: Modules.h:170
const CString & GetArgsHelpText() const
Definition: Modules.h:309
CModule * TModLoad(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, CModInfo::EModuleType eType)
Definition: Modules.h:345
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:342
bool OnUserNoticeMessage(CNoticeMessage &Message)
virtual EModRet OnCTCPReplyMessage(CCTCPMessage &Message)
Called when we receive a CTCP reply from IRC.
Definition: WebModules.h:127
void SetType(CModInfo::EModuleType eType)
Definition: Modules.h:1243
virtual EModRet OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
bool OnIRCDisconnected()
this is the main cron job class
Definition: Csocket.h:392
bool OnChanTextMessage(CTextMessage &Message)
bool OnNickMessage(CNickMessage &Message, const std::vector< CChan *> &vChans)
bool OnCTCPReply(CNick &Nick, CString &sMessage)
virtual void ListSockets()
virtual VWebSubPages & GetSubPages()
Returns a list of all registered SubPages.
Definition: Modules.h:537
virtual EModRet OnChanBufferEnding(CChan &Chan, CClient &Client)
Called after a channel buffer was played back to a client.
Definition: Client.h:38
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:251
virtual EModRet OnCTCPReply(CNick &Nick, CString &sMessage)
virtual EModRet OnChanTextMessage(CTextMessage &Message)
Called when we receive a channel PRIVMSG message from IRC.
const CString & GetCommand() const
Definition: Modules.h:394
Definition: Modules.h:261
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&#39;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.
CString ExpandString(const CString &sStr) const
void SetWikiPage(const CString &s)
Definition: Modules.h:319
const CString & GetArgs() const
Definition: Modules.h:1252
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:1453
Definition: Message.h:320
CString m_sModPath
Definition: Modules.h:1454
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.
CUser * GetUser() const
Definition: Modules.h:1476
CString m_sDataDir
Definition: Modules.h:1451
CString m_sName
Definition: Modules.h:332
A dictionary for strings.
Definition: ZNCString.h:595
CString GetArgs() const
Definition: Modules.h:396
bool OnModCommand(const CString &sCommand)
bool OnUserMsg(CString &sTarget, CString &sMessage)
void SetArgsHelpText(const CString &s)
Definition: Modules.h:320
bool OnPostRehash()
bool OnDevoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual void OnPreRehash()
Called just before znc.conf is rehashed.
CModule * GetModule() const
Definition: Modules.h:245
bool OnDevoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan *> &vChans)
Definition: Message.h:270
CModuleJob(CModule *pModule, const CString &sName, const CString &sDesc)
Definition: Modules.h:237
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)
virtual void OnKickMessage(CKickMessage &Message)
Called when a nick is kicked from a channel.
virtual void OnNickMessage(CNickMessage &Message, const std::vector< CChan *> &vChans)
Called when a nickname change occurs.
bool OnGetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType)
CModInfo::EModuleType GetType() const
Definition: Modules.h:1250
bool OnClientLogin()
bool OnMode(const CNick &OpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
bool OnUserPartMessage(CPartMessage &Message)
bool OnClientCapRequest(CClient *pClient, const CString &sCap, bool bState)
CIRCNetwork * m_pNetwork
Definition: Modules.h:1448
CInlineFormatMessage t_f(const CString &sEnglish, const CString &sContext="") const
CClient * GetClient() const
Definition: Modules.h:1268
CString m_sModName
Definition: Modules.h:1450
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)
const CString & GetName() const
Definition: Modules.h:246
virtual bool PutIRC(const CString &sLine)
This function sends a given 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:1082
bool OnUnknownUserRawMessage(CMessage &Message)
bool OnRawMode2(const CNick *pOpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
bool OnPartMessage(CPartMessage &Message)
ModLoader GetLoader() const
Definition: Modules.h:311
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:212
bool OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
void SetModule(CModule *p)
Definition: Modules.h:177
bool OnPrivBufferPlayLine2(CClient &Client, CString &sLine, const timeval &tv)
virtual void AddSubPage(TWebSubPage spSubPage)
Registers a sub page for the sidebar.
Definition: Modules.h:528
virtual EModRet OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
CString m_sPath
Definition: Modules.h:333
bool OnUserCTCP(CString &sTarget, CString &sMessage)
virtual void ClearSubPages()
Removes all registered (AddSubPage&#39;d) SubPages.
Definition: Modules.h:533
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)
CString GetModNick() const
bool OnDeleteUser(CUser &User)
bool OnChanBufferStarting(CChan &Chan, CClient &Client)
MCString::iterator BeginNV()
Definition: Modules.h:1234
ModHandle m_pDLL
Definition: Modules.h:1445
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:252
virtual bool WebRequiresAdmin()
Return true if this module should only be usable for admins on the web.
Definition: Modules.h:492
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.
void InternalServerDependentCapsOnIRCConnected()
bool OnJoinMessage(CJoinMessage &Message)
bool ReloadModule(const CString &sModule, const CString &sArgs, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
CIRCNetwork * m_pNetwork
Definition: Modules.h:1685
CString GetDescription() const
Definition: Modules.h:397
CModule * m_pModule
Definition: Modules.h:180
void SetDefaultType(EModuleType eType)
Definition: Modules.h:323
Definition: Message.h:250
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:204
bool OnAddUser(CUser &User, CString &sErrorRet)
CmdFunc GetFunction() const
Definition: Modules.h:395
bool OnPrivAction(CNick &Nick, CString &sMessage)
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:461
bool SupportsType(EModuleType eType) const
Definition: Modules.h:285
CString m_sDescription
Definition: Modules.h:334
bool SetNV(const CString &sName, const CString &sValue, bool bWriteToDisk=true)
virtual CString GetWebMenuTitle()
Return the title of the module&#39;s section in the web interface&#39;s side bar.
Definition: Modules.h:496
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:352
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:1475
bool OnRaw(CString &sLine)
virtual EModRet OnPrivMsg(CNick &Nick, CString &sMessage)
virtual bool ValidateWebRequestCSRFCheck(CWebSock &WebSock, const CString &sPageName)
If ValidateWebRequestCSRFCheck returned false, a CSRF error will be printed.
const CString & GetDescription() const
Definition: Modules.h:307
std::map< CString, std::unique_ptr< CCapability > > m_mServerDependentCaps
Definition: Modules.h:1456
Stop sending this even to other modules which were not called yet.
Definition: Modules.h:449
Definition: IRCSock.h:35
virtual EModRet OnPrivBufferPlayLine(CClient &Client, CString &sLine)
void InternalServerDependentCapsOnServerCapResult(const CString &sCap, bool bSuccess)
virtual EModRet OnUserTextMessage(CTextMessage &Message)
This module hook is called when a user sends a PRIVMSG message.
ModLoader m_fLoader
Definition: Modules.h:338
void(* FPTimer_t)(CModule *, CFPTimer *)
Definition: Modules.h:208
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&#39;s listening sockets...
Definition: Chan.h:35
const CString & GetDescription() const
virtual EModRet OnStatusCommand(CString &sCommand)
Called when a command to *status is sent.
Definition: Message.h:291
virtual EModRet OnPrivBufferEnding(CQuery &Query, CClient &Client)
Called after a query buffer was played back to a client.
Generate a grid-like or list-like output from a given input.
Definition: Utils.h:172
virtual EModRet OnUserTopicMessage(CTopicMessage &Message)
This module hook is called when a user wants to change a channel topic.
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)
CModule *(* ModLoader)(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, EModuleType eType)
Definition: Modules.h:263
Here is a small explanation of how messages on IRC work, and how you can use this class to get useful...
Definition: Message.h:57
Definition: ZNCString.h:673
virtual EModRet OnChanBufferStarting(CChan &Chan, CClient &Client)
Called before a channel buffer is played back to a client.
virtual void OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan *> &vChans)
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:1439
const char * pcCompileOptions
Definition: Modules.h:84
Definition: Translation.h:103
void InternalServerDependentCapsOnClientDetached()