1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 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 */
31 class ModuleNoNickChange : public Module
38 Srv->AddExtendedMode('N',MT_CHANNEL,false,0,0);
41 virtual ~ModuleNoNickChange()
46 virtual Version GetVersion()
48 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
51 virtual void On005Numeric(std::string &output)
53 std::stringstream line(output);
54 std::string temp1, temp2;
58 if (temp1.substr(0,10) == "CHANMODES=")
60 // append the chanmode to the end
61 temp1 = temp1.substr(10,temp1.length());
62 temp1 = "CHANMODES=" + temp1 + "N";
64 temp2 = temp2 + temp1 + " ";
67 output = temp2.substr(0,temp2.length()-1);
70 virtual int OnUserPreNick(userrec* user, std::string newnick)
72 irc::string server = user->server;
73 irc::string me = Srv->GetServerName().c_str();
76 for (int i =0; i != MAXCHANS; i++)
78 if (user->chans[i].channel != NULL)
80 chanrec* curr = user->chans[i].channel;
81 if (curr->IsCustomModeSet('N'))
83 if (!strchr(user->modes,'o'))
85 // don't allow the nickchange, theyre on at least one channel with +N set
86 // and theyre not an oper
87 WriteServ(user->fd,"447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
97 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
99 // check if this is our mode character...
100 if ((modechar == 'N') && (type == MT_CHANNEL))
112 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
114 class ModuleNoNickChangeFactory : public ModuleFactory
117 ModuleNoNickChangeFactory()
121 ~ModuleNoNickChangeFactory()
125 virtual Module * CreateModule()
127 return new ModuleNoNickChange;
133 extern "C" void * init_module( void )
135 return new ModuleNoNickChangeFactory;