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 NoNicks : public ModeHandler
32 NoNicks() : ModeHandler('N', 0, 0, false, MODETYPE_CHANNEL, false) { }
34 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
38 if (!channel->IsModeSet('N'))
40 channel->SetMode('N',true);
41 return MODEACTION_ALLOW;
46 if (channel->IsModeSet('N'))
48 channel->SetMode('N',false);
49 return MODEACTION_ALLOW;
53 return MODEACTION_DENY;
57 class ModuleNoNickChange : public Module
63 ModuleNoNickChange(Server* Me)
68 Srv->AddMode(nn, 'N');
71 virtual ~ModuleNoNickChange()
76 virtual Version GetVersion()
78 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
81 void Implements(char* List)
83 List[I_On005Numeric] = List[I_OnUserPreNick] = 1;
86 virtual void On005Numeric(std::string &output)
88 InsertMode(output,"N",4);
91 virtual int OnUserPreNick(userrec* user, const std::string &newnick)
93 irc::string server = user->server;
94 irc::string me = Srv->GetServerName().c_str();
97 for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++)
99 if (((ucrec*)(*i))->channel != NULL)
101 chanrec* curr = ((ucrec*)(*i))->channel;
102 if ((curr->IsModeSet('N')) && (!*user->oper))
104 // don't allow the nickchange, theyre on at least one channel with +N set
105 // and theyre not an oper
106 WriteServ(user->fd,"447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
116 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
118 class ModuleNoNickChangeFactory : public ModuleFactory
121 ModuleNoNickChangeFactory()
125 ~ModuleNoNickChangeFactory()
129 virtual Module * CreateModule(Server* Me)
131 return new ModuleNoNickChange(Me);
137 extern "C" void * init_module( void )
139 return new ModuleNoNickChangeFactory;