1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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
24 conf = new ConfigReader;
25 Implementation eventlist[] = { I_OnRehash, I_OnKill };
26 ServerInstance->Modules->Attach(eventlist, this, 2);
29 virtual ~ModuleOperLevels()
35 virtual void OnRehash(User* user)
38 conf = new ConfigReader;
41 virtual Version GetVersion()
43 return Version("Gives each oper type a 'level', cannot kill opers 'above' your level.", VF_VENDOR, API_VERSION);
46 virtual ModResult OnKill(User* source, User* dest, const std::string &reason)
48 long dest_level = 0,source_level = 0;
50 // oper killing an oper?
51 if (IS_OPER(dest) && IS_OPER(source))
53 for (int j =0; j < conf->Enumerate("type"); j++)
55 std::string typen = conf->ReadValue("type","name",j);
56 if (typen == dest->oper)
58 dest_level = conf->ReadInteger("type","level",j,true);
62 for (int k =0; k < conf->Enumerate("type"); k++)
64 std::string typen = conf->ReadValue("type","name",k);
65 if (typen == source->oper)
67 source_level = conf->ReadInteger("type","level",k,true);
71 if (dest_level > source_level)
73 if (IS_LOCAL(source)) ServerInstance->SNO->WriteGlobalSno('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());
74 dest->WriteServ("NOTICE %s :*** Oper %s attempted to /kill you!",dest->nick.c_str(),source->nick.c_str());
75 source->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Oper %s is a higher level than you",source->nick.c_str(),dest->nick.c_str());
79 return MOD_RES_PASSTHRU;
84 MODULE_INIT(ModuleOperLevels)