]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_dccallow.cpp
Fix ParamModeBase::OnUnset() not being virtual.
[user/henk/code/inspircd.git] / src / modules / m_dccallow.cpp
index 9d85f01da36a7981ce428e406f7bc1ed4da99490..eb364089a7807926a7e97732d6b5dc29b4482779 100644 (file)
 
 enum
 {
+       // From ircd-ratbox.
+       RPL_HELPSTART = 704,
+       RPL_HELPTXT = 705,
+       RPL_ENDOFHELP = 706,
+
        // InspIRCd-specific?
        RPL_DCCALLOWSTART = 990,
        RPL_DCCALLOWLIST = 991,
@@ -36,16 +41,11 @@ enum
        RPL_DCCALLOWREMOVED = 995,
        ERR_DCCALLOWINVALID = 996,
        RPL_DCCALLOWEXPIRED = 997,
-       ERR_UNKNOWNDCCALLOWCMD = 998,
-       // TODO: These numerics are conflicting and should be removed
-       // and be replaced with helpop.
-       RPL_DCCALLOWHELP = 998,
-       RPL_ENDOFDCCALLOWHELP = 999
+       ERR_UNKNOWNDCCALLOWCMD = 998
 };
 
 static const char* const helptext[] =
 {
-       "DCCALLOW [(+|-)<nick> [<time>]]|[LIST|HELP]",
        "You may allow DCCs from specific users by specifying a",
        "DCC allow for the user you want to receive DCCs from.",
        "For example, to allow the user Brain to send you inspircd.exe",
@@ -114,7 +114,7 @@ class CommandDccallow : public Command
                /* XXX we need to fix this so it can work with translation stuff (i.e. move +- into a seperate param */
        }
 
-       CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                /* syntax: DCCALLOW [+|-]<nick> (<time>) */
                if (!parameters.size())
@@ -213,9 +213,10 @@ class CommandDccallow : public Command
                                        {
                                                length = InspIRCd::Duration(default_length);
                                        }
-                                       else if (!atoi(parameters[1].c_str()))
+                                       else if (!InspIRCd::IsValidDuration(parameters[1]))
                                        {
-                                               length = 0;
+                                               user->WriteNumeric(ERR_DCCALLOWINVALID, user->nick, InspIRCd::Format("%s is not a valid DCCALLOW duration", parameters[1].c_str()));
+                                               return CMD_FAILURE;
                                        }
                                        else
                                        {
@@ -252,16 +253,17 @@ class CommandDccallow : public Command
                return CMD_FAILURE;
        }
 
-       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE
+       RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                return ROUTE_BROADCAST;
        }
 
        void DisplayHelp(User* user)
        {
+               user->WriteNumeric(RPL_HELPSTART, "*", "DCCALLOW [(+|-)<nick> [<time>]]|[LIST|HELP]");
                for (size_t i = 0; i < sizeof(helptext)/sizeof(helptext[0]); i++)
-                       user->WriteNumeric(RPL_DCCALLOWHELP, helptext[i]);
-               user->WriteNumeric(RPL_ENDOFDCCALLOWHELP, "End of DCCALLOW HELP");
+                       user->WriteNumeric(RPL_HELPTXT, "*", helptext[i]);
+               user->WriteNumeric(RPL_ENDOFHELP, "*", "End of DCCALLOW HELP");
 
                LocalUser* localuser = IS_LOCAL(user);
                if (localuser)
@@ -391,7 +393,7 @@ class ModuleDCCAllow : public Module
                                                        if (InspIRCd::Match(filename, bfl[i].filemask, ascii_case_insensitive_map))
                                                        {
                                                                /* We have a matching badfile entry, override whatever the default action is */
-                                                               if (bfl[i].action == "allow")
+                                                               if (stdalgo::string::equalsci(bfl[i].action, "allow"))
                                                                        return MOD_RES_PASSTHRU;
                                                                else
                                                                {