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 * ---------------------------------------------------
25 /* $ModDesc: Sets (and unsets) modes on opers when they oper up */
27 class ModuleModesOnOper : public Module
35 ModuleModesOnOper(Server* Me)
39 Conf = new ConfigReader;
42 void Implements(char* List)
44 List[I_OnPostOper] = List[I_OnRehash] = 1;
47 virtual void OnRehash(const std::string ¶meter)
50 Conf = new ConfigReader;
53 virtual ~ModuleModesOnOper()
58 virtual Version GetVersion()
60 return Version(1,0,0,1,VF_VENDOR);
63 virtual void OnPostOper(userrec* user, const std::string &opertype)
65 // whenever a user opers, go through the oper types, find their <type:modes>,
66 // and if they have one apply their modes. The mode string can contain +modes
67 // to add modes to the user or -modes to take modes from the user.
68 for (int j =0; j < Conf->Enumerate("type"); j++)
70 std::string typen = Conf->ReadValue("type","name",j);
71 if (!strcmp(typen.c_str(),user->oper))
73 std::string ThisOpersModes = Conf->ReadValue("type","modes",j);
74 char first = *(ThisOpersModes.c_str());
75 if ((first != '+') && (first != '-'))
76 ThisOpersModes = "+" + ThisOpersModes;
77 if (ThisOpersModes != "")
80 modes[0] = user->nick;
81 modes[1] = ThisOpersModes.c_str();
82 Srv->SendMode(modes,2,user);
90 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
92 class ModuleModesOnOperFactory : public ModuleFactory
95 ModuleModesOnOperFactory()
99 ~ModuleModesOnOperFactory()
103 virtual Module * CreateModule(Server* Me)
105 return new ModuleModesOnOper(Me);
111 extern "C" void * init_module( void )
113 return new ModuleModesOnOperFactory;