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
170class CCapability {
171 public:
172 virtual ~CCapability() = default;
173 virtual void OnServerChangedSupport(CIRCNetwork* pNetwork, bool bState) {}
174 virtual void OnClientChangedSupport(CClient* pClient, bool bState) {}
177 void SetModule(CModule* p) { m_pModule = p; }
178
179 protected:
180 CModule* m_pModule = nullptr;
181};
183class CTimer : public CCron {
184 public:
185 CTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles,
186 const CString& sLabel, const CString& sDescription);
188 virtual ~CTimer();
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};
208typedef void (*FPTimer_t)(CModule*, CFPTimer*);
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) {}
217 virtual ~CFPTimer() {}
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();
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
257typedef void* ModHandle;
259class CModInfo {
260 public:
263 typedef CModule* (*ModLoader)(ModHandle p, CUser* pUser,
264 CIRCNetwork* pNetwork,
265 const CString& sModName,
266 const CString& sModPath, EModuleType eType);
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) {}
279 ~CModInfo() {}
281 bool operator<(const CModInfo& Info) const {
282 return (GetName() < Info.GetName());
283 }
285 bool SupportsType(EModuleType eType) const {
286 return m_seType.find(eType) != m_seType.end();
287 }
289 void AddType(EModuleType eType) { m_seType.insert(eType); }
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; }
312 EModuleType GetDefaultType() const { return m_eDefaultType; }
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; }
323 void SetDefaultType(EModuleType eType) { m_eDefaultType = eType; }
324 // !Setters
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>
345CModule* TModLoad(ModHandle p, CUser* pUser, CIRCNetwork* pNetwork,
346 const CString& sModName, const CString& sModPath,
347 CModInfo::EModuleType eType) {
348 return new M(p, pUser, pNetwork, sModName, sModPath, eType);
349}
350
352class CModCommand : private CCoreTranslationMixin {
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;
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(); }
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:
423 CModule(
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();
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;
457 typedef enum {
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 ""; }
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
759 virtual EModRet OnInviteMessage(CInviteMessage& Message);
768 virtual EModRet OnInvite(const CNick& Nick, const CString& sChan);
769
775 virtual EModRet OnChanBufferStarting(CChan& Chan, CClient& Client);
781 virtual EModRet OnChanBufferEnding(CChan& Chan, CClient& Client);
782
788 virtual EModRet OnChanBufferPlayMessage(CMessage& Message);
790 virtual EModRet OnChanBufferPlayLine2(CChan& Chan, CClient& Client,
791 CString& sLine, const timeval& tv);
793 virtual EModRet OnChanBufferPlayLine(CChan& Chan, CClient& Client,
794 CString& sLine);
795
802 virtual EModRet OnPrivBufferStarting(CQuery& Query, CClient& Client);
809 virtual EModRet OnPrivBufferEnding(CQuery& Query, CClient& Client);
810
816 virtual EModRet OnPrivBufferPlayMessage(CMessage& Message);
818 virtual EModRet OnPrivBufferPlayLine2(CClient& Client, CString& sLine,
819 const timeval& tv);
821 virtual EModRet OnPrivBufferPlayLine(CClient& Client, CString& sLine);
822
824 virtual void OnClientLogin();
826 virtual void OnClientDisconnect();
827
832 virtual EModRet OnUserRaw(CString& sLine);
838 virtual EModRet OnUserRawMessage(CMessage& Message);
839
847 virtual EModRet OnUserCTCPReply(CString& sTarget, CString& sMessage);
848
856 virtual EModRet OnUserCTCPMessage(CCTCPMessage& Message);
858 virtual EModRet OnUserCTCP(CString& sTarget, CString& sMessage);
859
868 virtual EModRet OnUserAction(CString& sTarget, CString& sMessage);
869
875 virtual EModRet OnUserTextMessage(CTextMessage& Message);
877 virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage);
878
886 virtual EModRet OnUserNotice(CString& sTarget, CString& sMessage);
887
893 virtual EModRet OnUserJoinMessage(CJoinMessage& Message);
895 virtual EModRet OnUserJoin(CString& sChannel, CString& sKey);
896
902 virtual EModRet OnUserPartMessage(CPartMessage& Message);
904 virtual EModRet OnUserPart(CString& sChannel, CString& sMessage);
905
911 virtual EModRet OnUserTopicMessage(CTopicMessage& Message);
913 virtual EModRet OnUserTopic(CString& sChannel, CString& sTopic);
914
919 virtual EModRet OnUserTopicRequest(CString& sChannel);
920
926 virtual EModRet OnUserQuitMessage(CQuitMessage& Message);
928 virtual EModRet OnUserQuit(CString& sMessage);
929
935 virtual EModRet OnCTCPReplyMessage(CCTCPMessage& Message);
937 virtual EModRet OnCTCPReply(CNick& Nick, CString& sMessage);
938
944 virtual EModRet OnPrivCTCPMessage(CCTCPMessage& Message);
946 virtual EModRet OnPrivCTCP(CNick& Nick, CString& sMessage);
947
953 virtual EModRet OnChanCTCPMessage(CCTCPMessage& Message);
955 virtual EModRet OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
956
964 virtual EModRet OnPrivAction(CNick& Nick, CString& sMessage);
965
973 virtual EModRet OnChanAction(CNick& Nick, CChan& Channel,
974 CString& sMessage);
975
981 virtual EModRet OnPrivTextMessage(CTextMessage& Message);
983 virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage);
984
990 virtual EModRet OnChanTextMessage(CTextMessage& Message);
992 virtual EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
993
1001 virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage);
1002
1008 virtual EModRet OnChanNoticeMessage(CNoticeMessage& Message);
1010 virtual EModRet OnChanNotice(CNick& Nick, CChan& Channel,
1011 CString& sMessage);
1012
1018 virtual EModRet OnTopicMessage(CTopicMessage& Message);
1020 virtual EModRet OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
1021
1029 virtual bool OnServerCapAvailable(const CString& sCap);
1040 virtual bool OnServerCap302Available(const CString& sCap, const CString& sValue);
1048 virtual void OnServerCapResult(const CString& sCap, bool bSuccess);
1049
1055 virtual EModRet OnTimerAutoJoin(CChan& Channel);
1056
1063 virtual EModRet OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1068 virtual EModRet OnDeleteNetwork(CIRCNetwork& Network);
1069
1076 virtual EModRet OnSendToClientMessage(CMessage& Message);
1078 virtual EModRet OnSendToClient(CString& sLine, CClient& Client);
1079
1086 virtual EModRet OnSendToIRCMessage(CMessage& Message);
1088 virtual EModRet OnSendToIRC(CString& sLine);
1089
1095 virtual EModRet OnUserTagMessage(CTargetMessage& Message);
1101 virtual EModRet OnChanTagMessage(CTargetMessage& Message);
1107 virtual EModRet OnPrivTagMessage(CTargetMessage& Message);
1109 ModHandle GetDLL() { return m_pDLL; }
1110
1116 virtual bool PutIRC(const CString& sLine);
1122 virtual bool PutIRC(const CMessage& Message);
1130 virtual bool PutUser(const CString& sLine);
1137 virtual bool PutStatus(const CString& sLine);
1144 virtual bool PutModule(const CString& sLine);
1150 virtual unsigned int PutModule(const CTable& table);
1157 virtual bool PutModNotice(const CString& sLine);
1158
1160 const CString& GetModName() const { return m_sModName; }
1161
1165 CString GetModNick() const;
1166
1171 const CString& GetModDataDir() const { return m_sDataDir; }
1172
1173 // Timer stuff
1174 bool AddTimer(CTimer* pTimer);
1175 bool AddTimer(FPTimer_t pFBCallback, const CString& sLabel, u_int uInterval,
1176 u_int uCycles = 0, const CString& sDescription = "");
1177 bool RemTimer(CTimer* pTimer);
1178 bool RemTimer(const CString& sLabel);
1179 bool UnlinkTimer(CTimer* pTimer);
1180 CTimer* FindTimer(const CString& sLabel);
1181 std::set<CTimer*>::const_iterator BeginTimers() const {
1182 return m_sTimers.begin();
1184 std::set<CTimer*>::const_iterator EndTimers() const {
1185 return m_sTimers.end();
1187 virtual void ListTimers();
1188 // !Timer stuff
1189
1190 // Socket stuff
1191 bool AddSocket(CSocket* pSocket);
1192 bool RemSocket(CSocket* pSocket);
1193 bool RemSocket(const CString& sSockName);
1194 bool UnlinkSocket(CSocket* pSocket);
1195 CSocket* FindSocket(const CString& sSockName);
1196 std::set<CSocket*>::const_iterator BeginSockets() const {
1197 return m_sSockets.begin();
1199 std::set<CSocket*>::const_iterator EndSockets() const {
1200 return m_sSockets.end();
1202 virtual void ListSockets();
1203// !Socket stuff
1204
1205#ifdef HAVE_PTHREAD
1206 // Job stuff
1207 void AddJob(CModuleJob* pJob);
1209 bool CancelJob(const CString& sJobName);
1210 void CancelJobs(const std::set<CModuleJob*>& sJobs);
1211 bool UnlinkJob(CModuleJob* pJob);
1212// !Job stuff
1213#endif
1214
1215 // Command stuff
1217 void AddHelpCommand();
1219 bool AddCommand(const CModCommand& Command);
1222 bool AddCommand(const CString& sCmd, CModCommand::ModCmdFunc func,
1223 const CString& sArgs = "", const CString& sDesc = "");
1226 bool AddCommand(const CString& sCmd, const COptionalTranslation& Args,
1227 const COptionalTranslation& Desc,
1228 std::function<void(const CString& sLine)> func);
1230 bool RemCommand(const CString& sCmd);
1232 const CModCommand* FindCommand(const CString& sCmd) const;
1240 bool HandleCommand(const CString& sLine);
1244 void HandleHelpCommand(const CString& sLine = "");
1245 // !Command stuff
1248 bool SaveRegistry() const;
1249 bool MoveRegistry(const CString& sPath);
1250 bool SetNV(const CString& sName, const CString& sValue,
1251 bool bWriteToDisk = true);
1252 CString GetNV(const CString& sName) const;
1253 bool HasNV(const CString& sName) const {
1254 return m_mssRegistry.find(sName) != m_mssRegistry.end();
1256 bool DelNV(const CString& sName, bool bWriteToDisk = true);
1257 MCString::iterator FindNV(const CString& sName) {
1258 return m_mssRegistry.find(sName);
1260 MCString::iterator EndNV() { return m_mssRegistry.end(); }
1261 MCString::iterator BeginNV() { return m_mssRegistry.begin(); }
1262 void DelNV(MCString::iterator it) { m_mssRegistry.erase(it); }
1263 bool ClearNV(bool bWriteToDisk = true);
1265 const CString& GetSavePath() const;
1266 CString ExpandString(const CString& sStr) const;
1267 CString& ExpandString(const CString& sStr, CString& sRet) const;
1268
1269 // Setters
1270 void SetType(CModInfo::EModuleType eType) { m_eType = eType; }
1271 void SetDescription(const CString& s) { m_sDescription = s; }
1272 void SetModPath(const CString& s) { m_sModPath = s; }
1273 void SetArgs(const CString& s) { m_sArgs = s; }
1274 // !Setters
1275
1276 // Getters
1278 const CString& GetDescription() const { return m_sDescription; }
1279 const CString& GetArgs() const { return m_sArgs; }
1280 const CString& GetModPath() const { return m_sModPath; }
1281
1287 CUser* GetUser() const { return m_pUser; }
1291 CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1295 CClient* GetClient() const { return m_pClient; }
1296 CSockManager* GetManager() const { return m_pManager; }
1297 // !Getters
1298
1299 // Global Modules
1306 virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
1311 virtual EModRet OnDeleteUser(CUser& User);
1318 virtual void OnClientConnect(CZNCSock* pSock, const CString& sHost,
1319 unsigned short uPort);
1326 virtual EModRet OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1331 virtual void OnFailedLogin(const CString& sUsername,
1332 const CString& sRemoteIP);
1339 virtual EModRet OnUnknownUserRaw(CClient* pClient, CString& sLine);
1340 virtual EModRet OnUnknownUserRawMessage(CMessage& Message);
1341
1343 virtual void OnClientAttached();
1345 virtual void OnClientDetached();
1346
1347#ifndef SWIG
1361 void AddServerDependentCapability(const CString& sName, std::unique_ptr<CCapability> pCap);
1362#endif
1363
1371 virtual void OnClientCapLs(CClient* pClient, SCString& ssCaps);
1378 virtual bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1379 bool bState);
1391 virtual void OnClientCapRequest(CClient* pClient, const CString& sCap,
1392 bool bState);
1393
1399 virtual void OnClientGetSASLMechanisms(SCString& ssMechanisms);
1413 const CString& sMechanism, CString& sResponse);
1428 virtual EModRet OnClientSASLAuthenticate(const CString& sMechanism,
1429 const CString& sMessage);
1433 virtual void OnClientSASLAborted();
1434
1444 virtual EModRet OnModuleLoading(const CString& sModName,
1445 const CString& sArgs,
1446 CModInfo::EModuleType eType, bool& bSuccess,
1447 CString& sRetMsg);
1455 virtual EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess,
1456 CString& sRetMsg);
1464 virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
1465 bool& bSuccess, CString& sRetMsg);
1470 virtual void OnGetAvailableMods(std::set<CModInfo>& ssMods,
1471 CModInfo::EModuleType eType);
1472 // !Global Modules
1473
1474#ifndef SWIG
1475 // Translation
1476 CString t_s(const CString& sEnglish, const CString& sContext = "") const;
1477 CInlineFormatMessage t_f(const CString& sEnglish,
1478 const CString& sContext = "") const;
1479 CInlineFormatMessage t_p(const CString& sEnglish, const CString& sEnglishes,
1480 int iNum, const CString& sContext = "") const;
1481 CDelayedTranslation t_d(const CString& sEnglish,
1482 const CString& sContext = "") const;
1483#endif
1484
1485 // Default implementations of several callbacks to make
1486 // AddServerDependentCapability work in modpython/modperl.
1487 // Don't worry about existence of these functions.
1489 const CString& sCap, const CString& sValue);
1491 bool bSuccess);
1493 SCString& ssCaps);
1495 const CString& sCap,
1496 bool bState);
1498 const CString& sCap,
1499 bool bState);
1504
1505 protected:
1508 std::set<CTimer*> m_sTimers;
1509 std::set<CSocket*> m_sSockets;
1510#ifdef HAVE_PTHREAD
1511 std::set<CModuleJob*> m_sJobs;
1512#endif
1524 std::map<CString, std::unique_ptr<CCapability>> m_mServerDependentCaps;
1525
1526 private:
1527 MCString
1528 m_mssRegistry;
1529 VWebSubPages m_vSubPages;
1530 std::map<CString, CModCommand> m_mCommands;
1531};
1533class CModules : public std::vector<CModule*>, private CCoreTranslationMixin {
1534 public:
1536 ~CModules();
1538 CModules(const CModules&) = default;
1539 CModules& operator=(const CModules&) = default;
1541 void SetUser(CUser* pUser) { m_pUser = pUser; }
1542 void SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
1543 void SetClient(CClient* pClient) { m_pClient = pClient; }
1544 CUser* GetUser() const { return m_pUser; }
1545 CIRCNetwork* GetNetwork() const { return m_pNetwork; }
1546 CClient* GetClient() const { return m_pClient; }
1548 void UnloadAll();
1550 bool OnBoot();
1555 bool OnIRCConnecting(CIRCSock* pIRCSock);
1557 bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent,
1558 CString& sRealName);
1559 bool OnBroadcast(CString& sMessage);
1561 bool OnChanPermission3(const CNick* pOpNick, const CNick& Nick,
1562 CChan& Channel, char cMode, bool bAdded,
1563 bool bNoChange);
1564 bool OnChanPermission2(const CNick* pOpNick, const CNick& Nick,
1565 CChan& Channel, unsigned char uMode, bool bAdded,
1566 bool bNoChange);
1567 bool OnChanPermission(const CNick& OpNick, const CNick& Nick,
1568 CChan& Channel, unsigned char uMode, bool bAdded,
1569 bool bNoChange);
1570 bool OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1571 bool bNoChange);
1572 bool OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1573 bool bNoChange);
1574 bool OnDeop2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1575 bool bNoChange);
1576 bool OnDeop(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1577 bool bNoChange);
1578 bool OnVoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1579 bool bNoChange);
1580 bool OnVoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1581 bool bNoChange);
1582 bool OnDevoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel,
1583 bool bNoChange);
1584 bool OnDevoice(const CNick& OpNick, const CNick& Nick, CChan& Channel,
1585 bool bNoChange);
1586 bool OnRawMode2(const CNick* pOpNick, CChan& Channel, const CString& sModes,
1587 const CString& sArgs);
1588 bool OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes,
1589 const CString& sArgs);
1590 bool OnMode2(const CNick* pOpNick, CChan& Channel, char uMode,
1591 const CString& sArg, bool bAdded, bool bNoChange);
1592 bool OnMode(const CNick& OpNick, CChan& Channel, char uMode,
1593 const CString& sArg, bool bAdded, bool bNoChange);
1595 bool OnRaw(CString& sLine);
1596 bool OnRawMessage(CMessage& Message);
1597 bool OnNumericMessage(CNumericMessage& Message);
1599 bool OnStatusCommand(CString& sCommand);
1600 bool OnModCommand(const CString& sCommand);
1601 bool OnModNotice(const CString& sMessage);
1602 bool OnModCTCP(const CString& sMessage);
1604 bool OnQuit(const CNick& Nick, const CString& sMessage,
1605 const std::vector<CChan*>& vChans);
1606 bool OnQuitMessage(CQuitMessage& Message,
1607 const std::vector<CChan*>& vChans);
1608 bool OnNick(const CNick& Nick, const CString& sNewNick,
1609 const std::vector<CChan*>& vChans);
1610 bool OnNickMessage(CNickMessage& Message,
1611 const std::vector<CChan*>& vChans);
1612 bool OnKick(const CNick& Nick, const CString& sOpNick, CChan& Channel,
1613 const CString& sMessage);
1615 bool OnJoining(CChan& Channel);
1616 bool OnJoin(const CNick& Nick, CChan& Channel);
1618 bool OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage);
1620 bool OnInvite(const CNick& Nick, const CString& sChan);
1621 bool OnInviteMessage(CInviteMessage& Message);
1623 bool OnChanBufferStarting(CChan& Chan, CClient& Client);
1624 bool OnChanBufferEnding(CChan& Chan, CClient& Client);
1625 bool OnChanBufferPlayLine2(CChan& Chan, CClient& Client, CString& sLine,
1626 const timeval& tv);
1627 bool OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
1628 bool OnPrivBufferStarting(CQuery& Query, CClient& Client);
1629 bool OnPrivBufferEnding(CQuery& Query, CClient& Client);
1630 bool OnPrivBufferPlayLine2(CClient& Client, CString& sLine,
1631 const timeval& tv);
1632 bool OnPrivBufferPlayLine(CClient& Client, CString& sLine);
1634 bool OnPrivBufferPlayMessage(CMessage& Message);
1638 bool OnUserRaw(CString& sLine);
1640 bool OnUserCTCPReply(CString& sTarget, CString& sMessage);
1642 bool OnUserCTCP(CString& sTarget, CString& sMessage);
1644 bool OnUserAction(CString& sTarget, CString& sMessage);
1646 bool OnUserMsg(CString& sTarget, CString& sMessage);
1648 bool OnUserNotice(CString& sTarget, CString& sMessage);
1650 bool OnUserJoin(CString& sChannel, CString& sKey);
1652 bool OnUserPart(CString& sChannel, CString& sMessage);
1654 bool OnUserTopic(CString& sChannel, CString& sTopic);
1657 bool OnUserQuit(CString& sMessage);
1661 bool OnPrivTagMessage(CTargetMessage& Message);
1663 bool OnCTCPReply(CNick& Nick, CString& sMessage);
1665 bool OnPrivCTCP(CNick& Nick, CString& sMessage);
1667 bool OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage);
1669 bool OnPrivAction(CNick& Nick, CString& sMessage);
1671 bool OnChanAction(CNick& Nick, CChan& Channel, CString& sMessage);
1673 bool OnPrivMsg(CNick& Nick, CString& sMessage);
1675 bool OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
1677 bool OnPrivNotice(CNick& Nick, CString& sMessage);
1679 bool OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage);
1681 bool OnTopic(CNick& Nick, CChan& Channel, CString& sTopic);
1683 bool OnTimerAutoJoin(CChan& Channel);
1685 bool OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet);
1686 bool OnDeleteNetwork(CIRCNetwork& Network);
1688 bool OnSendToClient(CString& sLine, CClient& Client);
1690 bool OnSendToIRC(CString& sLine);
1693 bool OnClientDetached();
1695 bool OnServerCapAvailable(const CString& sCap, const CString& sValue);
1696 bool OnServerCapResult(const CString& sCap, bool bSuccess);
1698 CModule* FindModule(const CString& sModule) const;
1699 bool LoadModule(const CString& sModule, const CString& sArgs,
1700 CModInfo::EModuleType eType, CUser* pUser,
1701 CIRCNetwork* pNetwork, CString& sRetMsg);
1702 bool UnloadModule(const CString& sModule);
1703 bool UnloadModule(const CString& sModule, CString& sRetMsg);
1704 bool ReloadModule(const CString& sModule, const CString& sArgs,
1705 CUser* pUser, CIRCNetwork* pNetwork, CString& sRetMsg);
1707 static bool GetModInfo(CModInfo& ModInfo, const CString& sModule,
1708 CString& sRetMsg);
1709 static bool GetModPathInfo(CModInfo& ModInfo, const CString& sModule,
1710 const CString& sModPath, CString& sRetMsg);
1711 static void GetAvailableMods(
1712 std::set<CModInfo>& ssMods,
1714 static void GetDefaultMods(
1715 std::set<CModInfo>& ssMods,
1717
1718 // This returns the path to the .so and to the data dir
1719 // which is where static data (webadmin skins) are saved
1720 static bool FindModPath(const CString& sModule, CString& sModPath,
1721 CString& sDataPath);
1722 // Return a list of <module dir, data dir> pairs for directories in
1723 // which modules can be found.
1724 typedef std::queue<std::pair<CString, CString>> ModDirList;
1725 static ModDirList GetModDirs();
1726
1727 // Global Modules
1728 bool OnAddUser(CUser& User, CString& sErrorRet);
1729 bool OnDeleteUser(CUser& User);
1730 bool OnClientConnect(CZNCSock* pSock, const CString& sHost,
1731 unsigned short uPort);
1732 bool OnLoginAttempt(std::shared_ptr<CAuthBase> Auth);
1733 bool OnFailedLogin(const CString& sUsername, const CString& sRemoteIP);
1734 bool OnUnknownUserRaw(CClient* pClient, CString& sLine);
1736 bool OnClientCapLs(CClient* pClient, SCString& ssCaps);
1737 bool IsClientCapSupported(CClient* pClient, const CString& sCap,
1738 bool bState);
1739 bool OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState);
1743 bool OnClientSASLServerInitialChallenge(const CString& sMechanism,
1744 CString& sResponse);
1745 bool OnClientSASLAuthenticate(const CString& sMechanism,
1746 const CString& sBuffer);
1748 bool OnModuleLoading(const CString& sModName, const CString& sArgs,
1749 CModInfo::EModuleType eType, bool& bSuccess,
1750 CString& sRetMsg);
1751 bool OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
1752 bool OnGetModInfo(CModInfo& ModInfo, const CString& sModule, bool& bSuccess,
1753 CString& sRetMsg);
1754 bool OnGetAvailableMods(std::set<CModInfo>& ssMods,
1755 CModInfo::EModuleType eType);
1756 // !Global Modules
1757
1758 private:
1759 static ModHandle OpenModule(const CString& sModule, const CString& sModPath,
1760 CModInfo& Info, CString& sRetMsg);
1761 static bool ValidateModuleName(const CString& sModule, CString& sRetMsg);
1762
1763 protected:
1767};
1768
1769#endif // !ZNC_MODULES_H
void * ModHandle
Definition Modules.h:256
CModule * TModLoad(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, CModInfo::EModuleType eType)
Definition Modules.h:344
void TModInfo(CModInfo &Info)
Definition Modules.h:341
void(* FPTimer_t)(CModule *, CFPTimer *)
Definition Modules.h:207
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:234
Definition Client.h:38
Definition Message.h:252
Definition Modules.h:169
CModule * m_pModule
Definition Modules.h:179
virtual void OnClientChangedSupport(CClient *pClient, bool bState)
Definition Modules.h:173
CModule * GetModule()
Definition Modules.h:175
virtual void OnServerChangedSupport(CIRCNetwork *pNetwork, bool bState)
Definition Modules.h:172
void SetModule(CModule *p)
Definition Modules.h:176
virtual ~CCapability()=default
Definition Chan.h:35
Definition Client.h:99
Definition Translation.h:103
this is the main cron job class
Definition Csocket.h:393
Definition Translation.h:71
Definition Modules.h:209
virtual ~CFPTimer()
Definition Modules.h:216
void SetFPCallback(FPTimer_t p)
Definition Modules.h:218
void RunJob() override
this is the method you should override
Definition Modules.h:221
Definition IRCNetwork.h:40
Definition IRCSock.h:35
Definition ZNCString.h:673
Definition Message.h:314
A job is a task which should run without blocking the main thread.
Definition Threads.h:67
Definition Message.h:262
Definition Message.h:303
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:351
CModCommand & operator=(const CModCommand &other)=default
Assignment operator, needed so that this can be saved in a std::map.
CString GetDescription() const
Definition Modules.h:396
void AddHelp(CTable &Table) const
Add this command to the CTable instance.
static void InitHelp(CTable &Table)
Initialize a CTable so that it can be used with AddHelp().
void(CModule::* ModCmdFunc)(const CString &sLine)
Type for the callback function that handles the actual command.
Definition Modules.h:354
CModCommand()
Default constructor, needed so that this can be saved in a std::map.
CmdFunc GetFunction() const
Definition Modules.h:394
void Call(const CString &sLine) const
Definition Modules.h:398
std::function< void(const CString &sLine)> CmdFunc
Definition Modules.h:355
CString GetArgs() const
Definition Modules.h:395
const CString & GetCommand() const
Definition Modules.h:393
Definition Modules.h:258
const CString & GetPath() const
Definition Modules.h:305
void SetName(const CString &s)
Definition Modules.h:315
void SetHasArgs(bool b=false)
Definition Modules.h:320
CString m_sWikiPage
Definition Modules.h:334
void SetArgsHelpText(const CString &s)
Definition Modules.h:319
bool m_bHasArgs
Definition Modules.h:336
const CString & GetName() const
Definition Modules.h:304
void SetLoader(ModLoader fLoader)
Definition Modules.h:321
EModuleType m_eDefaultType
Definition Modules.h:330
EModuleType
Definition Modules.h:260
@ NetworkModule
Definition Modules.h:260
@ UserModule
Definition Modules.h:260
@ GlobalModule
Definition Modules.h:260
CString t_s(const CString &sEnglish, const CString &sContext="") const
CString m_sName
Definition Modules.h:331
bool operator<(const CModInfo &Info) const
Definition Modules.h:280
static CString ModuleTypeToString(EModuleType eType)
Definition Modules.h:290
bool GetHasArgs() const
Definition Modules.h:309
bool SupportsType(EModuleType eType) const
Definition Modules.h:284
~CModInfo()
Definition Modules.h:278
void SetPath(const CString &s)
Definition Modules.h:316
CString m_sDescription
Definition Modules.h:333
void SetWikiPage(const CString &s)
Definition Modules.h:318
std::set< EModuleType > m_seType
Definition Modules.h:329
void AddType(EModuleType eType)
Definition Modules.h:288
const CString & GetWikiPage() const
Definition Modules.h:307
const CString & GetArgsHelpText() const
Definition Modules.h:308
CModInfo(const CString &sName, const CString &sPath, EModuleType eType)
Definition Modules.h:268
CString m_sArgsHelpText
Definition Modules.h:335
ModLoader m_fLoader
Definition Modules.h:337
ModLoader GetLoader() const
Definition Modules.h:310
void SetDefaultType(EModuleType eType)
Definition Modules.h:322
const CString & GetDescription() const
Definition Modules.h:306
EModuleType GetDefaultType() const
Definition Modules.h:311
CString m_sPath
Definition Modules.h:332
CModule *(* ModLoader)(ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, EModuleType eType)
Definition Modules.h:262
CModInfo()
Definition Modules.h:267
void SetDescription(const CString &s)
Definition Modules.h:317
A CJob version which can be safely used in modules.
Definition Modules.h:234
virtual ~CModuleJob()
const CString & GetDescription() const
Definition Modules.h:246
const CString m_sDescription
Definition Modules.h:252
const CString & GetName() const
Definition Modules.h:245
const CString m_sName
Definition Modules.h:251
CModule * m_pModule
Definition Modules.h:250
CModule * GetModule() const
Definition Modules.h:244
CModuleJob & operator=(const CModuleJob &)=delete
The base class for your own ZNC modules.
Definition Modules.h:420
std::map< CString, std::unique_ptr< CCapability > > m_mServerDependentCaps
Definition Modules.h:1523
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:1506
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:1269
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:436
@ HALTCORE
Continue calling other modules.
Definition Modules.h:453
@ HALT
This is the same as both CModule::HALTMODS and CModule::HALTCORE together.
Definition Modules.h:444
@ CONTINUE
ZNC will continue event processing normally.
Definition Modules.h:440
@ HALTMODS
Stop sending this even to other modules which were not called yet.
Definition Modules.h:448
bool MoveRegistry(const CString &sPath)
std::set< CTimer * > m_sTimers
Definition Modules.h:1507
virtual CString GetWebMenuTitle()
Return the title of the module's section in the web interface's side bar.
Definition Modules.h:495
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:1170
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:1520
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:1108
CUser * m_pUser
Definition Modules.h:1514
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:1508
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:487
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:1270
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:1279
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:1260
virtual EModRet OnChanBufferPlayMessage(CMessage &Message)
Called for each message during a channel's buffer play back.
CModInfo::EModuleType m_eType
Definition Modules.h:1505
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:1272
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:1521
bool RemSocket(const CString &sSockName)
virtual void ClearSubPages()
Removes all registered (AddSubPage'd) SubPages.
Definition Modules.h:532
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)
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:1271
virtual VWebSubPages & GetSubPages()
Returns a list of all registered SubPages.
Definition Modules.h:536
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:1276
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 bool OnEmbeddedWebRequest(CWebSock &WebSock, const CString &sPageName, CTemplate &Tmpl)
Using this hook, module can embed web stuff directly to different places.
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:1159
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
CTimer * FindTimer(const CString &sLabel)
CClient * m_pClient
Definition Modules.h:1516
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:1195
bool SetNV(const CString &sName, const CString &sValue, bool bWriteToDisk=true)
std::set< CTimer * >::const_iterator BeginTimers() const
Definition Modules.h:1180
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:1519
virtual void OnOp(const CNick &OpNick, const CNick &Nick, CChan &Channel, bool bNoChange)
bool AddSocket(CSocket *pSocket)
CTranslationDomainRefHolder m_Translation
Definition Modules.h:1522
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:1259
virtual EModRet OnTopic(CNick &Nick, CChan &Channel, CString &sTopic)
virtual EModRet OnUserCTCPReply(CString &sTarget, CString &sMessage)
CSockManager * GetManager() const
Definition Modules.h:1295
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:1512
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.
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 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:1252
virtual EModRet OnPrivBufferPlayMessage(CMessage &Message)
Called for each message during a query's buffer play back.
const CString & GetArgs() const
Definition Modules.h:1278
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:456
@ UNLOAD
Your module can throw this enum at any given time.
Definition Modules.h:460
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:527
CIRCNetwork * GetNetwork() const
Definition Modules.h:1290
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:491
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:1198
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:1286
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:1277
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:1513
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:1515
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:1518
CDelayedTranslation t_d(const CString &sEnglish, const CString &sContext="") const
std::set< CTimer * >::const_iterator EndTimers() const
Definition Modules.h:1183
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:1510
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)
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:1294
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
CString m_sModName
Definition Modules.h:1517
MCString::iterator FindNV(const CString &sName)
Definition Modules.h:1256
bool ClearNV(bool bWriteToDisk=true)
void Unload()
This function throws CModule::UNLOAD which causes this module to be unloaded.
Definition Modules.h:469
Definition Modules.h:1532
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:1723
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:1545
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:1544
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:1542
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)
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:1765
bool OnClientSASLAborted()
bool OnSendToClient(CString &sLine, CClient &Client)
CUser * GetUser() const
Definition Modules.h:1543
CIRCNetwork * m_pNetwork
Definition Modules.h:1764
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:1763
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:1540
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:1541
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:282
Definition Nick.h:29
Definition Message.h:290
Definition Message.h:297
Definition Translation.h:85
CString Resolve() const
Definition Translation.h:90
Definition Message.h:323
Definition Query.h:29
Definition Message.h:332
Definition Socket.h:80
Base Csock implementation to be used by modules.
Definition Socket.h:247
String class that is used inside ZNC.
Definition ZNCString.h:68
Generate a grid-like or list-like output from a given input.
Definition Utils.h:173
Definition Message.h:227
Definition Template.h:129
Definition Message.h:341
Definition Modules.h:182
CModule * m_pModule
Definition Modules.h:203
CModule * GetModule() const
CTimer & operator=(const CTimer &)=delete
void SetModule(CModule *p)
CString m_sDescription
Definition Modules.h:204
virtual ~CTimer()
void SetDescription(const CString &s)
const CString & GetDescription() const
Definition Message.h:348
Definition User.h:38
Definition WebModules.h:127
Definition Socket.h:27
Definition znc.h:38
A dictionary for strings.
Definition ZNCString.h:595
C-style entry point to the module.
Definition Modules.h:81
void(* fpFillModInfo)(CModInfo &)
Definition Modules.h:85
const char * pcVersion
Definition Modules.h:82
const char * pcCompileOptions
Definition Modules.h:84
const char * pcVersionExtra
Definition Modules.h:83
Definition Translation.h:62