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 * ---------------------------------------------------
22 #include "helperfuncs.h"
24 /* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
28 class ModuleNoNickChange : public Module
35 Srv->AddExtendedMode('N',MT_CHANNEL,false,0,0);
38 virtual ~ModuleNoNickChange()
43 virtual Version GetVersion()
45 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
48 virtual void On005Numeric(std::string &output)
50 std::stringstream line(output);
51 std::string temp1, temp2;
55 if (temp1.substr(0,10) == "CHANMODES=")
57 // append the chanmode to the end
58 temp1 = temp1.substr(10,temp1.length());
59 temp1 = "CHANMODES=" + temp1 + "N";
61 temp2 = temp2 + temp1 + " ";
64 output = temp2.substr(0,temp2.length()-1);
67 virtual int OnUserPreNick(userrec* user, std::string newnick)
69 if (!strcasecmp(user->server,Srv->GetServerName().c_str()))
71 for (int i =0; i != MAXCHANS; i++)
73 if (user->chans[i].channel != NULL)
75 chanrec* curr = user->chans[i].channel;
76 if (curr->IsCustomModeSet('N'))
78 if (!strchr(user->modes,'o'))
80 // don't allow the nickchange, theyre on at least one channel with +N set
81 // and theyre not an oper
82 WriteServ(user->fd,"447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
92 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
94 // check if this is our mode character...
95 if ((modechar == 'N') && (type == MT_CHANNEL))
107 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
109 class ModuleNoNickChangeFactory : public ModuleFactory
112 ModuleNoNickChangeFactory()
116 ~ModuleNoNickChangeFactory()
120 virtual Module * CreateModule()
122 return new ModuleNoNickChange;
128 extern "C" void * init_module( void )
130 return new ModuleNoNickChangeFactory;