]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_knock.cpp
Pass the ModeHandler to User::HasModePermission()
[user/henk/code/inspircd.git] / src / modules / m_knock.cpp
index 96ea66d7b0e505294a6d8557255caebd02ce2b6b..cf623c4abdd2e1c12c1d0553f9b65e8af4afb356 100644 (file)
@@ -45,30 +45,30 @@ class CommandKnock : public Command
                Channel* c = ServerInstance->FindChan(parameters[0]);
                if (!c)
                {
-                       user->WriteNumeric(401, "%s %s :No such channel",user->nick.c_str(), parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
 
                if (c->HasUser(user))
                {
-                       user->WriteNumeric(480, "%s :Can't KNOCK on %s, you are already on that channel.", user->nick.c_str(), c->name.c_str());
+                       user->WriteNumeric(ERR_KNOCKONCHAN, c->name, InspIRCd::Format("Can't KNOCK on %s, you are already on that channel.", c->name.c_str()));
                        return CMD_FAILURE;
                }
 
                if (c->IsModeSet(noknockmode))
                {
-                       user->WriteNumeric(480, "%s :Can't KNOCK on %s, +K is set.",user->nick.c_str(), c->name.c_str());
+                       user->WriteNumeric(480, InspIRCd::Format("Can't KNOCK on %s, +K is set.", c->name.c_str()));
                        return CMD_FAILURE;
                }
 
                if (!c->IsModeSet(inviteonlymode))
                {
-                       user->WriteNumeric(480, "%s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!",user->nick.c_str(), c->name.c_str());
+                       user->WriteNumeric(ERR_CHANOPEN, c->name, InspIRCd::Format("Can't KNOCK on %s, channel is not invite only so knocking is pointless!", c->name.c_str()));
                        return CMD_FAILURE;
                }
 
                if (sendnotice)
-                       c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :User %s is KNOCKing on %s (%s)", c->name.c_str(), user->nick.c_str(), c->name.c_str(), parameters[1].c_str());
+                       c->WriteNotice(InspIRCd::Format("User %s is KNOCKing on %s (%s)", user->nick.c_str(), c->name.c_str(), parameters[1].c_str()));
 
                if (sendnumeric)
                        c->WriteChannelWithServ(ServerInstance->Config->ServerName, "710 %s %s %s :is KNOCKing: %s", c->name.c_str(), c->name.c_str(), user->GetFullHost().c_str(), parameters[1].c_str());
@@ -95,25 +95,15 @@ class ModuleKnock : public Module
        {
        }
 
-       void init() CXX11_OVERRIDE
-       {
-               ServerInstance->Modules->AddService(kn);
-               ServerInstance->Modules->AddService(cmd);
-
-               OnRehash(NULL);
-       }
-
-       void OnRehash(User* user) CXX11_OVERRIDE
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
                std::string knocknotify = ServerInstance->Config->ConfValue("knock")->getString("notify");
-               irc::string notify(knocknotify.c_str());
-
-               if (notify == "numeric")
+               if (stdalgo::string::equalsci(knocknotify, "numeric"))
                {
                        cmd.sendnotice = false;
                        cmd.sendnumeric = true;
                }
-               else if (notify == "both")
+               else if (stdalgo::string::equalsci(knocknotify, "both"))
                {
                        cmd.sendnotice = true;
                        cmd.sendnumeric = true;