summaryrefslogtreecommitdiff
path: root/src/modules/m_knock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/m_knock.cpp')
-rw-r--r--src/modules/m_knock.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 876c4f121..69c04dd9c 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -30,6 +30,7 @@ class CommandKnock : public Command
CmdResult Handle (const char** parameters, int pcnt, User *user)
{
Channel* c = ServerInstance->FindChan(parameters[0]);
+ std::string line;
if (!c)
{
@@ -37,19 +38,17 @@ class CommandKnock : public Command
return CMD_FAILURE;
}
- std::string line;
-
- if (c->IsModeSet('K'))
+ if (c->HasUser(user))
{
- user->WriteServ("480 %s :Can't KNOCK on %s, +K is set.",user->nick, c->name);
+ user->WriteServ("480 %s :Can't KNOCK on %s, you are already on that channel.", user->nick, c->name);
return CMD_FAILURE;
}
- for (int i = 1; i < pcnt - 1; i++)
+ if (c->IsModeSet('K'))
{
- line = line + std::string(parameters[i]) + " ";
+ user->WriteServ("480 %s :Can't KNOCK on %s, +K is set.",user->nick, c->name);
+ return CMD_FAILURE;
}
- line = line + std::string(parameters[pcnt-1]);
if (!c->modes[CM_INVITEONLY])
{
@@ -57,6 +56,12 @@ class CommandKnock : public Command
return CMD_FAILURE;
}
+ for (int i = 1; i < pcnt - 1; i++)
+ {
+ line = line + std::string(parameters[i]) + " ";
+ }
+ line = line + std::string(parameters[pcnt-1]);
+
c->WriteChannelWithServ((char*)ServerInstance->Config->ServerName, "NOTICE %s :User %s is KNOCKing on %s (%s)", c->name, user->nick, c->name, line.c_str());
user->WriteServ("NOTICE %s :KNOCKing on %s",user->nick,c->name);
return CMD_SUCCESS;