]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_kicknorejoin.cpp
m_cap Convert capability names in CAP REQ to lowercase before processing them
[user/henk/code/inspircd.git] / src / modules / m_kicknorejoin.cpp
index c754aa0f09e967c6c4eff50a81d95190b4d004b3..ce95085d85c234a55b19e2ed5750b4a047f16ef4 100644 (file)
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides channel mode +J (delay rejoin after kick) */
-
 typedef std::map<std::string, time_t> delaylist;
 
 /** Handles channel mode +J
  */
 class KickRejoin : public ModeHandler
 {
+       static const unsigned int max = 60;
  public:
-       unsigned int max;
        SimpleExtItem<delaylist> ext;
        KickRejoin(Module* Creator)
                : ModeHandler(Creator, "kicknorejoin", 'J', PARAM_SETONLY, MODETYPE_CHANNEL)
@@ -42,7 +40,7 @@ class KickRejoin : public ModeHandler
        {
        }
 
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE
        {
                if (adding)
                {
@@ -56,7 +54,6 @@ class KickRejoin : public ModeHandler
                                v = max;
 
                        parameter = ConvToStr(v);
-                       channel->SetModeParam(this, parameter);
                }
                else
                {
@@ -64,7 +61,6 @@ class KickRejoin : public ModeHandler
                                return MODEACTION_DENY;
 
                        ext.unset(channel);
-                       channel->SetModeParam(this, "");
                }
                return MODEACTION_ALLOW;
        }
@@ -75,29 +71,12 @@ class ModuleKickNoRejoin : public Module
        KickRejoin kr;
 
 public:
-
        ModuleKickNoRejoin()
                : kr(this)
        {
        }
 
-       void init()
-       {
-               ServerInstance->Modules->AddService(kr);
-               ServerInstance->Modules->AddService(kr.ext);
-               Implementation eventlist[] = { I_OnUserPreJoin, I_OnUserKick, I_OnRehash };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
-               OnRehash(NULL);
-       }
-
-       void OnRehash(User* user)
-       {
-               kr.max = ServerInstance->Duration(ServerInstance->Config->ConfValue("kicknorejoin")->getString("maxtime"));
-               if (!kr.max)
-                       kr.max = 30*60;
-       }
-
-       ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
+       ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE
        {
                if (chan)
                {
@@ -111,8 +90,8 @@ public:
                                                if (iter->first == user->uuid)
                                                {
                                                        std::string modeparam = chan->GetModeParameter(&kr);
-                                                       user->WriteNumeric(ERR_DELAYREJOIN, "%s %s :You must wait %s seconds after being kicked to rejoin (+J)",
-                                                               user->nick.c_str(), chan->name.c_str(), modeparam.c_str());
+                                                       user->WriteNumeric(ERR_DELAYREJOIN, "%s :You must wait %s seconds after being kicked to rejoin (+J)",
+                                                               chan->name.c_str(), modeparam.c_str());
                                                        return MOD_RES_DENY;
                                                }
                                                ++iter;
@@ -124,14 +103,14 @@ public:
                                        }
                                }
 
-                               if (!dl->size())
+                               if (dl->empty())
                                        kr.ext.unset(chan);
                        }
                }
                return MOD_RES_PASSTHRU;
        }
 
-       void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts)
+       void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts) CXX11_OVERRIDE
        {
                if (memb->chan->IsModeSet(&kr) && (IS_LOCAL(memb->user)) && (source != memb->user))
                {
@@ -145,15 +124,10 @@ public:
                }
        }
 
-       ~ModuleKickNoRejoin()
-       {
-       }
-
-       Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Channel mode to delay rejoin after kick", VF_VENDOR);
        }
 };
 
-
 MODULE_INIT(ModuleKickNoRejoin)