1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 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 * ---------------------------------------------------
23 /* $ModDesc: Provides support for /KNOCK and mode +K */
27 void handle_knock(char **parameters, int pcnt, userrec *user)
29 chanrec* c = Srv->FindChannel(parameters[0]);
30 std::string line = "";
32 for (int i = 1; i < pcnt - 1; i++)
34 line = line + std::string(parameters[i]) + " ";
36 line = line + std::string(parameters[pcnt-1]);
38 if (c->IsCustomModeSet('K'))
40 WriteServ(user->fd,"480 %s :Can't KNOCK on %s, +K is set.",user->nick, c->name);
45 WriteChannelWithServ((char*)Srv->GetServerName().c_str(),c,user,"NOTICE %s :User %s is KNOCKing on %s (%s)",c->name,user->nick,c->name,line.c_str());
46 WriteServ(user->fd,"NOTICE %s :KNOCKing on %s",user->nick,c->name);
51 WriteServ(user->fd,"480 %s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!",user->nick, c->name);
57 class ModuleKnock : public Module
64 Srv->AddExtendedMode('K',MT_CHANNEL,false,0,0);
65 Srv->AddCommand("KNOCK",handle_knock,0,2);
68 virtual ~ModuleKnock()
73 virtual Version GetVersion()
75 return Version(1,0,0,1);
78 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
80 // check if this is our mode character...
81 if ((modechar == 'K') && (type == MT_CHANNEL))
93 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
95 class ModuleKnockFactory : public ModuleFactory
102 ~ModuleKnockFactory()
106 virtual Module * CreateModule()
108 return new ModuleKnock;
114 extern "C" void * init_module( void )
116 return new ModuleKnockFactory;