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 * ---------------------------------------------------
16 /* $ModDesc: Gives each oper type a 'level', cannot kill opers 'above' your level. */
20 class ModuleOperLevels : public Module
30 ModuleOperLevels(InspIRCd* Me)
35 conf = new ConfigReader(ServerInstance);
36 Implementation eventlist[] = { I_OnRehash, I_OnKill };
37 ServerInstance->Modules->Attach(eventlist, this, 2);
40 virtual ~ModuleOperLevels()
45 void Implements(char* List)
47 List[I_OnRehash] = List[I_OnKill] = 1;
50 virtual void OnRehash(User* user, const std::string ¶meter)
53 conf = new ConfigReader(ServerInstance);
56 virtual Version GetVersion()
58 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
61 virtual int OnKill(User* source, User* dest, const std::string &reason)
63 long dest_level = 0,source_level = 0;
65 // oper killing an oper?
66 if (IS_OPER(dest) && IS_OPER(source))
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(),dest->oper))
73 dest_level = conf->ReadInteger("type","level",j,true);
77 for (int k =0; k < conf->Enumerate("type"); k++)
79 std::string typen = conf->ReadValue("type","name",k);
80 if (!strcmp(typen.c_str(),source->oper))
82 source_level = conf->ReadInteger("type","level",k,true);
86 if (dest_level > source_level)
88 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());
89 dest->WriteServ("NOTICE %s :Oper %s attempted to /kill you!",dest->nick,source->nick);
90 source->WriteServ("481 %s :Permission Denied - Oper %s is a higher level than you",source->nick,dest->nick);
99 MODULE_INIT(ModuleOperLevels)