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
|
/* NickServ core functions
*
* (C) 2003-2012 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 CommandNSSet : public Command
{
public:
CommandNSSet(Module *creator) : Command(creator, "nickserv/set", 1, 3)
{
this->SetDesc(_("Set options, including kill protection"));
this->SetSyntax(_("\037option\037 \037parameters\037"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
{
this->OnSyntaxError(source, "");
return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Sets various nickname options. \037option\037 can be one of:"));
Anope::string this_name = source.command;
for (BotInfo::command_map::const_iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
{
const Anope::string &c_name = it->first;
const CommandInfo &info = it->second;
if (c_name.find_ci(this_name + " ") == 0)
{
service_reference<Command> command("Command", info.name);
if (command)
{
source.command = c_name;
command->OnServHelp(source);
}
}
}
source.Reply(_("Type \002%s%s HELP %s \037option\037\002 for more information\n"
"on a specific option."), Config->UseStrictPrivMsgString.c_str(), source.owner->nick.c_str(), source.command.c_str());
return true;
}
};
class CommandNSSetPassword : public Command
{
public:
CommandNSSetPassword(Module *creator) : Command(creator, "nickserv/set/password", 1)
{
this->SetDesc(_("Set your nickname password"));
this->SetSyntax(_("\037new-password\037"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
{
const Anope::string ¶m = params[1];
unsigned len = param.length();
if (source.GetNick().equals_ci(param) || (Config->StrictPasswords && len < 5))
{
source.Reply(MORE_OBSCURE_PASSWORD);
return;
}
else if (len > Config->PassLen)
{
source.Reply(PASSWORD_TOO_LONG);
return;
}
enc_encrypt(param, source.nc->pass);
Anope::string tmp_pass;
if (enc_decrypt(source.nc->pass, tmp_pass) == 1)
source.Reply(_("Password for \002%s\002 changed to \002%s\002."), source.nc->display.c_str(), tmp_pass.c_str());
else
source.Reply(_("Password for \002%s\002 changed."), source.nc->display.c_str());
return;
}
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Changes the password used to identify you as the nick's\n"
"owner."));
return true;
}
};
class NSSet : public Module
{
CommandNSSet commandnsset;
CommandNSSetPassword commandnssetpassword;
public:
NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
commandnsset(this), commandnssetpassword(this)
{
this->SetAuthor("Anope");
}
};
MODULE_INIT(NSSet)
|