]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nickflood.cpp
Make irc::sockets::* parameters consistent, add irc::sockets::mask
[user/henk/code/inspircd.git] / src / modules / m_nickflood.cpp
index 4e6dca5b9ea376f3cdcaa40a0bac1eb2e864715e..a267cd4043d448031046c3cd29db7e297bad9c91 100644 (file)
@@ -17,7 +17,7 @@
 
 /** Holds settings and state associated with channel mode +F
  */
-class nickfloodsettings : public classbase
+class nickfloodsettings
 {
  public:
        int secs;
@@ -89,7 +89,7 @@ class NickFlood : public ModeHandler
 {
  public:
        SimpleExtItem<nickfloodsettings> ext;
-       NickFlood(Module* Creator) : ModeHandler(Creator, 'F', PARAM_SETONLY, MODETYPE_CHANNEL),
+       NickFlood(Module* Creator) : ModeHandler(Creator, "nickflood", 'F', PARAM_SETONLY, MODETYPE_CHANNEL),
                ext("nickflood", Creator) { }
 
        ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string &parameter)
@@ -200,7 +200,7 @@ class ModuleNickFlood : public Module
        {
                if (!ServerInstance->Modes->AddMode(&nf))
                        throw ModuleException("Could not add new modes!");
-               Extensible::Register(&nf.ext);
+               ServerInstance->Extensions.Register(&nf.ext);
                Implementation eventlist[] = { I_OnUserPreNick, I_OnUserPostNick };
                ServerInstance->Modules->Attach(eventlist, this, 2);
        }
@@ -213,11 +213,13 @@ class ModuleNickFlood : public Module
                for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
                {
                        Channel *channel = *i;
+                       ModResult res;
 
                        nickfloodsettings *f = nf.ext.get(channel);
                        if (f)
                        {
-                               if (CHANOPS_EXEMPT('F') && channel->GetPrefixValue(user) == OP_VALUE)
+                               FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,channel,"nickflood"));
+                               if (res == MOD_RES_ALLOW)
                                        continue;
 
                                if (f->islocked())
@@ -230,7 +232,7 @@ class ModuleNickFlood : public Module
                                {
                                        f->clear();
                                        f->lock();
-                                       channel->WriteChannelWithServ((char*)ServerInstance->Config->ServerName, "NOTICE %s :No nick changes are allowed for 60 seconds because there have been more than %d nick changes in %d seconds.", channel->name.c_str(), f->nicks, f->secs);
+                                       channel->WriteChannelWithServ((char*)ServerInstance->Config->ServerName.c_str(), "NOTICE %s :No nick changes are allowed for 60 seconds because there have been more than %d nick changes in %d seconds.", channel->name.c_str(), f->nicks, f->secs);
                                        return MOD_RES_DENY;
                                }
                        }
@@ -250,11 +252,13 @@ class ModuleNickFlood : public Module
                for (UCListIter i = user->chans.begin(); i != user->chans.end(); ++i)
                {
                        Channel *channel = *i;
+                       ModResult res;
 
                        nickfloodsettings *f = nf.ext.get(channel);
                        if (f)
                        {
-                               if (CHANOPS_EXEMPT('F') && channel->GetPrefixValue(user) == OP_VALUE)
+                               FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,channel,"nickflood"));
+                               if (res == MOD_RES_ALLOW)
                                        return;
                                
                                /* moved this here to avoid incrementing the counter for nick
@@ -269,7 +273,6 @@ class ModuleNickFlood : public Module
 
        ~ModuleNickFlood()
        {
-               ServerInstance->Modes->DelMode(&nf);
        }
 
        Version GetVersion()