mirror of
https://github.com/anope/anope.git
synced 2026-06-29 11:36:38 +02:00
Epic commit to replace most of the strings in Anope with a single Anope::string class, plus some other little fixes here and there. If you follow 1.9.x development and are testing things, THIS is one of those things that NEEDS testing.
This commit is contained in:
@@ -22,7 +22,7 @@ class CommandNSResetPass : public Command
|
||||
{
|
||||
}
|
||||
|
||||
CommandReturn Execute(User *u, const std::vector<ci::string> ¶ms)
|
||||
CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
NickAlias *na;
|
||||
|
||||
@@ -31,26 +31,26 @@ class CommandNSResetPass : public Command
|
||||
if (!(na = findnick(params[0])))
|
||||
notice_lang(Config.s_NickServ, u, NICK_X_NOT_REGISTERED, params[0].c_str());
|
||||
else if (na->HasFlag(NS_FORBIDDEN))
|
||||
notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
|
||||
notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick.c_str());
|
||||
else
|
||||
{
|
||||
if (SendResetEmail(u, na))
|
||||
{
|
||||
Alog() << Config.s_NickServ << ": " << u->GetMask() << " used RESETPASS on " << na->nick << " (" << na->nc->display << ")";
|
||||
notice_lang(Config.s_NickServ, u, NICK_RESETPASS_COMPLETE, na->nick);
|
||||
notice_lang(Config.s_NickServ, u, NICK_RESETPASS_COMPLETE, na->nick.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
bool OnHelp(User *u, const ci::string &subcommand)
|
||||
bool OnHelp(User *u, const Anope::string &subcommand)
|
||||
{
|
||||
notice_help(Config.s_NickServ, u, NICK_HELP_RESETPASS);
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnSyntaxError(User *u, const ci::string &subcommand)
|
||||
void OnSyntaxError(User *u, const Anope::string &subcommand)
|
||||
{
|
||||
syntax_error(Config.s_NickServ, u, "RESETPASS", NICK_RESETPASS_SYNTAX);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class CommandNSResetPass : public Command
|
||||
class NSResetPass : public Module
|
||||
{
|
||||
public:
|
||||
NSResetPass(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
NSResetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
|
||||
{
|
||||
if (!Config.UseMail)
|
||||
throw ModuleException("Not using mail.");
|
||||
@@ -77,14 +77,14 @@ class NSResetPass : public Module
|
||||
ModuleManager::Attach(I_OnPreCommand, this);
|
||||
}
|
||||
|
||||
EventReturn OnPreCommand(User *u, const std::string &service, const ci::string &command, const std::vector<ci::string> ¶ms)
|
||||
EventReturn OnPreCommand(User *u, BotInfo *service, const Anope::string &command, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (service == Config.s_NickServ && command == "CONFIRM" && !params.empty())
|
||||
if (service == findbot(Config.s_NickServ) && command.equals_ci("CONFIRM") && !params.empty())
|
||||
{
|
||||
NickAlias *na = findnick(u->nick);
|
||||
|
||||
time_t t;
|
||||
std::string c;
|
||||
Anope::string c;
|
||||
if (na && na->nc->GetExtRegular("ns_resetpass_code", c) && na->nc->GetExtRegular("ns_resetpass_time", t))
|
||||
{
|
||||
if (t < time(NULL) - 3600)
|
||||
@@ -95,16 +95,14 @@ class NSResetPass : public Module
|
||||
return EVENT_STOP;
|
||||
}
|
||||
|
||||
std::string passcode = params[0].c_str();
|
||||
if (passcode == c)
|
||||
Anope::string passcode = params[0];
|
||||
if (passcode.equals_cs(c))
|
||||
{
|
||||
na->nc->Shrink("ns_resetpass_code");
|
||||
na->nc->Shrink("ns_resetpass_time");
|
||||
|
||||
u->UpdateHost();
|
||||
if (na->last_realname)
|
||||
delete [] na->last_realname;
|
||||
na->last_realname = sstrdup(u->realname);
|
||||
na->last_realname = u->realname;
|
||||
na->last_seen = time(NULL);
|
||||
u->Login(na->nc);
|
||||
ircdproto->SendAccountLogin(u, u->Account());
|
||||
@@ -112,7 +110,7 @@ class NSResetPass : public Module
|
||||
FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(u));
|
||||
|
||||
Alog() << Config.s_NickServ << ": " << u->GetMask() << " used CONFIRM with RESETPASS to forcefully identify to " << na->nick;
|
||||
notice_lang(Config.s_NickServ, u, NICK_CONFIRM_SUCCESS, Config.s_NickServ);
|
||||
notice_lang(Config.s_NickServ, u, NICK_CONFIRM_SUCCESS, Config.s_NickServ.c_str());
|
||||
|
||||
if (ircd->vhost)
|
||||
do_on_id(u);
|
||||
@@ -137,9 +135,9 @@ class NSResetPass : public Module
|
||||
|
||||
static bool SendResetEmail(User *u, NickAlias *na)
|
||||
{
|
||||
char subject[BUFSIZE], message[BUFSIZE], passcode[20];
|
||||
char subject[BUFSIZE], message[BUFSIZE];
|
||||
|
||||
snprintf(subject, sizeof(subject), getstring(na, NICK_RESETPASS_SUBJECT), na->nick);
|
||||
snprintf(subject, sizeof(subject), getstring(na, NICK_RESETPASS_SUBJECT), na->nick.c_str());
|
||||
|
||||
int min = 1, max = 62;
|
||||
int chars[] = {
|
||||
@@ -150,17 +148,17 @@ static bool SendResetEmail(User *u, NickAlias *na)
|
||||
'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
||||
};
|
||||
|
||||
Anope::string passcode;
|
||||
int idx;
|
||||
for (idx = 0; idx < 20; ++idx)
|
||||
passcode[idx] = chars[1 + static_cast<int>((static_cast<float>(max - min)) * getrandom16() / 65536.0) + min];
|
||||
passcode[idx] = '\0';
|
||||
passcode += chars[1 + static_cast<int>((static_cast<float>(max - min)) * getrandom16() / 65536.0) + min];
|
||||
|
||||
snprintf(message, sizeof(message), getstring(na, NICK_RESETPASS_MESSAGE), na->nick, Config.s_NickServ, passcode, Config.NetworkName);
|
||||
snprintf(message, sizeof(message), getstring(na, NICK_RESETPASS_MESSAGE), na->nick.c_str(), Config.s_NickServ.c_str(), passcode.c_str(), Config.NetworkName.c_str());
|
||||
|
||||
na->nc->Shrink("ns_resetpass_code");
|
||||
na->nc->Shrink("ns_resetpass_time");
|
||||
|
||||
na->nc->Extend("ns_resetpass_code", new ExtensibleItemRegular<std::string>(passcode));
|
||||
na->nc->Extend("ns_resetpass_code", new ExtensibleItemRegular<Anope::string>(passcode));
|
||||
na->nc->Extend("ns_resetpass_time", new ExtensibleItemRegular<time_t>(time(NULL)));
|
||||
|
||||
return Mail(u, na->nc, Config.s_NickServ, subject, message);
|
||||
|
||||
Reference in New Issue
Block a user