ZNC trunk
Loading...
Searching...
No Matches
Modules.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 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
34class CAuthBase;
35class CChan;
36class CQuery;
37class CIRCNetwork;
38class CClient;
39class CWebSock;
40class CTemplate;
41class CIRCSock;
42class CModule;
43class 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
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
161class CZNC;
162class CUser;
163class CNick;
164class CChan;
165class CModule;
166class CFPTimer;
167class CSockManager;
168// !Forward Declarations
169
171 public:
172 virtual ~CCapability() = default;
173 virtual void OnServerChangedSupport(CIRCNetwork* pNetwork, bool bState) {}
174 virtual void OnClientChangedSupport(CClient* pClient, bool bState) {}
175
177 void SetModule(CModule* p) { m_pModule = p; }
178
179 protected:
180 CModule* m_pModule = nullptr;
181};
182
183class 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
195 void SetDescription(const CString& s);
196 // !Setters
197
198 // Getters
200 const CString& GetDescription() const;
201 // !Getters
202 private:
203 protected:
206};
207
208typedef void (*FPTimer_t)(CModule*, CFPTimer*);
209
210class 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
235class 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
257typedef void* ModHandle;
258
259class 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; }
321 void SetHasArgs(bool b = false) { m_bHasArgs = b; }
322 void SetLoader(ModLoader fLoader) { m_fLoader = fLoader; }
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
341template <class M>
342void TModInfo(CModInfo& Info) {}
343
344template <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
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;
406};
407
421class CModule {
422 public:
424 ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork,
425 const CString& sModName, const CString& sDataDir,
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 {
445 HALT = 2,
455 } EModRet;
456
457 typedef enum {
463
464 void SetUser(CUser* pUser);
465 void SetNetwork(CIRCNetwork* pNetwork);
466 void SetClient(CClient* pClient);
467
469 bool IsCallStackEmpty() const;
470
473 void Unload() { throw UNLOAD; }
474
481 virtual bool OnLoad(const CString& sArgsi, CString& sMessage);
486 virtual bool OnBoot();
487
491 virtual bool WebRequiresLogin() { return true; }
495 virtual bool WebRequiresAdmin() { return false; }
499 virtual CString GetWebMenuTitle() { return ""; }
510 virtual bool OnWebPreRequest(CWebSock& WebSock, const CString& sPageName);
520 virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName,
521 CTemplate& Tmpl);
527 virtual bool ValidateWebRequestCSRFCheck(CWebSock& WebSock, const CString& sPageName);
531 virtual void AddSubPage(TWebSubPage spSubPage) {
532 m_vSubPages.push_back(spSubPage);
533 }
534
536 virtual void ClearSubPages() { m_vSubPages.clear(); }
540 virtual VWebSubPages& GetSubPages() { return m_vSubPages; }
541 private:
552 virtual bool OnEmbeddedWebRequest(CWebSock& WebSock,
553 const CString& sPageName,
554 CTemplate& Tmpl);
555 public:
556 bool DoEmbeddedWebRequest(CWebSock& WebSock, const CString& sPageName,
557 CTemplate& Tmpl);
558
560 virtual void OnPreRehash();
562 virtual void OnPostRehash();
564 virtual void OnIRCDisconnected();
566 virtual void OnIRCConnected();
572 virtual EModRet OnIRCConnecting(CIRCSock* pIRCSock);
577 virtual void OnIRCConnectionError(CIRCSock* pIRCSock);
588 virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick,
589 CString& sIdent, CString& sRealName);
594 virtual EModRet OnBroadcast(CString& sMessage);
595
607 virtual void OnChanPermission3(const CNick* pOpNick, const CNick& Nick,
608 CChan& Channel, char cMode,
609 bool bAdded, bool bNoChange);
611 virtual void OnChanPermission2(const CNick* pOpNick, const CNick& Nick,
612 CChan& Channel, unsigned char uMode,
613 bool bAdded, bool bNoChange);
615 virtual void OnChanPermission(const CNick& OpNick, const CNick& Nick,
616 CChan& Channel, unsigned char uMode,
617 bool bAdded, bool bNoChange);
619 virtual void OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
620 bool bNoChange);
621 virtual void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel,
622 bool bNoChange);
624 virtual void OnDeop2(const CNick* pOpNick, const CNick& Nick,
625 CChan& Channel, bool bNoChange);
626 virtual void OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel,
627 bool bNoChange);
629 virtual void OnVoice2(const CNick* pOpNick, const CNick& Nick,
630 CChan& Channel, bool bNoChange);
631 virtual void OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
632 bool bNoChange);
634 virtual void OnDevoice2(const CNick* pOpNick, const CNick& Nick,
635 CChan& Channel, bool bNoChange);
636 virtual void OnDevoice(const CNick& OpNick, const CNick& Nick,
637 CChan& Channel, bool bNoChange);
646 virtual void OnMode2(const CNick* pOpNick, CChan& Channel, char uMode,
647 const CString& sArg, bool bAdded, bool bNoChange);
648 virtual void OnMode(const CNick& OpNick, CChan& Channel, char uMode,
649 const CString& sArg, bool bAdded, bool bNoChange);
657 virtual void OnRawMode2(const CNick* pOpNick, CChan& Channel,
658 const CString& sModes, const CString& sArgs);
659 virtual void OnRawMode(const CNick& OpNick, CChan& Channel,
660 const CString& sModes, const CString& sArgs);
661
667 virtual EModRet OnRaw(CString& sLine);
673 virtual EModRet OnRawMessage(CMessage& Message);
674
681
686 virtual EModRet OnStatusCommand(CString& sCommand);
690 virtual void OnModCommand(const CString& sCommand);
697 virtual void OnUnknownModCommand(const CString& sCommand);
701 virtual void OnModNotice(const CString& sMessage);
706 virtual void OnModCTCP(const CString& sMessage);
707
713 virtual void OnQuitMessage(CQuitMessage& Message,
714 const std::vector<CChan*>& vChans);
716 virtual void OnQuit(const CNick& Nick, const CString& sMessage,
717 const std::vector<CChan*>& vChans);
718
724 virtual void OnNickMessage(CNickMessage& Message,
725 const std::vector<CChan*>& vChans);
727 virtual void OnNick(const CNick& Nick, const CString& sNewNick,
728 const std::vector<CChan*>& vChans);
729
734 virtual void OnKickMessage(CKickMessage& Message);
736 virtual void OnKick(const CNick& OpNick, const CString& sKickedNick,
737 CChan& Channel, const CString& sMessage);
738
743 virtual EModRet OnJoining(CChan& Channel);
744
749 virtual void OnJoinMessage(CJoinMessage& Message);
751 virtual void OnJoin(const CNick& Nick, CChan& Channel);
752
757 virtual void OnPartMessage(CPartMessage& Message);
759 virtual void OnPart(const CNick& Nick, CChan& Channel,
760 const CString& sMessage);
761
776 virtual EModRet OnInvite(const CNick& Nick, const CString& sChan);
777
783 virtual EModRet OnChanBufferStarting(CChan& Chan, CClient& Client);
789 virtual EModRet OnChanBufferEnding(CChan& Chan, CClient& Client);
790
799 CString& sLine, const timeval& tv);
802 CString& sLine);
803
810 virtual EModRet OnPrivBufferStarting(CQuery& Query, CClient& Client);
817 virtual EModRet OnPrivBufferEnding(CQuery& Query, CClient& Client);
818
827 const timeval& tv);
829 virtual EModRet OnPrivBufferPlayLine(CClient& Client, CString& sLine);
830
832 virtual void OnClientLogin();
834 virtual void OnClientDisconnect();
835
840 virtual EModRet OnUserRaw(CString& sLine);
847
855 virtual EModRet OnUserCTCPReply(CString& sTarget, CString& sMessage);
856
866 virtual EModRet OnUserCTCP(CString& sTarget, CString& sMessage);
867
876 virtual EModRet OnUserAction(CString& sTarget, CString& sMessage);
877
885 virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage);
886
894 virtual EModRet OnUserNotice(CString& sTarget, CString& sMessage);
895
903 virtual EModRet OnUserJoin(CString& sChannel, CString& sKey);
904
912 virtual EModRet OnUserPart(CString& sChannel, CString& sMessage);
913
921 virtual EModRet OnUserTopic(CString& sChannel, CString& sTopic);
922
928
936 virtual EModRet OnUserQuit(CString& sMessage);
937
945 virtual EModRet OnCTCPReply(CNick& Nick, CString& sMessage);
946
954 virtual EModRet OnPrivCTCP(CNick& Nick, CString& sMessage);
955
963 virtual EModRet OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
964
972 virtual EModRet OnPrivAction(CNick& Nick, CString& sMessage);
973
981 virtual EModRet OnChanAction(CNick& Nick, CChan& Channel,
982 CString& sMessage);
983
991 virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage);
992
1000 virtual EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
1001
1009 virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage);
1010
1018 virtual EModRet OnChanNotice(CNick& Nick, CChan& Channel,
1019 CString& sMessage);
1020
1028 virtual EModRet OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
1029
1037 virtual bool OnServerCapAvailable(const CString& sCap);
1048 virtual bool OnServerCap302Available(const CString& sCap, const CString& sValue);
1056 virtual void OnServerCapResult(const CString& sCap, bool bSuccess);
1057
1063 virtual EModRet OnTimerAutoJoin(CChan& Channel);
1064
1071 virtual EModRet OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1077
1086 virtual EModRet OnSendToClient(CString& sLine, CClient& Client);
1087
1096 virtual EModRet OnSendToIRC(CString& sLine);
1097
1116
1118
1124 virtual bool PutIRC(const CString& sLine);
1130 virtual bool PutIRC(const CMessage& Message);
1138 virtual bool PutUser(const CString& sLine);
1145 virtual bool PutStatus(const CString& sLine);
1152 virtual bool PutModule(const CString& sLine);
1158 virtual unsigned int PutModule(const CTable& table);
1165 virtual bool PutModNotice(const CString& sLine);
1166
1168 const CString& GetModName() const { return m_sModName; }
1169
1174
1179 const CString& GetModDataDir() const { return m_sDataDir; }
1180
1181 // Timer stuff
1182 bool AddTimer(CTimer* pTimer);
1183 bool AddTimer(FPTimer_t pFBCallback, const CString& sLabel, u_int uInterval,
1184 u_int uCycles = 0, const CString& sDescription = "");
1185 bool RemTimer(CTimer* pTimer);
1186 bool RemTimer(const CString& sLabel);
1187 bool UnlinkTimer(CTimer* pTimer);
1188 CTimer* FindTimer(const CString& sLabel);
1189 std::set<CTimer*>::const_iterator BeginTimers() const {
1190 return m_sTimers.begin();
1191 }
1192 std::set<CTimer*>::const_iterator EndTimers() const {
1193 return m_sTimers.end();
1194 }
1195 virtual void ListTimers();
1196 // !Timer stuff
1197
1198 // Socket stuff
1199 bool AddSocket(CSocket* pSocket);
1200 bool RemSocket(CSocket* pSocket);
1201 bool RemSocket(const CString& sSockName);
1202 bool UnlinkSocket(CSocket* pSocket);
1203 CSocket* FindSocket(const CString& sSockName);
1204 std::set<CSocket*>::const_iterator BeginSockets() const {
1205 return m_sSockets.begin();
1206 }
1207 std::set<CSocket*>::const_iterator EndSockets() const {
1208 return m_sSockets.end();
1209 }
1210 virtual void ListSockets();
1211// !Socket stuff
1212
1213#ifdef HAVE_PTHREAD
1214 // Job stuff
1215 void AddJob(CModuleJob* pJob);
1217 bool CancelJob(const CString& sJobName);
1218 void CancelJobs(const std::set<CModuleJob*>& sJobs);
1220// !Job stuff
1221#endif
1222
1223 // Command stuff
1227 bool AddCommand(const CModCommand& Command);
1231 const CString& sArgs = "", const CString& sDesc = "");
1234 bool AddCommand(const CString& sCmd, const COptionalTranslation& Args,
1235 const COptionalTranslation& Desc,
1236 std::function<void(const CString& sLine)> func);
1238 bool RemCommand(const CString& sCmd);
1240 const CModCommand* FindCommand(const CString& sCmd) const;
1248 bool HandleCommand(const CString& sLine);
1252 void HandleHelpCommand(const CString& sLine = "");
1253 // !Command stuff
1254
1256 bool SaveRegistry() const;
1257 bool MoveRegistry(const CString& sPath);
1258 bool SetNV(const CString& sName, const CString& sValue,
1259 bool bWriteToDisk = true);
1260 CString GetNV(const CString& sName) const;
1261 bool HasNV(const CString& sName) const {
1262 return m_mssRegistry.find(sName) != m_mssRegistry.end();
1263 }
1264 bool DelNV(const CString& sName, bool bWriteToDisk = true);
1265 MCString::iterator FindNV(const CString& sName) {
1266 return m_mssRegistry.find(sName);
1267 }
1268 MCString::iterator EndNV() { return m_mssRegistry.end(); }
1269 MCString::iterator BeginNV() { return m_mssRegistry.begin(); }
1270 void DelNV(MCString::iterator it) { m_mssRegistry.erase(it); }
1271 bool ClearNV(bool bWriteToDisk = true);
1272
1273 const CString& GetSavePath() const;
1274 CString ExpandString(const CString& sStr) const;
1275 CString& ExpandString(const CString& sStr, CString& sRet) const;
1276
1277 // Setters
1278 void SetType(CModInfo::EModuleType eType) { m_eType = eType; }
1279 void SetDescription(const CString& s) { m_sDescription = s; }
1280 void SetModPath(const CString& s) { m_sModPath = s; }
1281 void SetArgs(const CString& s) { m_sArgs = s; }
1282 // !Setters
1283
1284 // Getters
1286 const CString& GetDescription() const { return m_sDescription; }
1287 const CString& GetArgs() const { return m_sArgs; }
1288 const CString& GetModPath() const { return m_sModPath; }
1289
1295 CUser* GetUser() const { return m_pUser; }
1299 CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1303 CClient* GetClient() const { return m_pClient; }
1305 // !Getters
1306
1307 // Global Modules
1314 virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
1326 virtual void OnClientConnect(CZNCSock* pSock, const CString& sHost,
1327 unsigned short uPort);
1334 virtual EModRet OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1339 virtual void OnFailedLogin(const CString& sUsername,
1340 const CString& sRemoteIP);
1347 virtual EModRet OnUnknownUserRaw(CClient* pClient, CString& sLine);
1349
1351 virtual void OnClientAttached();
1353 virtual void OnClientDetached();
1354
1355#ifndef SWIG
1369 void AddServerDependentCapability(const CString& sName, std::unique_ptr<CCapability> pCap);
1370#endif
1371
1379 virtual void OnClientCapLs(CClient* pClient, SCString& ssCaps);
1386 virtual bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1387 bool bState);
1399 virtual void OnClientCapRequest(CClient* pClient, const CString& sCap,
1400 bool bState);
1401
1407 virtual void OnClientGetSASLMechanisms(SCString& ssMechanisms);
1421 const CString& sMechanism, CString& sResponse);
1436 virtual EModRet OnClientSASLAuthenticate(const CString& sMechanism,
1437 const CString& sMessage);
1441 virtual void OnClientSASLAborted();
1442
1452 virtual EModRet OnModuleLoading(const CString& sModName,
1453 const CString& sArgs,
1454 CModInfo::EModuleType eType, bool& bSuccess,
1455 CString& sRetMsg);
1463 virtual EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess,
1464 CString& sRetMsg);
1472 virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
1473 bool& bSuccess, CString& sRetMsg);
1478 virtual void OnGetAvailableMods(std::set<CModInfo>& ssMods,
1479 CModInfo::EModuleType eType);
1480 // !Global Modules
1481
1482#ifndef SWIG
1483 // Translation
1484 CString t_s(const CString& sEnglish, const CString& sContext = "") const;
1486 const CString& sContext = "") const;
1487 CInlineFormatMessage t_p(const CString& sEnglish, const CString& sEnglishes,
1488 int iNum, const CString& sContext = "") const;
1490 const CString& sContext = "") const;
1491#endif
1492
1493 // Default implementations of several callbacks to make
1494 // AddServerDependentCapability work in modpython/modperl.
1495 // Don't worry about existence of these functions.
1497 const CString& sCap, const CString& sValue);
1499 bool bSuccess);
1501 SCString& ssCaps);
1503 const CString& sCap,
1504 bool bState);
1506 const CString& sCap,
1507 bool bState);
1512
1513 protected:
1516 std::set<CTimer*> m_sTimers;
1517 std::set<CSocket*> m_sSockets;
1518#ifdef HAVE_PTHREAD
1519 std::set<CModuleJob*> m_sJobs;
1520#endif
1532 std::map<CString, std::unique_ptr<CCapability>> m_mServerDependentCaps;
1533
1534 private:
1535 MCString
1536 m_mssRegistry;
1537 VWebSubPages m_vSubPages;
1538 std::map<CString, CModCommand> m_mCommands;
1539 int m_iCallStackDepth = 0;
1540
1541 friend struct CModCallProtector;
1542};
1543
1544class CModules : public std::vector<CModule*>, private CCoreTranslationMixin {
1545 public:
1548
1549 CModules(const CModules&) = default;
1550 CModules& operator=(const CModules&) = default;
1551
1552 void SetUser(CUser* pUser) { m_pUser = pUser; }
1553 void SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
1554 void SetClient(CClient* pClient) { m_pClient = pClient; }
1555 CUser* GetUser() const { return m_pUser; }
1556 CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1557 CClient* GetClient() const { return m_pClient; }
1558
1560
1561 bool OnBoot();
1566 bool OnIRCConnecting(CIRCSock* pIRCSock);
1568 bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent,
1569 CString& sRealName);
1570 bool OnBroadcast(CString& sMessage);
1571
1572 bool OnChanPermission3(const CNick* pOpNick, const CNick& Nick,
1573 CChan& Channel, char cMode, bool bAdded,
1574 bool bNoChange);
1575 bool OnChanPermission2(const CNick* pOpNick, const CNick& Nick,
1576 CChan& Channel, unsigned char uMode, bool bAdded,
1577 bool bNoChange);
1578 bool OnChanPermission(const CNick& OpNick, const CNick& Nick,
1579 CChan& Channel, unsigned char uMode, bool bAdded,
1580 bool bNoChange);
1581 bool OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1582 bool bNoChange);
1583 bool OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1584 bool bNoChange);
1585 bool OnDeop2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1586 bool bNoChange);
1587 bool OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1588 bool bNoChange);
1589 bool OnVoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1590 bool bNoChange);
1591 bool OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1592 bool bNoChange);
1593 bool OnDevoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1594 bool bNoChange);
1595 bool OnDevoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1596 bool bNoChange);
1597 bool OnRawMode2(const CNick* pOpNick, CChan& Channel, const CString& sModes,
1598 const CString& sArgs);
1599 bool OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes,
1600 const CString& sArgs);
1601 bool OnMode2(const CNick* pOpNick, CChan& Channel, char uMode,
1602 const CString& sArg, bool bAdded, bool bNoChange);
1603 bool OnMode(const CNick& OpNick, CChan& Channel, char uMode,
1604 const CString& sArg, bool bAdded, bool bNoChange);
1605
1606 bool OnRaw(CString& sLine);
1607 bool OnRawMessage(CMessage& Message);
1609
1610 bool OnStatusCommand(CString& sCommand);
1611 bool OnModCommand(const CString& sCommand);
1612 bool OnModNotice(const CString& sMessage);
1613 bool OnModCTCP(const CString& sMessage);
1614
1615 bool OnQuit(const CNick& Nick, const CString& sMessage,
1616 const std::vector<CChan*>& vChans);
1618 const std::vector<CChan*>& vChans);
1619 bool OnNick(const CNick& Nick, const CString& sNewNick,
1620 const std::vector<CChan*>& vChans);
1622 const std::vector<CChan*>& vChans);
1623 bool OnKick(const CNick& Nick, const CString& sOpNick, CChan& Channel,
1624 const CString& sMessage);
1626 bool OnJoining(CChan& Channel);
1627 bool OnJoin(const CNick& Nick, CChan& Channel);
1629 bool OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage);
1631 bool OnInvite(const CNick& Nick, const CString& sChan);
1633
1634 bool OnChanBufferStarting(CChan& Chan, CClient& Client);
1635 bool OnChanBufferEnding(CChan& Chan, CClient& Client);
1636 bool OnChanBufferPlayLine2(CChan& Chan, CClient& Client, CString& sLine,
1637 const timeval& tv);
1638 bool OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
1639 bool OnPrivBufferStarting(CQuery& Query, CClient& Client);
1640 bool OnPrivBufferEnding(CQuery& Query, CClient& Client);
1642 const timeval& tv);
1643 bool OnPrivBufferPlayLine(CClient& Client, CString& sLine);
1646
1649 bool OnUserRaw(CString& sLine);
1651 bool OnUserCTCPReply(CString& sTarget, CString& sMessage);
1653 bool OnUserCTCP(CString& sTarget, CString& sMessage);
1655 bool OnUserAction(CString& sTarget, CString& sMessage);
1657 bool OnUserMsg(CString& sTarget, CString& sMessage);
1659 bool OnUserNotice(CString& sTarget, CString& sMessage);
1661 bool OnUserJoin(CString& sChannel, CString& sKey);
1663 bool OnUserPart(CString& sChannel, CString& sMessage);
1665 bool OnUserTopic(CString& sChannel, CString& sTopic);
1668 bool OnUserQuit(CString& sMessage);
1673
1674 bool OnCTCPReply(CNick& Nick, CString& sMessage);
1676 bool OnPrivCTCP(CNick& Nick, CString& sMessage);
1678 bool OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
1680 bool OnPrivAction(CNick& Nick, CString& sMessage);
1682 bool OnChanAction(CNick& Nick, CChan& Channel, CString& sMessage);
1684 bool OnPrivMsg(CNick& Nick, CString& sMessage);
1686 bool OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
1688 bool OnPrivNotice(CNick& Nick, CString& sMessage);
1690 bool OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage);
1692 bool OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
1694 bool OnTimerAutoJoin(CChan& Channel);
1695
1696 bool OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1698
1699 bool OnSendToClient(CString& sLine, CClient& Client);
1701 bool OnSendToIRC(CString& sLine);
1705
1706 bool OnServerCapAvailable(const CString& sCap, const CString& sValue);
1707 bool OnServerCapResult(const CString& sCap, bool bSuccess);
1708
1709 CModule* FindModule(const CString& sModule) const;
1710 bool LoadModule(const CString& sModule, const CString& sArgs,
1711 CModInfo::EModuleType eType, CUser* pUser,
1712 CIRCNetwork* pNetwork, CString& sRetMsg);
1713 bool UnloadModule(const CString& sModule);
1714 bool UnloadModule(const CString& sModule, CString& sRetMsg);
1715 bool ReloadModule(const CString& sModule, const CString& sArgs,
1716 CUser* pUser, CIRCNetwork* pNetwork, CString& sRetMsg);
1717
1718 static bool GetModInfo(CModInfo& ModInfo, const CString& sModule,
1719 CString& sRetMsg);
1720 static bool GetModPathInfo(CModInfo& ModInfo, const CString& sModule,
1721 const CString& sModPath, CString& sRetMsg);
1722 static void GetAvailableMods(
1723 std::set<CModInfo>& ssMods,
1725 static void GetDefaultMods(
1726 std::set<CModInfo>& ssMods,
1728
1729 // This returns the path to the .so and to the data dir
1730 // which is where static data (webadmin skins) are saved
1731 static bool FindModPath(const CString& sModule, CString& sModPath,
1732 CString& sDataPath);
1733 // Return a list of <module dir, data dir> pairs for directories in
1734 // which modules can be found.
1735 typedef std::queue<std::pair<CString, CString>> ModDirList;
1737
1738 // Global Modules
1739 bool OnAddUser(CUser& User, CString& sErrorRet);
1740 bool OnDeleteUser(CUser& User);
1741 bool OnClientConnect(CZNCSock* pSock, const CString& sHost,
1742 unsigned short uPort);
1743 bool OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1744 bool OnFailedLogin(const CString& sUsername, const CString& sRemoteIP);
1745 bool OnUnknownUserRaw(CClient* pClient, CString& sLine);
1747 bool OnClientCapLs(CClient* pClient, SCString& ssCaps);
1748 bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1749 bool bState);
1750 bool OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState);
1751
1755 CString& sResponse);
1756 bool OnClientSASLAuthenticate(const CString& sMechanism,
1757 const CString& sBuffer);
1758
1759 bool OnModuleLoading(const CString& sModName, const CString& sArgs,
1760 CModInfo::EModuleType eType, bool& bSuccess,
1761 CString& sRetMsg);
1762 bool OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
1763 bool OnGetModInfo(CModInfo& ModInfo, const CString& sModule, bool& bSuccess,
1764 CString& sRetMsg);
1765 bool OnGetAvailableMods(std::set<CModInfo>& ssMods,
1766 CModInfo::EModuleType eType);
1767 // !Global Modules
1768
1769 private:
1770 static ModHandle OpenModule(const CString& sModule, const CString& sModPath,
1771 CModInfo& Info, CString& sRetMsg);
1772 static bool ValidateModuleName(const CString& sModule, CString& sRetMsg);
1773
1774 protected:
1778};
1779
1781 explicit CModCallProtector(CModule& pMod) : m_pMod(&pMod) {
1782 pMod.m_iCallStackDepth++;
1783 }
1784 ~CModCallProtector() { m_pMod->m_iCallStackDepth--; }
1785
1787};
1788
1789#ifndef SWIG
1790template <typename T, T* (CModule::*Getter)() const, void (CModule::*Setter)(T*)>
1792 CTemporaryModField(CModule& pMod, T* pValue) {
1793 m_pMod = &pMod;
1794 m_pOldT = (pMod.*Getter)();
1795 if (pValue) {
1796 (pMod.*Setter)(pValue);
1797 }
1798 }
1799
1801
1804};
1805
1812
1813// Same as above, but for plural CModules
1814template <typename T, T* (CModules::*Getter)() const, void (CModules::*Setter)(T*)>
1816 CTemporaryModsField(CModules& pMods, T* pValue) {
1817 m_pMods = &pMods;
1818 m_pOldT = (pMods.*Getter)();
1819 if (pValue) {
1820 (pMods.*Setter)(pValue);
1821 }
1822 }
1823
1825
1828};
1829
1836#endif
1837
1838#endif // !ZNC_MODULES_H
void * ModHandle
Definition Modules.h:257
void(*) FPTimer_t(CModule *, CFPTimer *)
Definition Modules.h:208
CModule * TModLoad(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, CModInfo::EModuleType eType)
Definition Modules.h:345
CTemporaryModsField< CUser, &CModules::GetUser, &CModules::SetUser > CTemporaryModsUser
Definition Modules.h:1834
void TModInfo(CModInfo &Info)
Definition Modules.h:342
CTemporaryModsField< CIRCNetwork, &CModules::GetNetwork, &CModules::SetNetwork > CTemporaryModsNetwork
Definition Modules.h:1832
CTemporaryModsField< CClient, &CModules::GetClient, &CModules::SetClient > CTemporaryModsClient
Definition Modules.h:1830
CTemporaryModField< CUser, &CModule::GetUser, &CModule::SetUser > CTemporaryModUser
Definition Modules.h:1810
CTemporaryModField< CIRCNetwork, &CModule::GetNetwork, &CModule::SetNetwork > CTemporaryModNetwork
Definition Modules.h:1808
CTemporaryModField< CClient, &CModule::GetClient, &CModule::SetClient > CTemporaryModClient
Definition Modules.h:1806
std::vector< TWebSubPage > VWebSubPages
Definition WebModules.h:33
std::shared_ptr< CWebSubPage > TWebSubPage
Definition WebModules.h:32
std::set< CString > SCString
Definition ZNCString.h:37
Definition Message.h:242
Definition Client.h:38
Definition Message.h:260
Definition Modules.h:170
CModule * m_pModule
Definition Modules.h:180
virtual void OnClientChangedSupport(CClient *pClient, bool bState)
Definition Modules.h:174
CModule * GetModule()
Definition Modules.h:176
virtual void OnServerChangedSupport(CIRCNetwork *pNetwork, bool bState)
Definition Modules.h:173
void SetModule(CModule *p)
Definition Modules.h:177
virtual ~CCapability()=default
Definition Chan.h:35
Definition Client.h:99
Definition Translation.h:103
Definition Translation.h:71
Definition Modules.h:210
CFPTimer(CModule *pModule, unsigned int uInterval, unsigned int uCycles, const CString &sLabel, const CString &sDescription)
Definition Modules.h:212
virtual ~CFPTimer()
Definition Modules.h:217
void SetFPCallback(FPTimer_t p)
Definition Modules.h:219
void RunJob() override
this is the method you should override
Definition Modules.h:222
Definition IRCNetwork.h:40
Definition IRCSock.h:35
Definition ZNCString.h:655
Definition Message.h:322
CJob()
Definition Threads.h:73
Definition Message.h:270
Definition Message.h:311
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
A helper class for handling commands in modules.
Definition Modules.h:352
CModCommand & operator=(const CModCommand &other)=default
Assignment operator, needed so that this can be saved in a std::map.
CModCommand(const CString &sCmd, CModule *pMod, ModCmdFunc func, const CString &sArgs, const CString &sDesc)
Construct a new CModCommand.
CString GetDescription() const
Definition Modules.h:397
CModCommand(const CString &sCmd, CmdFunc func, const COptionalTranslation &Args, const COptionalTranslation &Desc)
void AddHelp(CTable &Table) const
Add this command to the CTable instance.
void(CModule::*) ModCmdFunc(const CString &sLine)
Type for the callback function that handles the actual command.
Definition Modules.h:355
static void InitHelp(CTable &Table)
Initialize a CTable so that it can be used with AddHelp().
CModCommand()
Default constructor, needed so that this can be saved in a std::map.
CmdFunc GetFunction() const
Definition Modules.h:395
void Call(const CString &sLine) const
Definition Modules.h:399
std::function< void(const CString &sLine)> CmdFunc
Definition Modules.h:356
CModCommand(const CModCommand &other)=default
Copy constructor, needed so that this can be saved in a std::map.
CString GetArgs() const
Definition Modules.h:396
const CString & GetCommand() const
Definition Modules.h:394
Definition Modules.h:259
const CString & GetPath() const
Definition Modules.h:306
void SetName(const CString &s)
Definition Modules.h:316
void SetHasArgs(bool b=false)
Definition Modules.h:321
CString m_sWikiPage
Definition Modules.h:335
void SetArgsHelpText(const CString &s)
Definition Modules.h:320
bool m_bHasArgs
Definition Modules.h:337
const CString & GetName() const
Definition Modules.h:305
void SetLoader(ModLoader fLoader)
Definition Modules.h:322
EModuleType m_eDefaultType
Definition Modules.h:331
CModule *(*) ModLoader(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, EModuleType eType)
Definition Modules.h:263
EModuleType
Definition Modules.h:261
@ NetworkModule
Definition Modules.h:261
@ UserModule
Definition Modules.h:261
@ GlobalModule
Definition Modules.h:261
CString t_s(const CString &sEnglish, const CString &sContext="") const
CString m_sName
Definition Modules.h:332
bool operator<(const CModInfo &Info) const
Definition Modules.h:281
static CString ModuleTypeToString(EModuleType eType)
Definition Modules.h:291
bool GetHasArgs() const
Definition Modules.h:310
bool SupportsType(EModuleType eType) const
Definition Modules.h:285
~CModInfo()
Definition Modules.h:279
void SetPath(const CString &s)
Definition Modules.h:317
CString m_sDescription
Definition Modules.h:334
void SetWikiPage(const CString &s)
Definition Modules.h:319
std::set< EModuleType > m_seType
Definition Modules.h:330
void AddType(EModuleType eType)
Definition Modules.h:289
const CString & GetWikiPage() const
Definition Modules.h:308
const CString & GetArgsHelpText() const
Definition Modules.h:309
CModInfo(const CString &sName, const CString &sPath, EModuleType eType)
Definition Modules.h:269
CString m_sArgsHelpText
Definition Modules.h:336
ModLoader m_fLoader
Definition Modules.h:338
ModLoader GetLoader() const
Definition Modules.h:311
void SetDefaultType(EModuleType eType)
Definition Modules.h:323
const CString & GetDescription() const
Definition Modules.h:307
EModuleType GetDefaultType() const
Definition Modules.h:312
CString m_sPath
Definition Modules.h:333
CModInfo()
Definition Modules.h:268
void SetDescription(const CString &s)
Definition Modules.h:318
A CJob version which can be safely used in modules.
Definition Modules.h:235
virtual ~CModuleJob()
const CString & GetDescription() const
Definition Modules.h:247
const CString m_sDescription
Definition Modules.h:253
const CString & GetName() const
Definition Modules.h:246
const CString m_sName
Definition Modules.h:252
CModule * m_pModule
Definition Modules.h:251
CModule * GetModule() const
Definition Modules.h:245
CModuleJob(const CModuleJob &)=delete
CModuleJob & operator=(const CModuleJob &)=delete
CModuleJob(CModule *pModule, const CString &sName, const CString &sDesc)
Definition Modules.h:237
The base class for your own ZNC modules.
Definition Modules.h:421
std::map< CString, std::unique_ptr< CCapability > > m_mServerDependentCaps
Definition Modules.h:1532
CModule(const CModule &)=delete
virtual EModRet OnIRCConnecting(CIRCSock *pIRCSock)
This module hook is called just before ZNC tries to establish a connection to an IRC server.
virtual void OnDevoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual void OnDeop2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is deopped on a channel.
bool UnlinkSocket(CSocket *pSocket)
virtual EModRet OnDeleteNetwork(CIRCNetwork &Network)
This module hook is called when a network is deleted.
bool AddTimer(FPTimer_t pFBCallback, const CString &sLabel, u_int uInterval, u_int uCycles=0, const CString &sDescription="")
virtual EModRet OnUserQuit(CString &sMessage)
CString m_sDescription
Definition Modules.h:1515
virtual void OnVoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is voiced on a channel.
void SetType(CModInfo::EModuleType eType)
Definition Modules.h:1278
virtual EModRet OnBroadcast(CString &sMessage)
This module hook is called when a message is broadcasted to all users.
virtual EModRet OnTopicMessage(CTopicMessage &Message)
Called when we receive a channel topic change from IRC.
EModRet
This enum is just used for return from module hooks.
Definition Modules.h:437
@ HALTCORE
Continue calling other modules.
Definition Modules.h:454
@ HALT
This is the same as both CModule::HALTMODS and CModule::HALTCORE together.
Definition Modules.h:445
@ CONTINUE
ZNC will continue event processing normally.
Definition Modules.h:441
@ HALTMODS
Stop sending this even to other modules which were not called yet.
Definition Modules.h:449
bool MoveRegistry(const CString &sPath)
std::set< CTimer * > m_sTimers
Definition Modules.h:1516
virtual CString GetWebMenuTitle()
Return the title of the module's section in the web interface's side bar.
Definition Modules.h:499
void CancelJob(CModuleJob *pJob)
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 LoadRegistry()
const CString & GetModDataDir() const
Get the module's data dir.
Definition Modules.h:1179
virtual EModRet OnInviteMessage(CInviteMessage &Message)
Called when a user is invited to a channel.
const CString & GetSavePath() const
CSocket * FindSocket(const CString &sSockName)
virtual EModRet OnUserActionMessage(CActionMessage &Message)
Called when a client sends a CTCP ACTION request ("/me").
virtual EModRet OnChanBufferStarting(CChan &Chan, CClient &Client)
Called before a channel buffer is played back to a client.
CString m_sArgs
Definition Modules.h:1529
void InternalServerDependentCapsOnIRCConnected()
virtual void OnChanPermission(const CNick &OpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
virtual EModRet OnPrivTextMessage(CTextMessage &Message)
Called when we receive a private PRIVMSG message from IRC.
virtual EModRet OnUserQuitMessage(CQuitMessage &Message)
This module hook is called when a client quits ZNC.
virtual EModRet OnUserJoinMessage(CJoinMessage &Message)
This hooks is called when a user sends a JOIN message.
virtual void OnJoin(const CNick &Nick, CChan &Channel)
virtual EModRet OnGetModInfo(CModInfo &ModInfo, const CString &sModule, bool &bSuccess, CString &sRetMsg)
Called when info about a module is needed.
void InternalServerDependentCapsOnIRCDisconnected()
virtual void OnMode(const CNick &OpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
virtual void ListTimers()
virtual void OnClientDetached()
Called upon disconnect, and also during JumpNetwork.
virtual EModRet OnModuleUnloading(CModule *pModule, bool &bSuccess, CString &sRetMsg)
Called when a module is going to be unloaded.
virtual void OnRawMode2(const CNick *pOpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
Called on any channel mode change.
virtual EModRet OnPrivBufferStarting(CQuery &Query, CClient &Client)
Called before a query buffer is played back to a client.
ModHandle GetDLL()
Definition Modules.h:1117
CUser * m_pUser
Definition Modules.h:1523
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...
bool SaveRegistry() const
virtual EModRet OnChanActionMessage(CActionMessage &Message)
Called when we receive a channel CTCP ACTION ("/me" in a channel) from IRC.
virtual void OnClientGetSASLMechanisms(SCString &ssMechanisms)
Called when a client requests SASL authentication.
std::set< CSocket * > m_sSockets
Definition Modules.h:1517
virtual void OnRawMode(const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
virtual bool OnBoot()
This module hook is called during ZNC startup.
virtual bool WebRequiresLogin()
Modules which can only be used with an active user session have to return true here.
Definition Modules.h:491
virtual EModRet OnJoining(CChan &Channel)
This module hook is called just before ZNC tries to join an IRC channel.
bool InternalServerDependentCapsIsClientCapSupported(CClient *pClient, const CString &sCap, bool bState)
virtual void OnQuitMessage(CQuitMessage &Message, const std::vector< CChan * > &vChans)
Called when a nick quit from IRC.
virtual EModRet OnUnknownUserRaw(CClient *pClient, CString &sLine)
This function behaves like CModule::OnUserRaw(), but is also called before the client successfully lo...
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).
virtual EModRet OnUserPart(CString &sChannel, CString &sMessage)
void SetDescription(const CString &s)
Definition Modules.h:1279
virtual void OnNick(const CNick &Nick, const CString &sNewNick, const std::vector< CChan * > &vChans)
virtual void OnChanPermission2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
const CString & GetModPath() const
Definition Modules.h:1288
virtual EModRet OnUserTextMessage(CTextMessage &Message)
This module hook is called when a user sends a PRIVMSG message.
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.
MCString::iterator BeginNV()
Definition Modules.h:1269
virtual EModRet OnChanBufferPlayMessage(CMessage &Message)
Called for each message during a channel's buffer play back.
CModInfo::EModuleType m_eType
Definition Modules.h:1514
virtual EModRet OnClientSASLAuthenticate(const CString &sMechanism, const CString &sMessage)
Called when a client is sending us a SASL message after the mechanism was selected.
void SetArgs(const CString &s)
Definition Modules.h:1281
virtual EModRet OnUserCTCP(CString &sTarget, CString &sMessage)
bool UnlinkTimer(CTimer *pTimer)
virtual void OnKick(const CNick &OpNick, const CString &sKickedNick, CChan &Channel, const CString &sMessage)
virtual EModRet OnUserMsg(CString &sTarget, CString &sMessage)
CString m_sModPath
Definition Modules.h:1530
bool RemSocket(const CString &sSockName)
virtual void ClearSubPages()
Removes all registered (AddSubPage'd) SubPages.
Definition Modules.h:536
virtual CString GetWebFilesPath()
void SetUser(CUser *pUser)
virtual void OnModCTCP(const CString &sMessage)
Called when your module nick was sent a CTCP message.
virtual bool OnWebRequest(CWebSock &WebSock, const CString &sPageName, CTemplate &Tmpl)
If OnWebPreRequest returned false, and the RequiresAdmin/IsAdmin check has been passed,...
virtual EModRet OnChanNoticeMessage(CNoticeMessage &Message)
Called when we receive a channel NOTICE message from IRC.
void InternalServerDependentCapsOnClientAttached()
virtual EModRet OnChanBufferEnding(CChan &Chan, CClient &Client)
Called after a channel buffer was played back to a client.
virtual EModRet OnPrivBufferPlayLine2(CClient &Client, CString &sLine, const timeval &tv)
virtual EModRet OnPrivNotice(CNick &Nick, CString &sMessage)
bool AddCommand(const CString &sCmd, const COptionalTranslation &Args, const COptionalTranslation &Desc, std::function< void(const CString &sLine)> func)
virtual EModRet OnPrivBufferPlayLine(CClient &Client, CString &sLine)
virtual void OnDevoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is devoiced on a channel.
void InternalServerDependentCapsOnClientCapLs(CClient *pClient, SCString &ssCaps)
virtual ~CModule()
void SetModPath(const CString &s)
Definition Modules.h:1280
virtual VWebSubPages & GetSubPages()
Returns a list of all registered SubPages.
Definition Modules.h:540
virtual void OnFailedLogin(const CString &sUsername, const CString &sRemoteIP)
Called after a client login was rejected.
virtual EModRet OnPrivBufferEnding(CQuery &Query, CClient &Client)
Called after a query buffer was played back to a client.
CModInfo::EModuleType GetType() const
Definition Modules.h:1285
virtual EModRet OnUserTopic(CString &sChannel, CString &sTopic)
const CModCommand * FindCommand(const CString &sCmd) const
bool RemCommand(const CString &sCmd)
virtual EModRet OnChanNotice(CNick &Nick, CChan &Channel, CString &sMessage)
virtual bool OnServerCapAvailable(const CString &sCap)
Called for every CAP received via CAP LS from server.
void SetClient(CClient *pClient)
virtual void OnClientAttached()
Called after login, and also during JumpNetwork.
virtual void OnKickMessage(CKickMessage &Message)
Called when a nick is kicked from a channel.
virtual bool PutStatus(const CString &sLine)
This function generates a query from *status.
virtual void OnClientLogin()
Called when a client successfully logged in to ZNC.
virtual EModRet OnPrivNoticeMessage(CNoticeMessage &Message)
Called when we receive a private NOTICE message from IRC.
virtual EModRet OnAddNetwork(CIRCNetwork &Network, CString &sErrorRet)
This module hook is called when a network is being added.
virtual EModRet OnChanAction(CNick &Nick, CChan &Channel, CString &sMessage)
virtual EModRet OnPrivCTCPMessage(CCTCPMessage &Message)
Called when we receive a private CTCP request from IRC.
virtual EModRet OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
virtual EModRet OnPrivCTCP(CNick &Nick, CString &sMessage)
bool AddCommand(const CModCommand &Command)
virtual EModRet OnSendToIRC(CString &sLine)
void InternalServerDependentCapsOnClientCapRequest(CClient *pClient, const CString &sCap, bool bState)
virtual bool OnWebPreRequest(CWebSock &WebSock, const CString &sPageName)
For WebMods: Called before the list of registered SubPages will be checked.
virtual EModRet OnUnknownUserRawMessage(CMessage &Message)
virtual EModRet OnPrivTagMessage(CTargetMessage &Message)
Called when we receive a private TAGMSG message from IRC.
const CString & GetModName() const
Definition Modules.h:1168
virtual EModRet OnStatusCommand(CString &sCommand)
Called when a command to *status is sent.
bool DelNV(const CString &sName, bool bWriteToDisk=true)
void HandleHelpCommand(const CString &sLine="")
Send a description of all registered commands via PutModule().
void CancelJobs(const std::set< CModuleJob * > &sJobs)
bool AddTimer(CTimer *pTimer)
virtual void OnClientSASLAborted()
Called when a client sent '*' to abort SASL, or aborted it for another reason.
CModule & operator=(const CModule &)=delete
bool AddCommand(const CString &sCmd, CModCommand::ModCmdFunc func, const CString &sArgs="", const CString &sDesc="")
CTimer * FindTimer(const CString &sLabel)
CModule(ModHandle pDLL, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sDataDir, CModInfo::EModuleType eType=CModInfo::NetworkModule)
CClient * m_pClient
Definition Modules.h:1525
virtual CString GetWebPath()
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.
std::set< CSocket * >::const_iterator BeginSockets() const
Definition Modules.h:1204
bool SetNV(const CString &sName, const CString &sValue, bool bWriteToDisk=true)
std::set< CTimer * >::const_iterator BeginTimers() const
Definition Modules.h:1189
virtual EModRet OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
virtual EModRet OnUserTopicRequest(CString &sChannel)
This hook is called when a user requests a channel's topic.
virtual EModRet OnUserRawMessage(CMessage &Message)
This module hook is called when a client sends any message to ZNC.
CString m_sSavePath
Definition Modules.h:1528
virtual void OnOp(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool AddSocket(CSocket *pSocket)
CTranslationDomainRefHolder m_Translation
Definition Modules.h:1531
virtual bool OnServerCap302Available(const CString &sCap, const CString &sValue)
Called for every CAP received via CAP LS from server.
virtual EModRet OnDeleteUser(CUser &User)
This module hook is called when a user is deleted.
MCString::iterator EndNV()
Definition Modules.h:1268
virtual EModRet OnTopic(CNick &Nick, CChan &Channel, CString &sTopic)
virtual EModRet OnUserCTCPReply(CString &sTarget, CString &sMessage)
CSockManager * GetManager() const
Definition Modules.h:1304
virtual bool OnLoad(const CString &sArgsi, CString &sMessage)
This module hook is called when a module is loaded.
virtual EModRet OnUserPartMessage(CPartMessage &Message)
This hooks is called when a user sends a PART message.
ModHandle m_pDLL
Definition Modules.h:1521
virtual EModRet OnRaw(CString &sLine)
Called on any raw IRC line received from the IRC server.
CString GetModNick() const
virtual void OnJoinMessage(CJoinMessage &Message)
Called when a nick joins a channel.
void DelNV(MCString::iterator it)
Definition Modules.h:1270
virtual void OnDeop(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
virtual EModRet OnUserTopicMessage(CTopicMessage &Message)
This module hook is called when a user wants to change a channel topic.
virtual EModRet OnUserCTCPReplyMessage(CCTCPMessage &Message)
This module hook is called when a client sends a CTCP reply.
bool RemTimer(CTimer *pTimer)
virtual EModRet OnLoginAttempt(std::shared_ptr< CAuthBase > Auth)
This module hook is called when a client tries to login.
virtual void OnIRCDisconnected()
This module hook is called when a user gets disconnected from IRC.
virtual void OnModCommand(const CString &sCommand)
Called when a command to your module is sent, e.g.
virtual void OnClientCapLs(CClient *pClient, SCString &ssCaps)
Called when a client told us CAP LS.
CInlineFormatMessage t_p(const CString &sEnglish, const CString &sEnglishes, int iNum, const CString &sContext="") const
virtual void OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan * > &vChans)
virtual unsigned int PutModule(const CTable &table)
This function calls CModule::PutModule(const CString&, constCString&, const CString&) for each line i...
virtual bool PutModule(const CString &sLine)
This function sends a query from your module nick.
virtual EModRet OnUserNoticeMessage(CNoticeMessage &Message)
This module hook is called when a user sends a NOTICE message.
bool HasNV(const CString &sName) const
Definition Modules.h:1261
virtual EModRet OnPrivBufferPlayMessage(CMessage &Message)
Called for each message during a query's buffer play back.
const CString & GetArgs() const
Definition Modules.h:1287
void AddJob(CModuleJob *pJob)
virtual EModRet OnRawMessage(CMessage &Message)
Called on any raw message received from the IRC server.
virtual void OnPartMessage(CPartMessage &Message)
Called when a nick parts a channel.
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.
CString GetNV(const CString &sName) const
virtual void ListSockets()
virtual bool ValidateWebRequestCSRFCheck(CWebSock &WebSock, const CString &sPageName)
If ValidateWebRequestCSRFCheck returned false, a CSRF error will be printed.
EModException
Definition Modules.h:457
@ UNLOAD
Your module can throw this enum at any given time.
Definition Modules.h:461
virtual void OnNickMessage(CNickMessage &Message, const std::vector< CChan * > &vChans)
Called when a nickname change occurs.
bool UnlinkJob(CModuleJob *pJob)
virtual EModRet OnPrivAction(CNick &Nick, CString &sMessage)
virtual EModRet OnPrivMsg(CNick &Nick, CString &sMessage)
virtual void AddSubPage(TWebSubPage spSubPage)
Registers a sub page for the sidebar.
Definition Modules.h:531
CIRCNetwork * GetNetwork() const
Definition Modules.h:1299
void AddServerDependentCapability(const CString &sName, std::unique_ptr< CCapability > pCap)
Simple API to support client capabilities which depend on server to support that capability.
virtual EModRet OnPrivActionMessage(CActionMessage &Message)
Called when we receive a private CTCP ACTION ("/me" in query) from IRC.
virtual EModRet OnUserNotice(CString &sTarget, CString &sMessage)
virtual EModRet OnChanTagMessage(CTargetMessage &Message)
Called when we receive a channel TAGMSG message from IRC.
virtual EModRet OnChanTextMessage(CTextMessage &Message)
Called when we receive a channel PRIVMSG message from IRC.
virtual EModRet OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
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.
virtual EModRet OnAddUser(CUser &User, CString &sErrorRet)
This module hook is called when a user is being added.
virtual void OnIRCConnected()
This module hook is called after a successful login to IRC.
CInlineFormatMessage t_f(const CString &sEnglish, const CString &sContext="") const
virtual void OnClientDisconnect()
Called when a client disconnected from ZNC.
virtual EModRet OnChanCTCPMessage(CCTCPMessage &Message)
Called when we receive a channel CTCP request from IRC.
virtual EModRet OnSendToIRCMessage(CMessage &Message)
Called immediately before ZNC sends a raw traffic line to the IRC server.
virtual EModRet OnNumericMessage(CNumericMessage &Message)
Called when a numeric message is received from the IRC server.
virtual EModRet OnClientSASLServerInitialChallenge(const CString &sMechanism, CString &sResponse)
Called when a client has selected a SASL mechanism for SASL authentication.
virtual bool WebRequiresAdmin()
Return true if this module should only be usable for admins on the web.
Definition Modules.h:495
virtual EModRet OnUserCTCPMessage(CCTCPMessage &Message)
This module hook is called when a client sends a CTCP request.
CString t_s(const CString &sEnglish, const CString &sContext="") const
virtual EModRet OnIRCRegistration(CString &sPass, CString &sNick, CString &sIdent, CString &sRealName)
This module hook is called before loging in to the IRC server.
std::set< CSocket * >::const_iterator EndSockets() const
Definition Modules.h:1207
virtual bool PutIRC(const CMessage &Message)
This function sends a given IRC message to the IRC server, if we are connected to one.
virtual EModRet OnInvite(const CNick &Nick, const CString &sChan)
Called when user is invited into a channel.
bool CancelJob(const CString &sJobName)
virtual void OnPart(const CNick &Nick, CChan &Channel, const CString &sMessage)
void InternalServerDependentCapsOnServerCapResult(const CString &sCap, bool bSuccess)
virtual EModRet OnUserTagMessage(CTargetMessage &Message)
This module hook is called when a user sends a TAGMSG message.
virtual EModRet OnSendToClientMessage(CMessage &Message)
Called immediately before ZNC sends a raw traffic line to a client.
CUser * GetUser() const
Definition Modules.h:1295
void AddHelpCommand()
Register the "Help" command.
virtual void OnVoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool HandleCommand(const CString &sLine)
This function tries to dispatch the given command via the correct instance of CModCommand.
virtual EModRet OnUserAction(CString &sTarget, CString &sMessage)
const CString & GetDescription() const
Definition Modules.h:1286
virtual bool IsClientCapSupported(CClient *pClient, const CString &sCap, bool bState)
Called only to check if your module supports turning on/off named capability.
virtual void OnPostRehash()
This module hook is called after a successful rehash.
virtual EModRet OnUserRaw(CString &sLine)
This module hook is called when a client sends a raw traffic line to ZNC.
virtual EModRet OnSendToClient(CString &sLine, CClient &Client)
CSockManager * m_pManager
Definition Modules.h:1522
virtual EModRet OnChanBufferPlayLine2(CChan &Chan, CClient &Client, CString &sLine, const timeval &tv)
bool RemSocket(CSocket *pSocket)
virtual void OnUnknownModCommand(const CString &sCommand)
This is similar to OnModCommand(), but it is only called if HandleCommand didn't find any that wants ...
CIRCNetwork * m_pNetwork
Definition Modules.h:1524
virtual bool PutUser(const CString &sLine)
This function sends a given raw IRC line to a client.
virtual bool PutModNotice(const CString &sLine)
Send a notice from your module nick.
virtual EModRet OnCTCPReplyMessage(CCTCPMessage &Message)
Called when we receive a CTCP reply from IRC.
virtual void OnModNotice(const CString &sMessage)
Called when a your module nick was sent a notice.
virtual void OnIRCConnectionError(CIRCSock *pIRCSock)
This module hook is called when a CIRCSock fails to connect or a module returned HALTCORE from OnIRCC...
virtual EModRet OnUserJoin(CString &sChannel, CString &sKey)
void InternalServerDependentCapsOnClientDetached()
CString m_sDataDir
Definition Modules.h:1527
CDelayedTranslation t_d(const CString &sEnglish, const CString &sContext="") const
std::set< CTimer * >::const_iterator EndTimers() const
Definition Modules.h:1192
CString & ExpandString(const CString &sStr, CString &sRet) const
bool RemTimer(const CString &sLabel)
virtual EModRet OnCTCPReply(CNick &Nick, CString &sMessage)
std::set< CModuleJob * > m_sJobs
Definition Modules.h:1519
virtual void OnOp2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
Called when a nick is opped on a channel.
void SetNetwork(CIRCNetwork *pNetwork)
friend struct CModCallProtector
Definition Modules.h:1541
virtual bool PutIRC(const CString &sLine)
This function sends a given IRC line to the IRC server, if we are connected to one.
CClient * GetClient() const
Definition Modules.h:1303
bool InternalServerDependentCapsOnServerCap302Available(const CString &sCap, const CString &sValue)
virtual void OnPreRehash()
Called just before znc.conf is rehashed.
virtual void OnGetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType)
Called when list of available mods is requested.
CString ExpandString(const CString &sStr) const
bool DoEmbeddedWebRequest(CWebSock &WebSock, const CString &sPageName, CTemplate &Tmpl)
CString m_sModName
Definition Modules.h:1526
bool IsCallStackEmpty() const
True if the module can be safely unloaded.
MCString::iterator FindNV(const CString &sName)
Definition Modules.h:1265
bool ClearNV(bool bWriteToDisk=true)
void Unload()
This function throws CModule::UNLOAD which causes this module to be unloaded.
Definition Modules.h:473
Definition Modules.h:1544
static bool GetModInfo(CModInfo &ModInfo, const CString &sModule, CString &sRetMsg)
bool OnUserPartMessage(CPartMessage &Message)
bool OnServerCapResult(const CString &sCap, bool bSuccess)
bool OnModuleLoading(const CString &sModName, const CString &sArgs, CModInfo::EModuleType eType, bool &bSuccess, CString &sRetMsg)
bool OnUserAction(CString &sTarget, CString &sMessage)
bool OnUserCTCPMessage(CCTCPMessage &Message)
bool OnPrivBufferPlayLine(CClient &Client, CString &sLine)
bool OnJoin(const CNick &Nick, CChan &Channel)
bool OnBroadcast(CString &sMessage)
bool OnNumericMessage(CNumericMessage &Message)
bool OnMode2(const CNick *pOpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
bool OnDeleteUser(CUser &User)
bool OnPrivBufferEnding(CQuery &Query, CClient &Client)
std::queue< std::pair< CString, CString > > ModDirList
Definition Modules.h:1735
bool OnChanCTCP(CNick &Nick, CChan &Channel, CString &sMessage)
bool OnRawMessage(CMessage &Message)
bool OnTopic(CNick &Nick, CChan &Channel, CString &sTopic)
bool OnIRCConnectionError(CIRCSock *pIRCSock)
static void GetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType=CModInfo::UserModule)
bool OnPrivAction(CNick &Nick, CString &sMessage)
bool OnClientConnect(CZNCSock *pSock, const CString &sHost, unsigned short uPort)
bool OnPrivBufferPlayMessage(CMessage &Message)
bool OnModNotice(const CString &sMessage)
bool OnChanAction(CNick &Nick, CChan &Channel, CString &sMessage)
bool OnPreRehash()
bool OnClientSASLServerInitialChallenge(const CString &sMechanism, CString &sResponse)
bool OnRaw(CString &sLine)
bool OnPartMessage(CPartMessage &Message)
bool OnLoginAttempt(std::shared_ptr< CAuthBase > Auth)
bool OnClientCapRequest(CClient *pClient, const CString &sCap, bool bState)
CModule * FindModule(const CString &sModule) const
bool OnInviteMessage(CInviteMessage &Message)
bool OnSendToIRCMessage(CMessage &Message)
bool OnUnknownUserRawMessage(CMessage &Message)
bool OnPrivTextMessage(CTextMessage &Message)
bool OnClientCapLs(CClient *pClient, SCString &ssCaps)
bool OnChanBufferEnding(CChan &Chan, CClient &Client)
bool OnServerCapAvailable(const CString &sCap, const CString &sValue)
bool OnQuitMessage(CQuitMessage &Message, const std::vector< CChan * > &vChans)
void UnloadAll()
static ModDirList GetModDirs()
CClient * GetClient() const
Definition Modules.h:1557
bool OnIRCRegistration(CString &sPass, CString &sNick, CString &sIdent, CString &sRealName)
bool IsClientCapSupported(CClient *pClient, const CString &sCap, bool bState)
bool OnGetModInfo(CModInfo &ModInfo, const CString &sModule, bool &bSuccess, CString &sRetMsg)
bool OnUserCTCPReplyMessage(CCTCPMessage &Message)
bool OnUserJoin(CString &sChannel, CString &sKey)
bool OnInvite(const CNick &Nick, const CString &sChan)
bool OnCTCPReply(CNick &Nick, CString &sMessage)
bool OnUserTopicRequest(CString &sChannel)
CIRCNetwork * GetNetwork() const
Definition Modules.h:1556
bool OnQuit(const CNick &Nick, const CString &sMessage, const std::vector< CChan * > &vChans)
bool ReloadModule(const CString &sModule, const CString &sArgs, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
bool OnPrivTagMessage(CTargetMessage &Message)
bool OnUserNoticeMessage(CNoticeMessage &Message)
bool OnDeleteNetwork(CIRCNetwork &Network)
bool OnBoot()
bool OnUserCTCP(CString &sTarget, CString &sMessage)
bool OnChanPermission3(const CNick *pOpNick, const CNick &Nick, CChan &Channel, char cMode, bool bAdded, bool bNoChange)
bool OnClientSASLAuthenticate(const CString &sMechanism, const CString &sBuffer)
bool OnUserCTCPReply(CString &sTarget, CString &sMessage)
bool OnUserRawMessage(CMessage &Message)
void SetClient(CClient *pClient)
Definition Modules.h:1554
bool OnChanBufferPlayLine(CChan &Chan, CClient &Client, CString &sLine)
bool OnChanNoticeMessage(CNoticeMessage &Message)
bool OnChanBufferStarting(CChan &Chan, CClient &Client)
bool OnClientLogin()
bool OnJoinMessage(CJoinMessage &Message)
bool OnChanBufferPlayLine2(CChan &Chan, CClient &Client, CString &sLine, const timeval &tv)
static void GetDefaultMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType=CModInfo::UserModule)
bool OnTopicMessage(CTopicMessage &Message)
bool LoadModule(const CString &sModule, const CString &sArgs, CModInfo::EModuleType eType, CUser *pUser, CIRCNetwork *pNetwork, CString &sRetMsg)
bool OnChanNotice(CNick &Nick, CChan &Channel, CString &sMessage)
bool OnKick(const CNick &Nick, const CString &sOpNick, CChan &Channel, const CString &sMessage)
bool OnOp2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnClientAttached()
bool OnTimerAutoJoin(CChan &Channel)
bool OnChanTextMessage(CTextMessage &Message)
bool OnPostRehash()
bool UnloadModule(const CString &sModule, CString &sRetMsg)
CModules & operator=(const CModules &)=default
bool OnModuleUnloading(CModule *pModule, bool &bSuccess, CString &sRetMsg)
bool OnUserTopic(CString &sChannel, CString &sTopic)
CModules(const CModules &)=default
bool OnGetAvailableMods(std::set< CModInfo > &ssMods, CModInfo::EModuleType eType)
bool OnNickMessage(CNickMessage &Message, const std::vector< CChan * > &vChans)
bool OnAddNetwork(CIRCNetwork &Network, CString &sErrorRet)
bool OnVoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool UnloadModule(const CString &sModule)
bool OnUserRaw(CString &sLine)
bool OnPrivNotice(CNick &Nick, CString &sMessage)
bool OnChanTagMessage(CTargetMessage &Message)
bool OnClientGetSASLMechanisms(SCString &ssMechanisms)
bool OnIRCDisconnected()
bool OnUserActionMessage(CActionMessage &Message)
bool OnChanMsg(CNick &Nick, CChan &Channel, CString &sMessage)
bool OnClientDetached()
bool OnUserMsg(CString &sTarget, CString &sMessage)
bool OnOp(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnChanCTCPMessage(CCTCPMessage &Message)
bool OnModCommand(const CString &sCommand)
bool OnUserTagMessage(CTargetMessage &Message)
bool OnPrivMsg(CNick &Nick, CString &sMessage)
CClient * m_pClient
Definition Modules.h:1777
bool OnClientSASLAborted()
bool OnSendToClient(CString &sLine, CClient &Client)
CUser * GetUser() const
Definition Modules.h:1555
CIRCNetwork * m_pNetwork
Definition Modules.h:1776
bool OnRawMode2(const CNick *pOpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
bool OnPrivNoticeMessage(CNoticeMessage &Message)
bool OnSendToIRC(CString &sLine)
bool OnDevoice2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnChanPermission2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
bool OnUnknownUserRaw(CClient *pClient, CString &sLine)
bool OnDevoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnModCTCP(const CString &sMessage)
static bool GetModPathInfo(CModInfo &ModInfo, const CString &sModule, const CString &sModPath, CString &sRetMsg)
bool OnUserTextMessage(CTextMessage &Message)
bool OnPrivCTCPMessage(CCTCPMessage &Message)
bool OnCTCPReplyMessage(CCTCPMessage &Message)
static bool FindModPath(const CString &sModule, CString &sModPath, CString &sDataPath)
bool OnVoice(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnChanActionMessage(CActionMessage &Message)
bool OnUserQuit(CString &sMessage)
bool OnNick(const CNick &Nick, const CString &sNewNick, const std::vector< CChan * > &vChans)
bool OnPrivCTCP(CNick &Nick, CString &sMessage)
bool OnPrivBufferPlayLine2(CClient &Client, CString &sLine, const timeval &tv)
bool OnUserJoinMessage(CJoinMessage &Message)
bool OnPrivBufferStarting(CQuery &Query, CClient &Client)
bool OnStatusCommand(CString &sCommand)
bool OnKickMessage(CKickMessage &Message)
bool OnIRCConnecting(CIRCSock *pIRCSock)
CUser * m_pUser
Definition Modules.h:1775
bool OnUserNotice(CString &sTarget, CString &sMessage)
bool OnRawMode(const CNick &OpNick, CChan &Channel, const CString &sModes, const CString &sArgs)
bool OnJoining(CChan &Channel)
void SetUser(CUser *pUser)
Definition Modules.h:1552
bool OnIRCConnected()
bool OnDeop2(const CNick *pOpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnUserPart(CString &sChannel, CString &sMessage)
void SetNetwork(CIRCNetwork *pNetwork)
Definition Modules.h:1553
bool OnMode(const CNick &OpNick, CChan &Channel, char uMode, const CString &sArg, bool bAdded, bool bNoChange)
bool OnFailedLogin(const CString &sUsername, const CString &sRemoteIP)
bool OnPart(const CNick &Nick, CChan &Channel, const CString &sMessage)
bool OnUserQuitMessage(CQuitMessage &Message)
bool OnChanBufferPlayMessage(CMessage &Message)
bool OnSendToClientMessage(CMessage &Message)
bool OnDeop(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool OnPrivActionMessage(CActionMessage &Message)
bool OnAddUser(CUser &User, CString &sErrorRet)
bool OnUserTopicMessage(CTopicMessage &Message)
bool OnChanPermission(const CNick &OpNick, const CNick &Nick, CChan &Channel, unsigned char uMode, bool bAdded, bool bNoChange)
bool OnClientDisconnect()
Definition Message.h:290
Definition Nick.h:29
Definition Message.h:298
Definition Message.h:305
Definition Translation.h:85
Definition Message.h:331
Definition Query.h:29
Definition Message.h:340
Definition Socket.h:80
Base Csock implementation to be used by modules.
Definition Socket.h:269
String class that is used inside ZNC.
Definition ZNCString.h:50
Generate a grid-like or list-like output from a given input.
Definition Utils.h:173
Definition Message.h:235
Definition Template.h:129
Definition Message.h:349
Definition Modules.h:183
CModule * m_pModule
Definition Modules.h:204
CModule * GetModule() const
CTimer & operator=(const CTimer &)=delete
void SetModule(CModule *p)
CTimer(const CTimer &)=delete
CString m_sDescription
Definition Modules.h:205
CTimer(CModule *pModule, unsigned int uInterval, unsigned int uCycles, const CString &sLabel, const CString &sDescription)
virtual ~CTimer()
void SetDescription(const CString &s)
const CString & GetDescription() const
Definition Message.h:356
Definition User.h:38
Definition WebModules.h:127
Definition Socket.h:27
Definition znc.h:38
A dictionary for strings.
Definition ZNCString.h:577
CModule * m_pMod
Definition Modules.h:1786
CModCallProtector(CModule &pMod)
Definition Modules.h:1781
~CModCallProtector()
Definition Modules.h:1784
C-style entry point to the module.
Definition Modules.h:81
const char * pcVersion
Definition Modules.h:82
void(*) fpFillModInfo(CModInfo &)
Definition Modules.h:85
const char * pcCompileOptions
Definition Modules.h:84
const char * pcVersionExtra
Definition Modules.h:83
Definition Modules.h:1791
CTemporaryModField(CModule &pMod, T *pValue)
Definition Modules.h:1792
~CTemporaryModField()
Definition Modules.h:1800
Definition Modules.h:1815
~CTemporaryModsField()
Definition Modules.h:1824
CTemporaryModsField(CModules &pMods, T *pValue)
Definition Modules.h:1816
Definition Translation.h:62