mirror of
https://github.com/anope/anope.git
synced 2026-07-04 23:13:13 +02:00
Finish audit of BotServ commands.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2014 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
@@ -46,16 +46,6 @@ Legend:
|
||||
[ ] HelpServ must die (1.9.1?)
|
||||
[-] Command parser cleanup: mod_current_buffer needs to go away and be replaced by a proper parser. Commands should then indicate how they want the buffer split.
|
||||
These all need reviewing, remove them from the list _AS YOU GO_. Talk t0 w00t or CBX if you don't know what this is for:
|
||||
src/core/bs_assign.c
|
||||
src/core/bs_badwords.c
|
||||
src/core/bs_bot.c
|
||||
src/core/bs_botlist.c
|
||||
src/core/bs_help.c
|
||||
src/core/bs_info.c
|
||||
src/core/bs_kick.c
|
||||
src/core/bs_say.c
|
||||
src/core/bs_set.c
|
||||
src/core/bs_unassign.c
|
||||
src/core/cs_access.c
|
||||
src/core/cs_akick.c
|
||||
src/core/cs_ban.c
|
||||
|
||||
@@ -239,10 +239,9 @@ class CommandBSBadwords : public Command
|
||||
{
|
||||
const char *chan = params[0].c_str();
|
||||
const char *cmd = params[1].c_str();
|
||||
const char *word = params[2].c_str();
|
||||
const char *word = params.size() > 2 ? params[2].c_str() : NULL;
|
||||
ChannelInfo *ci;
|
||||
int need_args = (cmd
|
||||
&& (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR")));
|
||||
int need_args = (cmd && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR")));
|
||||
|
||||
if (!cmd || (need_args ? 0 : !word))
|
||||
{
|
||||
|
||||
+37
-18
@@ -22,10 +22,10 @@ class CommandBSBot : public Command
|
||||
private:
|
||||
CommandReturn DoAdd(User *u, std::vector<std::string> ¶ms)
|
||||
{
|
||||
const char *nick = params[1].c_str();
|
||||
const char *user = params[2].c_str();
|
||||
const char *host = params[3].c_str();
|
||||
const char *real = params[4].c_str();
|
||||
const char *nick = params[0].c_str();
|
||||
const char *user = params[1].c_str();
|
||||
const char *host = params[2].c_str();
|
||||
const char *real = params[3].c_str();
|
||||
const char *ch = NULL;
|
||||
BotInfo *bi;
|
||||
|
||||
@@ -138,11 +138,11 @@ class CommandBSBot : public Command
|
||||
|
||||
CommandReturn DoChange(User *u, std::vector<std::string> ¶ms)
|
||||
{
|
||||
const char *oldnick = params[1].c_str();
|
||||
const char *nick = params[2].c_str();
|
||||
const char *user = params[3].c_str();
|
||||
const char *host = params[4].c_str();
|
||||
const char *real = params[5].c_str();
|
||||
const char *oldnick = params[0].c_str();
|
||||
const char *nick = params[1].c_str();
|
||||
const char *user = params[2].c_str();
|
||||
const char *host = params[3].c_str();
|
||||
const char *real = params[4].c_str();
|
||||
const char *ch = NULL;
|
||||
BotInfo *bi;
|
||||
|
||||
@@ -311,7 +311,7 @@ class CommandBSBot : public Command
|
||||
|
||||
CommandReturn DoDel(User *u, std::vector<std::string> ¶ms)
|
||||
{
|
||||
const char *nick = params[1].c_str();
|
||||
const char *nick = params[0].c_str();
|
||||
BotInfo *bi;
|
||||
|
||||
if (!nick)
|
||||
@@ -340,19 +340,13 @@ class CommandBSBot : public Command
|
||||
return MOD_CONT;
|
||||
}
|
||||
public:
|
||||
CommandBSBot() : Command("BOT", 1, 5)
|
||||
CommandBSBot() : Command("BOT", 1, 6)
|
||||
{
|
||||
}
|
||||
|
||||
CommandReturn Execute(User *u, std::vector<std::string> ¶ms)
|
||||
{
|
||||
const char *cmd = strtok(NULL, " ");
|
||||
|
||||
if (!cmd)
|
||||
{
|
||||
this->OnSyntaxError(u);
|
||||
return MOD_CONT;
|
||||
}
|
||||
const char *cmd = params[0].c_str();
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
@@ -362,14 +356,39 @@ class CommandBSBot : public Command
|
||||
|
||||
if (!stricmp(cmd, "ADD"))
|
||||
{
|
||||
// ADD nick user host real - 5
|
||||
if (params.size() < 5)
|
||||
{
|
||||
this->OnSyntaxError(u);
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
// ADD takes less params than CHANGE, so we need to take 6 if given and append it with a space to 5.
|
||||
if (params.size() >= 6)
|
||||
params[5] = params[5] + " " + params[6];
|
||||
|
||||
return this->DoAdd(u, params);
|
||||
}
|
||||
else if (!stricmp(cmd, "CHANGE"))
|
||||
{
|
||||
// CHANGE oldn newn user host real - 6
|
||||
if (params.size() < 6)
|
||||
{
|
||||
this->OnSyntaxError(u);
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
return this->DoChange(u, params);
|
||||
}
|
||||
else if (!stricmp(cmd, "DEL"))
|
||||
{
|
||||
// DEL nick
|
||||
if (params.size() < 1)
|
||||
{
|
||||
this->OnSyntaxError(u);
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
return this->DoDel(u, params);
|
||||
}
|
||||
else
|
||||
|
||||
+2
-1
@@ -24,12 +24,13 @@ class CommandBSHelp : public Command
|
||||
|
||||
CommandReturn Execute(User *u, std::vector<std::string> ¶ms)
|
||||
{
|
||||
mod_help_cmd(s_BotServ, u, BOTSERV, params.size() > 0 ? params[0].c_str() : NULL);
|
||||
mod_help_cmd(s_BotServ, u, BOTSERV, params[0].c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
void OnSyntaxError(User *u)
|
||||
{
|
||||
// Abuse syntax error to display general list help.
|
||||
notice_help(s_BotServ, u, BOT_HELP);
|
||||
moduleDisplayHelp(4, u);
|
||||
notice_help(s_BotServ, u, BOT_HELP_FOOTER, BSMinUsers);
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ class CommandBSInfo : public Command
|
||||
{
|
||||
BotInfo *bi;
|
||||
ChannelInfo *ci;
|
||||
char *query = strtok(NULL, " ");
|
||||
const char *query = params[0].c_str();
|
||||
|
||||
int need_comma = 0, is_servadmin = is_services_admin(u);
|
||||
char buf[BUFSIZE], *end;
|
||||
|
||||
+19
-11
@@ -30,7 +30,7 @@ class CommandBSKick : public Command
|
||||
const char *chan = params[0].c_str();
|
||||
const char *option = params[1].c_str();
|
||||
const char *value = params[2].c_str();
|
||||
const char *ttb = params[3].c_str();
|
||||
const char *ttb = params.size() > 3 ? params[3].c_str() : NULL;
|
||||
|
||||
ChannelInfo *ci;
|
||||
|
||||
@@ -315,16 +315,24 @@ class CommandBSKick : public Command
|
||||
|
||||
bool OnHelp(User *u, const std::string &subcommand)
|
||||
{
|
||||
// XXX: This is not a good way to handle it, we need to accept params for HELP.
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK);
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_BADWORDS);
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_BOLDS);
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_CAPS);
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_COLORS);
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_FLOOD);
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_REPEAT);
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_REVERSES);
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_UNDERLINES);
|
||||
if (subcommand == "BADWORDS")
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_BADWORDS);
|
||||
else if (subcommand == "BOLDS")
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_BOLDS);
|
||||
else if (subcommand == "CAPS")
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_CAPS);
|
||||
else if (subcommand == "COLORS")
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_COLORS);
|
||||
else if (subcommand == "FLOOD")
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_FLOOD);
|
||||
else if (subcommand == "REPEAT")
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_REPEAT);
|
||||
else if (subcommand == "REVERSES")
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_REVERSES);
|
||||
else if (subcommand == "UNDERLINES")
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK_UNDERLINES);
|
||||
else
|
||||
notice_help(s_BotServ, u, BOT_HELP_KICK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user