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 * ---------------------------------------------------
23 #include "configreader.h"
26 /* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
28 class NoNicks : public ModeHandler
31 NoNicks(InspIRCd* Instance) : ModeHandler(Instance, 'N', 0, 0, false, MODETYPE_CHANNEL, false) { }
33 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
37 if (!channel->IsModeSet('N'))
39 channel->SetMode('N',true);
40 return MODEACTION_ALLOW;
45 if (channel->IsModeSet('N'))
47 channel->SetMode('N',false);
48 return MODEACTION_ALLOW;
52 return MODEACTION_DENY;
56 class ModuleNoNickChange : public Module
60 ModuleNoNickChange(InspIRCd* Me)
64 nn = new NoNicks(ServerInstance);
65 ServerInstance->AddMode(nn, 'N');
68 virtual ~ModuleNoNickChange()
70 ServerInstance->Modes->DelMode(nn);
74 virtual Version GetVersion()
76 return Version(1,0,0,1,VF_COMMON|VF_VENDOR);
79 void Implements(char* List)
81 List[I_OnUserPreNick] = 1;
84 virtual int OnUserPreNick(userrec* user, const std::string &newnick)
86 irc::string server = user->server;
87 irc::string me = ServerInstance->Config->ServerName;
90 for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++)
92 if (((ucrec*)(*i))->channel != NULL)
94 chanrec* curr = ((ucrec*)(*i))->channel;
95 if ((curr->IsModeSet('N')) && (!*user->oper))
97 // don't allow the nickchange, theyre on at least one channel with +N set
98 // and theyre not an oper
99 user->WriteServ("447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
109 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
111 class ModuleNoNickChangeFactory : public ModuleFactory
114 ModuleNoNickChangeFactory()
118 ~ModuleNoNickChangeFactory()
122 virtual Module * CreateModule(InspIRCd* Me)
124 return new ModuleNoNickChange(Me);
130 extern "C" void * init_module( void )
132 return new ModuleNoNickChangeFactory;