]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_banredirect.cpp
m_spanningtree Remove duplicate code for sending channel messages from RouteCommand()
[user/henk/code/inspircd.git] / src / modules / m_banredirect.cpp
index 20b3a62e256a1a580a5f765a7483c41c427d515d..73d8270d1b098452caa55dc9fc1c886bba7825bd 100644 (file)
@@ -25,8 +25,6 @@
 #include "inspircd.h"
 #include "listmode.h"
 
-/* $ModDesc: Allows an extended ban (+b) syntax redirecting banned users to another channel */
-
 /* Originally written by Om, January 2009
  */
 
@@ -46,7 +44,7 @@ typedef std::vector<BanRedirectEntry> BanRedirectList;
 
 class BanRedirect : public ModeWatcher
 {
-       ModeReference ban;
+       ChanModeReference ban;
  public:
        SimpleExtItem<BanRedirectList> extItem;
        BanRedirect(Module* parent)
@@ -219,21 +217,22 @@ class ModuleBanRedirect : public Module
 {
        BanRedirect re;
        bool nofollow;
+       ChanModeReference limitmode;
+       ChanModeReference redirectmode;
 
  public:
        ModuleBanRedirect()
-       : re(this)
+               : re(this)
+               , nofollow(false)
+               , limitmode(this, "limit")
+               , redirectmode(this, "redirect")
        {
-               nofollow = false;
        }
 
-
        void init() CXX11_OVERRIDE
        {
                ServerInstance->Modes->AddModeWatcher(&re);
                ServerInstance->Modules->AddService(re.extItem);
-               Implementation list[] = { I_OnUserPreJoin };
-               ServerInstance->Modules->Attach(list, this, sizeof(list)/sizeof(Implementation));
        }
 
        void OnCleanup(int target_type, void* item) CXX11_OVERRIDE
@@ -313,9 +312,9 @@ class ModuleBanRedirect : public Module
                                                std::string destlimit;
 
                                                if (destchan)
-                                                       destlimit = destchan->GetModeParameter('l');
+                                                       destlimit = destchan->GetModeParameter(limitmode);
 
-                                               if(destchan && ServerInstance->Modules->Find("m_redirect.so") && destchan->IsModeSet('L') && !destlimit.empty() && (destchan->GetUserCounter() >= atoi(destlimit.c_str())))
+                                               if(destchan && destchan->IsModeSet(redirectmode) && !destlimit.empty() && (destchan->GetUserCounter() >= atoi(destlimit.c_str())))
                                                {
                                                        user->WriteNumeric(474, "%s %s :Cannot join channel (You are banned)", user->nick.c_str(), chan->name.c_str());
                                                        return MOD_RES_DENY;
@@ -340,7 +339,7 @@ class ModuleBanRedirect : public Module
        {
                /* XXX is this the best place to do this? */
                if (!ServerInstance->Modes->DelModeWatcher(&re))
-                       ServerInstance->Logs->Log("m_banredirect.so", LOG_DEBUG, "Failed to delete modewatcher!");
+                       ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Failed to delete modewatcher!");
        }
 
        Version GetVersion() CXX11_OVERRIDE