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"
27 /* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
29 class ModuleNoNickChange : public Module
34 ModuleNoNickChange(Server* Me)
39 Srv->AddExtendedMode('N',MT_CHANNEL,false,0,0);
42 virtual ~ModuleNoNickChange()
46 virtual Version GetVersion()
48 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
51 void Implements(char* List)
53 List[I_On005Numeric] = List[I_OnUserPreNick] = List[I_OnExtendedMode] = 1;
56 virtual void On005Numeric(std::string &output)
58 InsertMode(output,"N",4);
61 virtual int OnUserPreNick(userrec* user, std::string newnick)
63 irc::string server = user->server;
64 irc::string me = Srv->GetServerName().c_str();
67 for (unsigned int i =0; i < user->chans.size(); i++)
69 if (user->chans[i].channel != NULL)
71 chanrec* curr = user->chans[i].channel;
72 if (curr->IsCustomModeSet('N'))
76 // don't allow the nickchange, theyre on at least one channel with +N set
77 // and theyre not an oper
78 WriteServ(user->fd,"447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
88 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
90 // check if this is our mode character...
91 if ((modechar == 'N') && (type == MT_CHANNEL))
103 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
105 class ModuleNoNickChangeFactory : public ModuleFactory
108 ModuleNoNickChangeFactory()
112 ~ModuleNoNickChangeFactory()
116 virtual Module * CreateModule(Server* Me)
118 return new ModuleNoNickChange(Me);
124 extern "C" void * init_module( void )
126 return new ModuleNoNickChangeFactory;