1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
21 /* $ModDesc: Gives each oper type a 'level', cannot kill opers 'above' your level. */
25 class ModuleOperLevels : public Module
35 ModuleOperLevels(InspIRCd* Me)
40 conf = new ConfigReader(ServerInstance);
43 virtual ~ModuleOperLevels()
48 void Implements(char* List)
50 List[I_OnRehash] = List[I_OnKill] = 1;
53 virtual void OnRehash(userrec* user, const std::string ¶meter)
56 conf = new ConfigReader(ServerInstance);
59 virtual Version GetVersion()
61 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
64 virtual int OnKill(userrec* source, userrec* dest, const std::string &reason)
66 long dest_level = 0,source_level = 0;
68 // oper killing an oper?
69 if (IS_OPER(dest) && IS_OPER(source))
71 for (int j =0; j < conf->Enumerate("type"); j++)
73 std::string typen = conf->ReadValue("type","name",j);
74 if (!strcmp(typen.c_str(),dest->oper))
76 dest_level = conf->ReadInteger("type","level",j,true);
80 for (int k =0; k < conf->Enumerate("type"); k++)
82 std::string typen = conf->ReadValue("type","name",k);
83 if (!strcmp(typen.c_str(),source->oper))
85 source_level = conf->ReadInteger("type","level",k,true);
89 if (dest_level > source_level)
91 ServerInstance->WriteOpers("Oper %s (level %d) attempted to /kill a higher oper: %s (level %d): Reason: %s",source->nick,source_level,dest->nick,dest_level,reason.c_str());
92 dest->WriteServ("NOTICE %s :Oper %s attempted to /kill you!",dest->nick,source->nick);
93 source->WriteServ("481 %s :Permission Denied- Oper %s is a higher level than you",source->nick,dest->nick);
102 class ModuleOperLevelsFactory : public ModuleFactory
105 ModuleOperLevelsFactory()
109 ~ModuleOperLevelsFactory()
113 virtual Module * CreateModule(InspIRCd* Me)
115 return new ModuleOperLevels(Me);
120 extern "C" void * init_module( void )
122 return new ModuleOperLevelsFactory;