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()
73 virtual Version GetVersion()
75 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
78 void Implements(char* List)
80 List[I_OnUserPreNick] = 1;
83 virtual int OnUserPreNick(userrec* user, const std::string &newnick)
85 irc::string server = user->server;
86 irc::string me = ServerInstance->Config->ServerName;
89 for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++)
91 if (((ucrec*)(*i))->channel != NULL)
93 chanrec* curr = ((ucrec*)(*i))->channel;
94 if ((curr->IsModeSet('N')) && (!*user->oper))
96 // don't allow the nickchange, theyre on at least one channel with +N set
97 // and theyre not an oper
98 user->WriteServ("447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
108 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
110 class ModuleNoNickChangeFactory : public ModuleFactory
113 ModuleNoNickChangeFactory()
117 ~ModuleNoNickChangeFactory()
121 virtual Module * CreateModule(InspIRCd* Me)
123 return new ModuleNoNickChange(Me);
129 extern "C" void * init_module( void )
131 return new ModuleNoNickChangeFactory;