1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 20:26:39 +02:00

Rewrote the config reader to better handle invalid configs.

This prevents Anope from exploding when /os reload has errors.
This commit is contained in:
Adam
2010-08-17 19:27:37 -04:00
parent 2575008baa
commit e65d8b2f3d
195 changed files with 3133 additions and 3249 deletions
+13 -13
View File
@@ -27,12 +27,12 @@ class CommandNSSendPass : public Command
Anope::string nick = params[0];
NickAlias *na;
if (Config.RestrictMail && !u->Account()->HasCommand("nickserv/sendpass"))
notice_lang(Config.s_NickServ, u, ACCESS_DENIED);
if (Config->RestrictMail && !u->Account()->HasCommand("nickserv/sendpass"))
notice_lang(Config->s_NickServ, u, ACCESS_DENIED);
else if (!(na = findnick(nick)))
notice_lang(Config.s_NickServ, u, NICK_X_NOT_REGISTERED, nick.c_str());
notice_lang(Config->s_NickServ, u, NICK_X_NOT_REGISTERED, nick.c_str());
else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick.c_str());
notice_lang(Config->s_NickServ, u, NICK_X_FORBIDDEN, na->nick.c_str());
else
{
Anope::string tmp_pass;
@@ -40,12 +40,12 @@ class CommandNSSendPass : public Command
{
if (SendPassMail(u, na, tmp_pass))
{
Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SENDPASS on " << nick;
notice_lang(Config.s_NickServ, u, NICK_SENDPASS_OK, nick.c_str());
Alog() << Config->s_NickServ << ": " << u->GetMask() << " used SENDPASS on " << nick;
notice_lang(Config->s_NickServ, u, NICK_SENDPASS_OK, nick.c_str());
}
}
else
notice_lang(Config.s_NickServ, u, NICK_SENDPASS_UNAVAILABLE);
notice_lang(Config->s_NickServ, u, NICK_SENDPASS_UNAVAILABLE);
}
return MOD_CONT;
@@ -53,18 +53,18 @@ class CommandNSSendPass : public Command
bool OnHelp(User *u, const Anope::string &subcommand)
{
notice_help(Config.s_NickServ, u, NICK_HELP_SENDPASS);
notice_help(Config->s_NickServ, u, NICK_HELP_SENDPASS);
return true;
}
void OnSyntaxError(User *u, const Anope::string &subcommand)
{
syntax_error(Config.s_NickServ, u, "SENDPASS", NICK_SENDPASS_SYNTAX);
syntax_error(Config->s_NickServ, u, "SENDPASS", NICK_SENDPASS_SYNTAX);
}
void OnServHelp(User *u)
{
notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SENDPASS);
notice_lang(Config->s_NickServ, u, NICK_HELP_CMD_SENDPASS);
}
};
@@ -75,7 +75,7 @@ class NSSendPass : public Module
public:
NSSendPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
if (!Config.UseMail)
if (!Config->UseMail)
throw ModuleException("Not using mail, whut.");
Anope::string tmp_pass = "plain:tmp";
@@ -94,9 +94,9 @@ static bool SendPassMail(User *u, NickAlias *na, const Anope::string &pass)
char subject[BUFSIZE], message[BUFSIZE];
snprintf(subject, sizeof(subject), getstring(na, NICK_SENDPASS_SUBJECT), na->nick.c_str());
snprintf(message, sizeof(message), getstring(na, NICK_SENDPASS), na->nick.c_str(), pass.c_str(), Config.NetworkName.c_str());
snprintf(message, sizeof(message), getstring(na, NICK_SENDPASS), na->nick.c_str(), pass.c_str(), Config->NetworkName.c_str());
return Mail(u, na->nc, Config.s_NickServ, subject, message);
return Mail(u, na->nc, Config->s_NickServ, subject, message);
}
MODULE_INIT(NSSendPass)