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 ModuleNoNickChange : public Module
34 ModuleNoNickChange(Server* Me)
39 Srv->AddExtendedMode('N',MT_CHANNEL,false,0,0);
42 virtual ~ModuleNoNickChange()
46 virtual Version GetVersion()
48 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
51 void Implements(char* List)
53 List[I_On005Numeric] = List[I_OnUserPreNick] = List[I_OnExtendedMode] = 1;
56 virtual void On005Numeric(std::string &output)
58 std::stringstream line(output);
59 std::string temp1, temp2;
63 if (temp1.substr(0,10) == "CHANMODES=")
65 // append the chanmode to the end
66 temp1 = temp1.substr(10,temp1.length());
67 temp1 = "CHANMODES=" + temp1 + "N";
69 temp2 = temp2 + temp1 + " ";
72 output = temp2.substr(0,temp2.length()-1);
75 virtual int OnUserPreNick(userrec* user, std::string newnick)
77 irc::string server = user->server;
78 irc::string me = Srv->GetServerName().c_str();
81 for (unsigned int i =0; i < user->chans.size(); i++)
83 if (user->chans[i].channel != NULL)
85 chanrec* curr = user->chans[i].channel;
86 if (curr->IsCustomModeSet('N'))
88 if (!strchr(user->modes,'o'))
90 // don't allow the nickchange, theyre on at least one channel with +N set
91 // and theyre not an oper
92 WriteServ(user->fd,"447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
102 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
104 // check if this is our mode character...
105 if ((modechar == 'N') && (type == MT_CHANNEL))
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;