]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_operlevels.cpp
Add method for writing server notices.
[user/henk/code/inspircd.git] / src / modules / m_operlevels.cpp
index da506dd582e0c164cc240a68e4b24d9b483fa318..1d4302d21d41fab686d74fe07b9120433fa6c86d 100644 (file)
 class ModuleOperLevels : public Module
 {
        public:
-               ModuleOperLevels()
-               {
-                       Implementation eventlist[] = { I_OnRehash, I_OnKill };
-                       ServerInstance->Modules->Attach(eventlist, this, 2);
-               }
-
-               virtual ~ModuleOperLevels()
-               {
-               }
-
-
-               virtual void OnRehash(User* user)
+               void init()
                {
+                       ServerInstance->Modules->Attach(I_OnKill, this);
                }
 
                virtual Version GetVersion()
@@ -50,22 +40,23 @@ class ModuleOperLevels : public Module
                virtual ModResult OnKill(User* source, User* dest, const std::string &reason)
                {
                        // oper killing an oper?
-                       if (IS_OPER(dest) && IS_OPER(source))
+                       if (dest->IsOper() && source->IsOper())
                        {
-                               long dest_level = atol(dest->oper->getConfig("level").c_str());
-                               long source_level = atol(source->oper->getConfig("level").c_str());
+                               std::string level = dest->oper->getConfig("level");
+                               long dest_level = atol(level.c_str());
+                               level = source->oper->getConfig("level");
+                               long source_level = atol(level.c_str());
+
                                if (dest_level > source_level)
                                {
                                        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());
-                                       dest->WriteServ("NOTICE %s :*** Oper %s attempted to /kill you!",dest->nick.c_str(),source->nick.c_str());
+                                       dest->WriteNotice("*** Oper " + source->nick + " attempted to /kill you!");
                                        source->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Oper %s is a higher level than you",source->nick.c_str(),dest->nick.c_str());
                                        return MOD_RES_DENY;
                                }
                        }
                        return MOD_RES_PASSTHRU;
                }
-
 };
 
 MODULE_INIT(ModuleOperLevels)
-