]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_redirect.cpp
Framework for central regex module, and a bare-bone implementation based on InspIRCd...
[user/henk/code/inspircd.git] / src / modules / m_redirect.cpp
index 289a73dcacb2723707e3338cfc2a9889b37ef6da..3ed3a0791ce3ab134b40b3ec57dcbfaa50c0ba4c 100644 (file)
@@ -35,16 +35,16 @@ class Redirect : public ModeHandler
                /* When TS is equal, the alphabetically later one wins */
                return (their_param < our_param);
        }
-       
+
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
        {
                if (adding)
                {
                        Channel* c = NULL;
 
-                       if (!ServerInstance->IsChannel(parameter.c_str()))
+                       if (IS_LOCAL(source) && !ServerInstance->IsChannel(parameter.c_str(), ServerInstance->Config->Limits.ChanMax))
                        {
-                               source->WriteNumeric(403, "%s %s :Invalid channel name",source->nick.c_str(), parameter.c_str());
+                               source->WriteNumeric(403, "%s %s :Invalid channel name", source->nick.c_str(), parameter.c_str());
                                parameter.clear();
                                return MODEACTION_DENY;
                        }
@@ -89,36 +89,36 @@ class Redirect : public ModeHandler
                }
 
                return MODEACTION_DENY;
-               
+
        }
 };
 
 class ModuleRedirect : public Module
 {
-       
+
        Redirect* re;
-       
+
  public:
+
        ModuleRedirect(InspIRCd* Me)
                : Module(Me)
        {
-               
+
                re = new Redirect(ServerInstance);
                if (!ServerInstance->Modes->AddMode(re))
                        throw ModuleException("Could not add new modes!");
                Implementation eventlist[] = { I_OnUserPreJoin };
                ServerInstance->Modules->Attach(eventlist, this, 1);
        }
-       
+
 
        virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
        {
                if (chan)
                {
-                       if (chan->IsModeSet('L') && chan->limit)
+                       if (chan->IsModeSet('L') && chan->modes[CM_LIMIT])
                        {
-                               if (chan->GetUserCounter() >= chan->limit)
+                               if (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str()))
                                {
                                        std::string channel = chan->GetModeParameter('L');
 
@@ -145,10 +145,10 @@ class ModuleRedirect : public Module
                ServerInstance->Modes->DelMode(re);
                delete re;
        }
-       
+
        virtual Version GetVersion()
        {
-               return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
        }
 };