1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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 * ---------------------------------------------------
16 /* $ModDesc: Gives each oper type a 'level', cannot kill opers 'above' your level. */
17 class ModuleOperLevels : public Module
22 ModuleOperLevels(InspIRCd* Me)
25 conf = new ConfigReader(ServerInstance);
26 Implementation eventlist[] = { I_OnRehash, I_OnKill };
27 ServerInstance->Modules->Attach(eventlist, this, 2);
30 virtual ~ModuleOperLevels()
36 virtual void OnRehash(User* user, const std::string ¶meter)
39 conf = new ConfigReader(ServerInstance);
42 virtual Version GetVersion()
44 return Version("$Id$", VF_VENDOR, API_VERSION);
47 virtual int OnKill(User* source, User* dest, const std::string &reason)
49 long dest_level = 0,source_level = 0;
51 // oper killing an oper?
52 if (IS_OPER(dest) && IS_OPER(source))
54 for (int j =0; j < conf->Enumerate("type"); j++)
56 std::string typen = conf->ReadValue("type","name",j);
57 if (typen == dest->oper)
59 dest_level = conf->ReadInteger("type","level",j,true);
63 for (int k =0; k < conf->Enumerate("type"); k++)
65 std::string typen = conf->ReadValue("type","name",k);
66 if (typen == source->oper)
68 source_level = conf->ReadInteger("type","level",k,true);
72 if (dest_level > source_level)
74 ServerInstance->SNO->WriteToSnoMask('A', "Oper %s (level %ld) attempted to /kill a higher oper: %s (level %ld): Reason: %s",source->nick.c_str(),source_level,dest->nick.c_str(),dest_level,reason.c_str());
75 dest->WriteServ("NOTICE %s :Oper %s attempted to /kill you!",dest->nick.c_str(),source->nick.c_str());
76 source->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Oper %s is a higher level than you",source->nick.c_str(),dest->nick.c_str());
85 MODULE_INIT(ModuleOperLevels)