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 * ---------------------------------------------------
23 /* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
27 class ModuleNoNickChange : public Module
34 Srv->AddExtendedMode('N',MT_CHANNEL,false,0,0);
37 virtual ~ModuleNoNickChange()
42 virtual Version GetVersion()
44 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
47 virtual void On005Numeric(std::string &output)
49 std::stringstream line(output);
50 std::string temp1, temp2;
54 if (temp1.substr(0,10) == "CHANMODES=")
56 // append the chanmode to the end
57 temp1 = temp1.substr(10,temp1.length());
58 temp1 = "CHANMODES=" + temp1 + "N";
60 temp2 = temp2 + temp1 + " ";
63 output = temp2.substr(0,temp2.length()-1);
66 virtual int OnUserPreNick(userrec* user, std::string newnick)
68 if (!strcasecmp(user->server,Srv->GetServerName().c_str()))
70 for (int i =0; i != MAXCHANS; i++)
72 if (user->chans[i].channel != NULL)
74 chanrec* curr = user->chans[i].channel;
75 if (curr->IsCustomModeSet('N'))
77 if (!strchr(user->modes,'o'))
79 // don't allow the nickchange, theyre on at least one channel with +N set
80 // and theyre not an oper
81 WriteServ(user->fd,"447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
91 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
93 // check if this is our mode character...
94 if ((modechar == 'N') && (type == MT_CHANNEL))
106 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
108 class ModuleNoNickChangeFactory : public ModuleFactory
111 ModuleNoNickChangeFactory()
115 ~ModuleNoNickChangeFactory()
119 virtual Module * CreateModule()
121 return new ModuleNoNickChange;
127 extern "C" void * init_module( void )
129 return new ModuleNoNickChangeFactory;