summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commands.c29
-rw-r--r--src/core/bs_kick.c7
-rw-r--r--src/core/bs_set.c16
-rw-r--r--src/core/cs_help.c39
-rw-r--r--src/core/cs_set.c12
-rw-r--r--src/core/ms_set.c2
-rw-r--r--src/core/ns_help.c1
-rw-r--r--src/core/ns_saset.c2
-rw-r--r--src/core/ns_set.c8
-rw-r--r--src/core/os_set.c2
-rw-r--r--src/hashcomp.cpp2
11 files changed, 64 insertions, 56 deletions
diff --git a/src/commands.c b/src/commands.c
index d4932fe4d..6c422a9d7 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -15,6 +15,7 @@
#include "services.h"
#include "commands.h"
#include "language.h"
+#include "hashcomp.h"
/*************************************************************************/
@@ -96,7 +97,7 @@ XXX: priv checking
return;
}
*/
-
+
std::vector<std::string> params;
std::string curparam;
char *s = NULL;
@@ -180,23 +181,21 @@ void do_help_limited(char *service, User * u, Command * c)
void mod_help_cmd(char *service, User * u, CommandHash * cmdTable[],
const char *cmd)
{
- Command *c = findCommand(cmdTable, cmd);
- Command *current;
bool has_had_help = false;
int cont = MOD_CONT;
- const char *p1 = NULL, *p2 = NULL, *p3 = NULL, *p4 = NULL;
-
- for (current = c; (current) && (cont == MOD_CONT);
- current = current->next) {
- p1 = current->help_param1;
- p2 = current->help_param2;
- p3 = current->help_param3;
- p4 = current->help_param4;
- has_had_help = current->OnHelp(u, ""); // XXX: this needs finishing to actually pass a subcommand
- }
- if (has_had_help == false) {
+
+ spacesepstream tokens(cmd);
+ std::string token;
+ tokens.GetToken(token);
+
+ Command *c = findCommand(cmdTable, token.c_str());
+
+ std::string subcommand = tokens.StreamEnd() ? "" : tokens.GetRemaining();
+
+ for (Command *current = c; current && cont == MOD_CONT; current = current->next)
+ has_had_help = current->OnHelp(u, subcommand);
+ if (!has_had_help)
notice_lang(service, u, NO_HELP_AVAILABLE, cmd);
- }
//else {
// do_help_limited(service, u, c);
//}
diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c
index 525a6da23..2e5d1d724 100644
--- a/src/core/bs_kick.c
+++ b/src/core/bs_kick.c
@@ -315,7 +315,9 @@ class CommandBSKick : public Command
bool OnHelp(User *u, const std::string &subcommand)
{
- if (subcommand == "BADWORDS")
+ if (subcommand.empty())
+ notice_help(s_BotServ, u, BOT_HELP_KICK);
+ else 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);
@@ -332,7 +334,8 @@ class CommandBSKick : public Command
else if (subcommand == "UNDERLINES")
notice_help(s_BotServ, u, BOT_HELP_KICK_UNDERLINES);
else
- notice_help(s_BotServ, u, BOT_HELP_KICK);
+ return false;
+
return true;
}
diff --git a/src/core/bs_set.c b/src/core/bs_set.c
index b03b622b1..d8bf4c03b 100644
--- a/src/core/bs_set.c
+++ b/src/core/bs_set.c
@@ -150,7 +150,13 @@ class CommandBSSet : public Command
bool OnHelp(User *u, const std::string &subcommand)
{
- if (subcommand == "DONTKICKOPS")
+ if (subcommand.empty())
+ {
+ notice_help(s_BotServ, u, BOT_HELP_SET);
+ if (is_services_admin(u))
+ notice_help(s_BotServ, u, BOT_SERVADMIN_HELP_SET);
+ }
+ else if (subcommand == "DONTKICKOPS")
notice_help(s_BotServ, u, BOT_HELP_SET_DONTKICKOPS);
else if (subcommand == "DONTKICKVOICES")
notice_help(s_BotServ, u, BOT_HELP_SET_DONTKICKVOICES);
@@ -164,12 +170,8 @@ class CommandBSSet : public Command
notice_lang(s_BotServ, u, BOT_SERVADMIN_HELP_SET_NOBOT);
else if (subcommand == "PRIVATE")
notice_lang(s_BotServ, u, BOT_SERVADMIN_HELP_SET_PRIVATE);
- else if (subcommand.empty())
- {
- notice_help(s_BotServ, u, BOT_HELP_SET);
- if (is_services_admin(u) || is_services_root(u))
- notice_help(s_BotServ, u, BOT_SERVADMIN_HELP_SET);
- }
+ else
+ return false;
return true;
}
diff --git a/src/core/cs_help.c b/src/core/cs_help.c
index 17ec5fe4c..173fe1a7f 100644
--- a/src/core/cs_help.c
+++ b/src/core/cs_help.c
@@ -6,8 +6,8 @@
* 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.
- *
+ * Based on the original code of Services by Andy Church.
+ *
* $Id$
*
*/
@@ -18,29 +18,21 @@
class CommandCSHelp : public Command
{
public:
- CommandCSHelp() : Command("HELP", 0, 2)
+ CommandCSHelp() : Command("HELP", 1, 1)
{
this->SetFlag(CFLAG_ALLOW_UNREGISTERED);
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
- const char *cmd = params.size() > 0 ? params[0].c_str() : NULL;
+ const char *cmd = params[0].c_str();
- if (!cmd)
- {
- notice_help(s_ChanServ, u, CHAN_HELP);
- moduleDisplayHelp(2, u);
- if (CSExpire >= 86400)
- notice_help(s_ChanServ, u, CHAN_HELP_EXPIRES, CSExpire / 86400);
- if (is_services_oper(u))
- notice_help(s_ChanServ, u, CHAN_SERVADMIN_HELP);
- }
- else if (stricmp(cmd, "LEVELS DESC") == 0)
+ if (!stricmp(cmd, "LEVELS DESC"))
{
int i;
notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC);
- if (!levelinfo_maxwidth) {
+ if (!levelinfo_maxwidth)
+ {
for (i = 0; levelinfo[i].what >= 0; i++)
{
int len = strlen(levelinfo[i].name);
@@ -50,17 +42,24 @@ class CommandCSHelp : public Command
}
for (i = 0; levelinfo[i].what >= 0; i++)
{
- notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC_FORMAT,
- levelinfo_maxwidth, levelinfo[i].name,
- getstring(u, levelinfo[i].desc));
+ notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC_FORMAT, levelinfo_maxwidth, levelinfo[i].name, getstring(u, levelinfo[i].desc));
}
}
else
- {
mod_help_cmd(s_ChanServ, u, CHANSERV, cmd);
- }
+
return MOD_CONT;
}
+
+ void OnSyntaxError(User *u)
+ {
+ notice_help(s_ChanServ, u, CHAN_HELP);
+ moduleDisplayHelp(2, u);
+ if (CSExpire >= 86400)
+ notice_help(s_ChanServ, u, CHAN_HELP_EXPIRES, CSExpire / 86400);
+ if (is_services_oper(u))
+ notice_help(s_ChanServ, u, CHAN_SERVADMIN_HELP);
+ }
};
diff --git a/src/core/cs_set.c b/src/core/cs_set.c
index 76ec975b8..63a2bfb36 100644
--- a/src/core/cs_set.c
+++ b/src/core/cs_set.c
@@ -668,14 +668,9 @@ class CommandCSSet : public Command
{
if (subcommand.empty())
{
- if (is_services_admin(u) || is_services_root(u))
- {
+ notice_help(s_ChanServ, u, CHAN_HELP_SET);
+ if (is_services_admin(u))
notice_help(s_ChanServ, u, CHAN_SERVADMIN_HELP_SET);
- }
- else
- {
- notice_help(s_ChanServ, u, CHAN_HELP_SET);
- }
}
else if (subcommand == "FOUNDER")
notice_help(s_ChanServ, u, CHAN_HELP_SET_FOUNDER);
@@ -719,6 +714,9 @@ class CommandCSSet : public Command
notice_help(s_ChanServ, u, CHAN_HELP_SET_PEACE);
else if (subcommand == "NOEXPIRE")
notice_help(s_ChanServ, u, CHAN_SERVADMIN_HELP_SET_NOEXPIRE);
+ else
+ return false;
+
return true;
}
diff --git a/src/core/ms_set.c b/src/core/ms_set.c
index 64d897187..aa8d33453 100644
--- a/src/core/ms_set.c
+++ b/src/core/ms_set.c
@@ -249,6 +249,8 @@ class CommandMSSet : public Command
else
notice_help(s_MemoServ, u, MEMO_HELP_SET_LIMIT, MSMaxMemos);
}
+ else
+ return false;
return true;
}
diff --git a/src/core/ns_help.c b/src/core/ns_help.c
index 6b335bd24..061293824 100644
--- a/src/core/ns_help.c
+++ b/src/core/ns_help.c
@@ -26,6 +26,7 @@ class CommandNSHelp : public Command
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
const char *cmd = params[0].c_str();
+
if (!stricmp(cmd, "SET LANGUAGE"))
{
int i;
diff --git a/src/core/ns_saset.c b/src/core/ns_saset.c
index 185bb592d..f4cae7c07 100644
--- a/src/core/ns_saset.c
+++ b/src/core/ns_saset.c
@@ -569,6 +569,8 @@ public:
notice_help(s_NickServ, u, NICK_HELP_SASET_AUTOOP);
else if (subcommand == "LANGUAGE")
notice_help(s_NickServ, u, NICK_HELP_SASET_LANGUAGE);
+ else
+ return false;
return true;
}
diff --git a/src/core/ns_set.c b/src/core/ns_set.c
index 9e00c0267..d99c657eb 100644
--- a/src/core/ns_set.c
+++ b/src/core/ns_set.c
@@ -463,8 +463,6 @@ class CommandNSSet : public Command
*/
if (u->nc->flags & NI_SUSPENDED)
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nc->display);
- else if (!nick_identified(u))
- notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
else if (!stricmp(cmd, "DISPLAY"))
return this->DoSetDisplay(u, params, u->nc);
else if (!stricmp(cmd, "PASSWORD"))
@@ -498,7 +496,9 @@ class CommandNSSet : public Command
bool OnHelp(User *u, const std::string &subcommand)
{
- if (subcommand == "DISPLAY")
+ if (subcommand.empty())
+ notice_help(s_NickServ, u, NICK_HELP_SET);
+ else if (subcommand == "DISPLAY")
notice_help(s_NickServ, u, NICK_HELP_SET_DISPLAY);
else if (subcommand == "PASSWORD")
notice_help(s_NickServ, u, NICK_HELP_SET_PASSWORD);
@@ -523,7 +523,7 @@ class CommandNSSet : public Command
else if (subcommand == "AUTOOP")
notice_help(s_NickServ, u, NICK_HELP_SET_AUTOOP);
else
- notice_help(s_NickServ, u, NICK_HELP_SET);
+ return false;
return true;
}
diff --git a/src/core/os_set.c b/src/core/os_set.c
index 1d4ed8523..362db0194 100644
--- a/src/core/os_set.c
+++ b/src/core/os_set.c
@@ -283,6 +283,8 @@ class CommandOSSet : public Command
notice_help(s_OperServ, u, OPER_HELP_SET_IGNORE);
else if (subcommand == "SUPERADMIN")
notice_help(s_OperServ, u, OPER_HELP_SET_SUPERADMIN);
+ else
+ return false;
return true;
}
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index fe892c0e1..f6cea75b3 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -28,7 +28,7 @@ bool sepstream::GetToken(std::string &token)
if (*n == sep || n + 1 == tokens.end())
{
last_starting_position = n + 1;
- token = std::string(lsp, n + 1 == tokens.end() ? n + 1 : ++n);
+ token = std::string(lsp, n + 1 == tokens.end() ? n + 1 : n++);
while (token.length() && token.find_last_of(sep) == token.length() - 1)
token.erase(token.end() - 1);