1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
18 #include "configreader.h"
21 /* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
23 class NoNicks : public ModeHandler
26 NoNicks(InspIRCd* Instance) : ModeHandler(Instance, 'N', 0, 0, false, MODETYPE_CHANNEL, false) { }
28 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
32 if (!channel->IsModeSet('N'))
34 channel->SetMode('N',true);
35 return MODEACTION_ALLOW;
40 if (channel->IsModeSet('N'))
42 channel->SetMode('N',false);
43 return MODEACTION_ALLOW;
47 return MODEACTION_DENY;
51 class ModuleNoNickChange : public Module
55 ModuleNoNickChange(InspIRCd* Me)
59 nn = new NoNicks(ServerInstance);
60 ServerInstance->AddMode(nn, 'N');
63 virtual ~ModuleNoNickChange()
65 ServerInstance->Modes->DelMode(nn);
69 virtual Version GetVersion()
71 return Version(1,1,0,1,VF_COMMON|VF_VENDOR,API_VERSION);
74 void Implements(char* List)
76 List[I_OnUserPreNick] = 1;
79 virtual int OnUserPreNick(userrec* user, const std::string &newnick)
81 irc::string server = user->server;
82 irc::string me = ServerInstance->Config->ServerName;
85 for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
87 chanrec* curr = i->first;
88 if ((curr->IsModeSet('N')) && (!*user->oper))
90 // don't allow the nickchange, theyre on at least one channel with +N set
91 // and theyre not an oper
92 user->WriteServ("447 %s :Can't change nickname while on %s (+N is set)", user->nick, curr->name);
101 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
103 class ModuleNoNickChangeFactory : public ModuleFactory
106 ModuleNoNickChangeFactory()
110 ~ModuleNoNickChangeFactory()
114 virtual Module * CreateModule(InspIRCd* Me)
116 return new ModuleNoNickChange(Me);
122 extern "C" void * init_module( void )
124 return new ModuleNoNickChangeFactory;