-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdisconnectonban.cpp
More file actions
36 lines (29 loc) · 1.44 KB
/
disconnectonban.cpp
File metadata and controls
36 lines (29 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Disconnect On Ban module.
// Prevent your ZNC from re-connecting to a network if you are network banned.
#include <znc/IRCNetwork.h>
#include <znc/Modules.h>
#include <znc/User.h> // For GetUser()->GetStatusPrefix()
class Cdisconnectonban : public CModule {
public:
MODCONSTRUCTOR(Cdisconnectonban) {}
virtual ~Cdisconnectonban() {}
EModRet OnNumericMessage(CNumericMessage& msg) override {
if (msg.GetCode() == 465) {
CString sPrefix = GetUser()->GetStatusPrefix();
// :irc.server.com 465 mynick :You are banned from this server- Temporary K-line 1 min. - Example (2024/12/29 15.39)
m_pNetwork->SetIRCConnectEnabled(false);
// Send message to client by *status.
// TODO: Figure out how to remove extra spaces around module name?
m_pNetwork->PutStatus("You are banned from the network. ZNC has disabled the network by the \x002 disconnectonban \x002 module. Use ` /msg " + sPrefix + "status jump ` to reconnect.");
// Send message to client via *disconnectonban
//PutModule("You are banned from the network. ZNC has disabled the network because this module is loaded.");
}
return CONTINUE;
}
};
template <>
void TModInfo<Cdisconnectonban>(CModInfo& Info) {
//Info.SetWikiPage("disconnectonban");
}
// Network only module.
NETWORKMODULEDEFS(Cdisconnectonban, "Disconnect ZNC from the network when you are K/G/Z-lined.")