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 * ---------------------------------------------------
19 // Hostname ModesOnOper (+x mode) module for inspircd.
20 // version 1.0.0.1 by brain (C. J. Edwards) Mar 2004.
22 // When loaded this module will automatically set the
23 // +x mode on all connecting clients.
25 // Setting +x on a client causes the module to change the
26 // dhost entry (displayed host) for each user who has the
27 // mode, ModesOnOper their host. Unlike unreal, the algorithm
28 // is non-reversible as uncloaked hosts are passed along
29 // the server->server link, and all encoding of hosts is
30 // done locally on the server by this module.
37 /* $ModDesc: Sets (and unsets) modes on opers when they oper up */
39 class ModuleModesOnOper : public Module
50 Conf = new ConfigReader;
53 virtual ~ModuleModesOnOper()
59 virtual Version GetVersion()
61 return Version(1,0,0,1,VF_VENDOR);
64 virtual void OnOper(userrec* user)
66 // whenever a user opers, go through the oper types, find their <type:modes>,
67 // and if they have one apply their modes. The mode string can contain +modes
68 // to add modes to the user or -modes to take modes from the user.
69 for (int j =0; j < Conf->Enumerate("type"); j++)
71 std::string typen = Conf->ReadValue("type","name",j);
72 if (!strcmp(typen.c_str(),user->oper))
74 std::string ThisOpersModes = Conf->ReadValue("type","modes",j);
75 if (ThisOpersModes != "")
78 modes[0] = user->nick;
79 modes[1] = (char*)ThisOpersModes.c_str();
80 Srv->SendMode(modes,2,user);
88 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
90 class ModuleModesOnOperFactory : public ModuleFactory
93 ModuleModesOnOperFactory()
97 ~ModuleModesOnOperFactory()
101 virtual Module * CreateModule()
103 return new ModuleModesOnOper;
109 extern "C" void * init_module( void )
111 return new ModuleModesOnOperFactory;