-
Notifications
You must be signed in to change notification settings - Fork 6
/
cs_akick_check.cpp
95 lines (79 loc) · 2.04 KB
/
cs_akick_check.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* ChanServ AKICK Check
*
* (C) 2018 - Matt Schatz ([email protected])
* Please refer to the GPL License in use by Anope at:
* https://github.com/anope/anope/blob/master/docs/COPYING
*
* Check channel AKICKs upon services start, when a user
* logs in or out of an account, groups a nick, or
* changes their nickname or displayed host.
*
* Configuration to put into your chanserv config:
module { name = "cs_akick_check" }
*/
#include "module.h"
class CSAkickCheck : public Module
{
public:
CSAkickCheck(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, THIRD)
{
if (Anope::VersionMajor() != 2 || Anope::VersionMinor() != 0)
throw ModuleException("Requires version 2.0.x of Anope.");
this->SetAuthor("genius3000");
this->SetVersion("1.0.0");
}
void OnUplinkSync(Server *) anope_override
{
for (channel_map::const_iterator chan = ChannelList.begin(), chan_end = ChannelList.end(); chan != chan_end; ++chan)
{
Channel *c = chan->second;
for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
ChanUserContainer *uc = it->second;
++it;
c->CheckKick(uc->user);
}
}
}
void CheckAkicks(User *u)
{
for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; )
{
ChanUserContainer *cc = it->second;
++it;
Channel *c = cc->chan;
if (c)
c->CheckKick(u);
}
}
// Hacky way to catch IDENT changes.
void OnLog(Log *l) anope_override
{
if (!Me || !Me->IsSynced() || l->type != LOG_USER || l->u == NULL || l->category != "ident")
return;
CheckAkicks(l->u);
}
void OnNickGroup(User *u, NickAlias *) anope_override
{
CheckAkicks(u);
}
void OnNickLogout(User *u) anope_override
{
CheckAkicks(u);
}
void OnSetDisplayedHost(User *u) anope_override
{
CheckAkicks(u);
}
void OnUserNickChange(User *u, const Anope::string &) anope_override
{
CheckAkicks(u);
}
void OnUserLogin(User *u) anope_override
{
CheckAkicks(u);
}
};
MODULE_INIT(CSAkickCheck)