mirror of
https://github.com/anope/anope.git
synced 2026-07-03 17:43:13 +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:
+55
-55
@@ -31,15 +31,15 @@ class CommandBSKick : public Command
|
||||
ChannelInfo *ci = cs_findchan(chan);
|
||||
|
||||
if (readonly)
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_DISABLED);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_DISABLED);
|
||||
else if (chan.empty() || option.empty() || value.empty())
|
||||
syntax_error(Config.s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
|
||||
syntax_error(Config->s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
|
||||
else if (!value.equals_ci("ON") && !value.equals_ci("OFF"))
|
||||
syntax_error(Config.s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
|
||||
syntax_error(Config->s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
|
||||
else if (!check_access(u, ci, CA_SET) && !u->Account()->HasPriv("botserv/administration"))
|
||||
notice_lang(Config.s_BotServ, u, ACCESS_DENIED);
|
||||
notice_lang(Config->s_BotServ, u, ACCESS_DENIED);
|
||||
else if (!ci->bi)
|
||||
notice_help(Config.s_BotServ, u, BOT_NOT_ASSIGNED);
|
||||
notice_help(Config->s_BotServ, u, BOT_NOT_ASSIGNED);
|
||||
else
|
||||
{
|
||||
if (option.equals_ci("BADWORDS"))
|
||||
@@ -57,7 +57,7 @@ class CommandBSKick : public Command
|
||||
Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BADWORDS];
|
||||
/* reset the value back to 0 - TSL */
|
||||
ci->ttb[TTB_BADWORDS] = 0;
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -65,14 +65,14 @@ class CommandBSKick : public Command
|
||||
ci->ttb[TTB_BADWORDS] = 0;
|
||||
ci->botflags.SetFlag(BS_KICK_BADWORDS);
|
||||
if (ci->ttb[TTB_BADWORDS])
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN, ci->ttb[TTB_BADWORDS]);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN, ci->ttb[TTB_BADWORDS]);
|
||||
else
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_ON);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BADWORDS_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_KICK_BADWORDS);
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_OFF);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BADWORDS_OFF);
|
||||
}
|
||||
}
|
||||
else if (option.equals_ci("BOLDS"))
|
||||
@@ -87,7 +87,7 @@ class CommandBSKick : public Command
|
||||
{
|
||||
Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BOLDS];
|
||||
ci->ttb[TTB_BOLDS] = 0;
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -95,14 +95,14 @@ class CommandBSKick : public Command
|
||||
ci->ttb[TTB_BOLDS] = 0;
|
||||
ci->botflags.SetFlag(BS_KICK_BOLDS);
|
||||
if (ci->ttb[TTB_BOLDS])
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_ON_BAN, ci->ttb[TTB_BOLDS]);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BOLDS_ON_BAN, ci->ttb[TTB_BOLDS]);
|
||||
else
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_ON);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BOLDS_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_KICK_BOLDS);
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_OFF);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BOLDS_OFF);
|
||||
}
|
||||
}
|
||||
else if (option.equals_ci("CAPS"))
|
||||
@@ -120,7 +120,7 @@ class CommandBSKick : public Command
|
||||
{
|
||||
Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_CAPS];
|
||||
ci->ttb[TTB_CAPS] = 0;
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -143,14 +143,14 @@ class CommandBSKick : public Command
|
||||
|
||||
ci->botflags.SetFlag(BS_KICK_CAPS);
|
||||
if (ci->ttb[TTB_CAPS])
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON_BAN, ci->capsmin, ci->capspercent, ci->ttb[TTB_CAPS]);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_CAPS_ON_BAN, ci->capsmin, ci->capspercent, ci->ttb[TTB_CAPS]);
|
||||
else
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON, ci->capsmin, ci->capspercent);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_CAPS_ON, ci->capsmin, ci->capspercent);
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_KICK_CAPS);
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_OFF);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_CAPS_OFF);
|
||||
}
|
||||
}
|
||||
else if (option.equals_ci("COLORS"))
|
||||
@@ -165,7 +165,7 @@ class CommandBSKick : public Command
|
||||
{
|
||||
Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_COLORS];
|
||||
ci->ttb[TTB_COLORS] = 0;
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -173,14 +173,14 @@ class CommandBSKick : public Command
|
||||
ci->ttb[TTB_COLORS] = 0;
|
||||
ci->botflags.SetFlag(BS_KICK_COLORS);
|
||||
if (ci->ttb[TTB_COLORS])
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_ON_BAN, ci->ttb[TTB_COLORS]);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_COLORS_ON_BAN, ci->ttb[TTB_COLORS]);
|
||||
else
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_ON);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_COLORS_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_KICK_COLORS);
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_OFF);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_COLORS_OFF);
|
||||
}
|
||||
}
|
||||
else if (option.equals_ci("FLOOD"))
|
||||
@@ -198,7 +198,7 @@ class CommandBSKick : public Command
|
||||
{
|
||||
Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_FLOOD];
|
||||
ci->ttb[TTB_FLOOD] = 0;
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -216,19 +216,19 @@ class CommandBSKick : public Command
|
||||
ci->floodsecs = 10;
|
||||
else
|
||||
ci->floodsecs = secs.is_number_only() ? convertTo<int16>(secs) : 10;
|
||||
if (ci->floodsecs < 1 || ci->floodsecs > Config.BSKeepData)
|
||||
if (ci->floodsecs < 1 || ci->floodsecs > Config->BSKeepData)
|
||||
ci->floodsecs = 10;
|
||||
|
||||
ci->botflags.SetFlag(BS_KICK_FLOOD);
|
||||
if (ci->ttb[TTB_FLOOD])
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON_BAN, ci->floodlines, ci->floodsecs, ci->ttb[TTB_FLOOD]);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_FLOOD_ON_BAN, ci->floodlines, ci->floodsecs, ci->ttb[TTB_FLOOD]);
|
||||
else
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON, ci->floodlines, ci->floodsecs);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_FLOOD_ON, ci->floodlines, ci->floodsecs);
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_KICK_FLOOD);
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_OFF);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_FLOOD_OFF);
|
||||
}
|
||||
}
|
||||
else if (option.equals_ci("REPEAT"))
|
||||
@@ -245,7 +245,7 @@ class CommandBSKick : public Command
|
||||
{
|
||||
Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REPEAT];
|
||||
ci->ttb[TTB_REPEAT] = 0;
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -261,14 +261,14 @@ class CommandBSKick : public Command
|
||||
|
||||
ci->botflags.SetFlag(BS_KICK_REPEAT);
|
||||
if (ci->ttb[TTB_REPEAT])
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON_BAN, ci->repeattimes, ci->ttb[TTB_REPEAT]);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_REPEAT_ON_BAN, ci->repeattimes, ci->ttb[TTB_REPEAT]);
|
||||
else
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON, ci->repeattimes);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_REPEAT_ON, ci->repeattimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_KICK_REPEAT);
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_OFF);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_REPEAT_OFF);
|
||||
}
|
||||
}
|
||||
else if (option.equals_ci("REVERSES"))
|
||||
@@ -283,7 +283,7 @@ class CommandBSKick : public Command
|
||||
{
|
||||
Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REVERSES];
|
||||
ci->ttb[TTB_REVERSES] = 0;
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -291,14 +291,14 @@ class CommandBSKick : public Command
|
||||
ci->ttb[TTB_REVERSES] = 0;
|
||||
ci->botflags.SetFlag(BS_KICK_REVERSES);
|
||||
if (ci->ttb[TTB_REVERSES])
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_ON_BAN, ci->ttb[TTB_REVERSES]);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_REVERSES_ON_BAN, ci->ttb[TTB_REVERSES]);
|
||||
else
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_ON);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_REVERSES_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_KICK_REVERSES);
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_OFF);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_REVERSES_OFF);
|
||||
}
|
||||
}
|
||||
else if (option.equals_ci("UNDERLINES"))
|
||||
@@ -313,7 +313,7 @@ class CommandBSKick : public Command
|
||||
{
|
||||
Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_UNDERLINES];
|
||||
ci->ttb[TTB_UNDERLINES] = 0;
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -321,14 +321,14 @@ class CommandBSKick : public Command
|
||||
ci->ttb[TTB_UNDERLINES] = 0;
|
||||
ci->botflags.SetFlag(BS_KICK_UNDERLINES);
|
||||
if (ci->ttb[TTB_UNDERLINES])
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN, ci->ttb[TTB_UNDERLINES]);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN, ci->ttb[TTB_UNDERLINES]);
|
||||
else
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_ON);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_UNDERLINES_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_KICK_UNDERLINES);
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_OFF);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_UNDERLINES_OFF);
|
||||
}
|
||||
}
|
||||
else if (option.equals_ci("ITALICS"))
|
||||
@@ -343,7 +343,7 @@ class CommandBSKick : public Command
|
||||
{
|
||||
Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_ITALICS];
|
||||
ci->ttb[TTB_ITALICS] = 0;
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -351,18 +351,18 @@ class CommandBSKick : public Command
|
||||
ci->ttb[TTB_ITALICS] = 0;
|
||||
ci->botflags.SetFlag(BS_KICK_ITALICS);
|
||||
if (ci->ttb[TTB_ITALICS])
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_ITALICS_ON_BAN, ci->ttb[TTB_ITALICS]);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_ITALICS_ON_BAN, ci->ttb[TTB_ITALICS]);
|
||||
else
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_ITALICS_ON);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_ITALICS_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_KICK_ITALICS);
|
||||
notice_lang(Config.s_BotServ, u, BOT_KICK_ITALICS_OFF);
|
||||
notice_lang(Config->s_BotServ, u, BOT_KICK_ITALICS_OFF);
|
||||
}
|
||||
}
|
||||
else
|
||||
notice_help(Config.s_BotServ, u, BOT_KICK_UNKNOWN, option.c_str());
|
||||
notice_help(Config->s_BotServ, u, BOT_KICK_UNKNOWN, option.c_str());
|
||||
}
|
||||
return MOD_CONT;
|
||||
}
|
||||
@@ -370,25 +370,25 @@ class CommandBSKick : public Command
|
||||
bool OnHelp(User *u, const Anope::string &subcommand)
|
||||
{
|
||||
if (subcommand.empty())
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK);
|
||||
else if (subcommand.equals_ci("BADWORDS"))
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK_BADWORDS);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK_BADWORDS);
|
||||
else if (subcommand.equals_ci("BOLDS"))
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK_BOLDS);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK_BOLDS);
|
||||
else if (subcommand.equals_ci("CAPS"))
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK_CAPS);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK_CAPS);
|
||||
else if (subcommand.equals_ci("COLORS"))
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK_COLORS);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK_COLORS);
|
||||
else if (subcommand.equals_ci("FLOOD"))
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK_FLOOD);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK_FLOOD);
|
||||
else if (subcommand.equals_ci("REPEAT"))
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK_REPEAT);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK_REPEAT);
|
||||
else if (subcommand.equals_ci("REVERSES"))
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK_REVERSES);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK_REVERSES);
|
||||
else if (subcommand.equals_ci("UNDERLINES"))
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK_UNDERLINES);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK_UNDERLINES);
|
||||
else if (subcommand.equals_ci("ITALICS"))
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_KICK_ITALICS);
|
||||
notice_help(Config->s_BotServ, u, BOT_HELP_KICK_ITALICS);
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -397,12 +397,12 @@ class CommandBSKick : public Command
|
||||
|
||||
void OnSyntaxError(User *u, const Anope::string &subcommand)
|
||||
{
|
||||
syntax_error(Config.s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
|
||||
syntax_error(Config->s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
|
||||
}
|
||||
|
||||
void OnServHelp(User *u)
|
||||
{
|
||||
notice_lang(Config.s_BotServ, u, BOT_HELP_CMD_KICK);
|
||||
notice_lang(Config->s_BotServ, u, BOT_HELP_CMD_KICK);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user