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 * ---------------------------------------------------
26 #include "configreader.h"
29 /* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
33 class NoNicks : public ModeHandler
36 NoNicks(InspIRCd* Instance) : ModeHandler(Instance, 'N', 0, 0, false, MODETYPE_CHANNEL, false) { }
38 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
42 if (!channel->IsModeSet('N'))
44 channel->SetMode('N',true);
45 return MODEACTION_ALLOW;
50 if (channel->IsModeSet('N'))
52 channel->SetMode('N',false);
53 return MODEACTION_ALLOW;
57 return MODEACTION_DENY;
61 class ModuleNoNickChange : public Module
67 ModuleNoNickChange(InspIRCd* Me)
71 nn = new NoNicks(ServerInstance);
72 ServerInstance->AddMode(nn, 'N');
75 virtual ~ModuleNoNickChange()
80 virtual Version GetVersion()
82 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
85 void Implements(char* List)
87 List[I_On005Numeric] = List[I_OnUserPreNick] = 1;
90 virtual void On005Numeric(std::string &output)
94 virtual int OnUserPreNick(userrec* user, const std::string &newnick)
96 irc::string server = user->server;
97 irc::string me = ServerInstance->Config->ServerName;
100 for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++)
102 if (((ucrec*)(*i))->channel != NULL)
104 chanrec* curr = ((ucrec*)(*i))->channel;
105 if ((curr->IsModeSet('N')) && (!*user->oper))
107 // don't allow the nickchange, theyre on at least one channel with +N set
108 // and theyre not an oper
109 user->WriteServ("447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
119 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
121 class ModuleNoNickChangeFactory : public ModuleFactory
124 ModuleNoNickChangeFactory()
128 ~ModuleNoNickChangeFactory()
132 virtual Module * CreateModule(InspIRCd* Me)
134 return new ModuleNoNickChange(Me);
140 extern "C" void * init_module( void )
142 return new ModuleNoNickChangeFactory;