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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
/* NickServ core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
class CommandNSSuspend : public Command
{
public:
CommandNSSuspend(Module *creator) : Command(creator, "nickserv/suspend", 2, 2)
{
this->SetDesc(_("Suspend a given nick"));
this->SetSyntax(_("\037nickname\037 \037reason\037"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
{
User *u = source.u;
const Anope::string &nick = params[0];
const Anope::string &reason = params[1];
if (readonly)
{
source.Reply(READ_ONLY_MODE);
return;
}
NickAlias *na = findnick(nick);
if (!na)
{
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
return;
}
if (Config->NSSecureAdmins && na->nc->IsServicesOper())
{
source.Reply(ACCESS_DENIED);
return;
}
na->nc->SetFlag(NI_SUSPENDED);
na->nc->SetFlag(NI_SECURE);
na->nc->UnsetFlag(NI_KILLPROTECT);
na->nc->UnsetFlag(NI_KILL_QUICK);
na->nc->UnsetFlag(NI_KILL_IMMED);
for (std::list<NickAlias *>::iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end; ++it)
{
NickAlias *na2 = *it;
if (na2->nc == na->nc)
{
na2->last_quit = reason;
User *u2 = finduser(na2->nick);
if (u2)
{
u2->Logout();
u2->Collide(na2);
}
}
}
Log(LOG_ADMIN, u, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << ")";
source.Reply(_("Nick %s is now suspended."), nick.c_str());
FOREACH_MOD(I_OnNickSuspended, OnNickSuspend(na));
return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Suspends a registered nickname, which prevents from being used\n"
"while keeping all the data for that nick."));
return true;
}
};
class CommandNSUnSuspend : public Command
{
public:
CommandNSUnSuspend(Module *creator) : Command(creator, "nickserv/unsuspend", 1, 1)
{
this->SetDesc(_("Unsuspend a given nick"));
this->SetSyntax(_("\037nickname\037"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
{
User *u = source.u;
const Anope::string &nick = params[0];
if (readonly)
{
source.Reply(READ_ONLY_MODE);
return;
}
NickAlias *na = findnick(nick);
if (!na)
{
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
return;
}
if (Config->NSSecureAdmins && na->nc->IsServicesOper())
{
source.Reply(ACCESS_DENIED);
return;
}
na->nc->UnsetFlag(NI_SUSPENDED);
Log(LOG_ADMIN, u, this) << "for " << na->nick;
source.Reply(_("Nick %s is now released."), nick.c_str());
FOREACH_MOD(I_OnNickUnsuspended, OnNickUnsuspended(na));
return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Unsuspends a nickname which allows it to be used again."));
return true;
}
};
class NSSuspend : public Module
{
CommandNSSuspend commandnssuspend;
CommandNSUnSuspend commandnsunsuspend;
public:
NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
commandnssuspend(this), commandnsunsuspend(this)
{
this->SetAuthor("Anope");
ModuleManager::RegisterService(&commandnssuspend);
ModuleManager::RegisterService(&commandnsunsuspend);
}
};
MODULE_INIT(NSSuspend)
|