From 0fedacd78dce0cf8727b0a68c6f4fdbfc2a14b72 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 30 Jan 2008 01:07:14 +0000 Subject: Merge in patches to fix bug #487, submitted by dz, thanks :) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8769 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_knock.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/modules/m_knock.cpp') 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; -- cgit v1.2.3