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"
28 /* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
30 class NoNicks : public ModeHandler
33 NoNicks() : ModeHandler('N', 0, 0, false, MODETYPE_CHANNEL, false) { }
35 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
39 if (!channel->IsModeSet('N'))
41 channel->SetMode('N',true);
42 return MODEACTION_ALLOW;
47 if (channel->IsModeSet('N'))
49 channel->SetMode('N',false);
50 return MODEACTION_ALLOW;
54 return MODEACTION_DENY;
58 class ModuleNoNickChange : public Module
64 ModuleNoNickChange(Server* Me)
69 Srv->AddMode(nn, 'N');
72 virtual ~ModuleNoNickChange()
77 virtual Version GetVersion()
79 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
82 void Implements(char* List)
84 List[I_On005Numeric] = List[I_OnUserPreNick] = 1;
87 virtual void On005Numeric(std::string &output)
89 InsertMode(output,"N",4);
92 virtual int OnUserPreNick(userrec* user, const std::string &newnick)
94 irc::string server = user->server;
95 irc::string me = Srv->GetServerName().c_str();
98 for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++)
100 if (((ucrec*)(*i))->channel != NULL)
102 chanrec* curr = ((ucrec*)(*i))->channel;
103 if ((curr->IsModeSet('N')) && (!*user->oper))
105 // don't allow the nickchange, theyre on at least one channel with +N set
106 // and theyre not an oper
107 user->WriteServ("447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
117 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
119 class ModuleNoNickChangeFactory : public ModuleFactory
122 ModuleNoNickChangeFactory()
126 ~ModuleNoNickChangeFactory()
130 virtual Module * CreateModule(Server* Me)
132 return new ModuleNoNickChange(Me);
138 extern "C" void * init_module( void )
140 return new ModuleNoNickChangeFactory;