1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
24 #include "helperfuncs.h"
26 /* $ModDesc: Provides support for /KNOCK and mode +K */
30 class cmd_knock : public command_t
33 cmd_knock () : command_t("KNOCK", 0, 2)
35 this->source = "m_knock.so";
38 void Handle (char **parameters, int pcnt, userrec *user)
40 chanrec* c = Srv->FindChannel(parameters[0]);
44 WriteServ(user->fd,"401 %s %s :No such channel",user->nick, parameters[0]);
48 std::string line = "";
50 if (c->IsModeSet('K'))
52 WriteServ(user->fd,"480 %s :Can't KNOCK on %s, +K is set.",user->nick, c->name);
56 for (int i = 1; i < pcnt - 1; i++)
58 line = line + std::string(parameters[i]) + " ";
60 line = line + std::string(parameters[pcnt-1]);
62 if (c->modes[CM_INVITEONLY])
64 WriteChannelWithServ((char*)Srv->GetServerName().c_str(),c,"NOTICE %s :User %s is KNOCKing on %s (%s)",c->name,user->nick,c->name,line.c_str());
65 WriteServ(user->fd,"NOTICE %s :KNOCKing on %s",user->nick,c->name);
70 WriteServ(user->fd,"480 %s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!",user->nick, c->name);
76 class ModuleKnock : public Module
80 ModuleKnock(Server* Me)
84 Srv->AddExtendedMode('K',MT_CHANNEL,false,0,0);
85 mycommand = new cmd_knock();
86 Srv->AddCommand(mycommand);
89 void Implements(char* List)
91 List[I_On005Numeric] = List[I_OnExtendedMode] = 1;
94 virtual void On005Numeric(std::string &output)
96 InsertMode(output,"K",4);
99 virtual ~ModuleKnock()
103 virtual Version GetVersion()
105 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
108 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
110 // check if this is our mode character...
111 if ((modechar == 'K') && (type == MT_CHANNEL))
123 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
125 class ModuleKnockFactory : public ModuleFactory
132 ~ModuleKnockFactory()
136 virtual Module * CreateModule(Server* Me)
138 return new ModuleKnock(Me);
144 extern "C" void * init_module( void )
146 return new ModuleKnockFactory;