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 /* $ModDesc: Sets (and unsets) modes on opers when they oper up */
26 class ModuleModesOnOper : public Module
34 ModuleModesOnOper(Server* Me)
38 Conf = new ConfigReader;
41 void Implements(char* List)
43 List[I_OnPostOper] = List[I_OnRehash] = 1;
46 virtual void OnRehash(const std::string ¶meter)
49 Conf = new ConfigReader;
52 virtual ~ModuleModesOnOper()
57 virtual Version GetVersion()
59 return Version(1,0,0,1,VF_VENDOR);
62 virtual void OnPostOper(userrec* user, const std::string &opertype)
64 // whenever a user opers, go through the oper types, find their <type:modes>,
65 // and if they have one apply their modes. The mode string can contain +modes
66 // to add modes to the user or -modes to take modes from the user.
67 for (int j =0; j < Conf->Enumerate("type"); j++)
69 std::string typen = Conf->ReadValue("type","name",j);
70 if (!strcmp(typen.c_str(),user->oper))
72 std::string ThisOpersModes = Conf->ReadValue("type","modes",j);
73 char first = *(ThisOpersModes.c_str());
74 if ((first != '+') && (first != '-'))
75 ThisOpersModes = "+" + ThisOpersModes;
76 if (ThisOpersModes != "")
79 modes[0] = user->nick;
80 modes[1] = (char*)ThisOpersModes.c_str();
81 Srv->SendMode(modes,2,user);
89 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
91 class ModuleModesOnOperFactory : public ModuleFactory
94 ModuleModesOnOperFactory()
98 ~ModuleModesOnOperFactory()
102 virtual Module * CreateModule(Server* Me)
104 return new ModuleModesOnOper(Me);
110 extern "C" void * init_module( void )
112 return new ModuleModesOnOperFactory;