summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/conf/helpop-full.conf.example5
-rw-r--r--docs/conf/helpop.conf.example5
-rw-r--r--src/modules/m_helpop.cpp44
3 files changed, 28 insertions, 26 deletions
diff --git a/docs/conf/helpop-full.conf.example b/docs/conf/helpop-full.conf.example
index f6ebb828b..4aac17e17 100644
--- a/docs/conf/helpop-full.conf.example
+++ b/docs/conf/helpop-full.conf.example
@@ -6,6 +6,8 @@
<alias text="HELP" replace="HELPOP $2-">
+<helpmsg missing="There is no help for the topic you searched for. Please try again.">
+
<helpop key="start" value="InspIRCd Help System
This system provides help for commands and modes.
@@ -19,9 +21,6 @@ parameter for this command.
/HELPOP SNOMASKS - To see a list of oper snotice masks
/HELPOP EXTBANS - To see a list of extended bans">
-<helpop key="nohelp" value="There is no help for the topic
-you searched for. Please try again.">
-
#####################
# User Commands #
#####################
diff --git a/docs/conf/helpop.conf.example b/docs/conf/helpop.conf.example
index 8456346d9..bf9e37835 100644
--- a/docs/conf/helpop.conf.example
+++ b/docs/conf/helpop.conf.example
@@ -11,6 +11,8 @@
<alias text="HELP" replace="HELPOP $2-">
+<helpmsg missing="There is no help for the topic you searched for. Please try again.">
+
<helpop key="start" value="InspIRCd Help System
This system provides help for commands and modes.
@@ -24,9 +26,6 @@ parameter for this command.
/HELPOP SNOMASKS - To see a list of oper snotice masks
/HELPOP EXTBANS - To see a list of extended bans">
-<helpop key="nohelp" value="There is no help for the topic
-you searched for. Please try again.">
-
<helpop key="cuser" value="User Commands
-------------
diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp
index f88298576..f913140d6 100644
--- a/src/modules/m_helpop.cpp
+++ b/src/modules/m_helpop.cpp
@@ -27,7 +27,13 @@
enum
{
// From UnrealIRCd.
- RPL_WHOISHELPOP = 310
+ RPL_WHOISHELPOP = 310,
+
+ // From ircd-ratbox.
+ ERR_HELPNOTFOUND = 524,
+ RPL_HELPSTART = 704,
+ RPL_HELPTXT = 705,
+ RPL_ENDOFHELP = 706
};
typedef std::map<std::string, std::string, irc::insensitive_swo> HelpopMap;
@@ -48,8 +54,12 @@ class Helpop : public SimpleUserModeHandler
*/
class CommandHelpop : public Command
{
+ private:
const std::string startkey;
+
public:
+ std::string nohelp;
+
CommandHelpop(Module* Creator)
: Command(Creator, "HELPOP", 0)
, startkey("start")
@@ -64,38 +74,34 @@ class CommandHelpop : public Command
if (parameter == "index")
{
/* iterate over all helpop items */
- user->WriteNumeric(290, "HELPOP topic index");
+ user->WriteNumeric(RPL_HELPSTART, parameter, "HELPOP topic index");
for (HelpopMap::const_iterator iter = helpop_map.begin(); iter != helpop_map.end(); iter++)
- user->WriteNumeric(292, InspIRCd::Format(" %s", iter->first.c_str()));
- user->WriteNumeric(292, "*** End of HELPOP topic index");
+ user->WriteNumeric(RPL_HELPTXT, parameter, InspIRCd::Format(" %s", iter->first.c_str()));
+ user->WriteNumeric(RPL_ENDOFHELP, parameter, "*** End of HELPOP topic index");
}
else
{
- user->WriteNumeric(290, InspIRCd::Format("*** HELPOP for %s", parameter.c_str()));
- user->WriteNumeric(292, " -");
-
HelpopMap::const_iterator iter = helpop_map.find(parameter);
-
if (iter == helpop_map.end())
{
- iter = helpop_map.find("nohelp");
+ user->WriteNumeric(ERR_HELPNOTFOUND, parameter, nohelp);
+ return CMD_FAILURE;
}
const std::string& value = iter->second;
- irc::sepstream stream(value, '\n');
+ irc::sepstream stream(value, '\n', true);
std::string token = "*";
+ user->WriteNumeric(RPL_HELPSTART, parameter, InspIRCd::Format("*** HELPOP for %s", parameter.c_str()));
while (stream.GetToken(token))
{
// Writing a blank line will not work with some clients
if (token.empty())
- user->WriteNumeric(292, ' ');
+ user->WriteNumeric(RPL_HELPTXT, parameter, ' ');
else
- user->WriteNumeric(292, token);
+ user->WriteNumeric(RPL_HELPTXT, parameter, token);
}
-
- user->WriteNumeric(292, " -");
- user->WriteNumeric(292, "*** End of HELPOP");
+ user->WriteNumeric(RPL_ENDOFHELP, parameter, "*** End of HELPOP");
}
return CMD_SUCCESS;
}
@@ -139,13 +145,11 @@ class ModuleHelpop : public Module, public Whois::EventListener
// error!
throw ModuleException("m_helpop: Helpop file is missing important entry 'start'. Please check the example conf.");
}
- else if (help.find("nohelp") == help.end())
- {
- // error!
- throw ModuleException("m_helpop: Helpop file is missing important entry 'nohelp'. Please check the example conf.");
- }
helpop_map.swap(help);
+
+ ConfigTag* tag = ServerInstance->Config->ConfValue("helpmsg");
+ cmd.nohelp = tag->getString("nohelp", "There is no help for the topic you searched for. Please try again.", 1);
}
void OnWhois(Whois::Context& whois) CXX11_OVERRIDE