]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_kicknorejoin.cpp
Add <showwhois:opersonly>, allows server admins to unlock umode +W use for regular...
[user/henk/code/inspircd.git] / src / modules / m_kicknorejoin.cpp
index 8d4386dd1bdd61f55303cb52bdefa4ebcf230b8c..bf5e10595c38b2c2925c8f71520f1adf81d9d800 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -38,27 +38,27 @@ class KickRejoin : public ModeHandler
                        return std::make_pair(true, channel->GetModeParameter('J'));
                else
                        return std::make_pair(false, parameter);
-       } 
+       }
 
        bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel)
        {
                /* 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)
+
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
        {
                if (!adding)
                {
                        // Taking the mode off, we need to clean up.
                        delaylist* dl;
-                       
+
                        if (channel->GetExt("norejoinusers", dl))
                        {
                                delete dl;
                                channel->Shrink("norejoinusers");
                        }
-                       
+
                        if (!channel->IsModeSet('J'))
                        {
                                return MODEACTION_DENY;
@@ -114,23 +114,23 @@ class KickRejoin : public ModeHandler
 
 class ModuleKickNoRejoin : public Module
 {
-       
+
        KickRejoin* kr;
-       
+
 public:
+
        ModuleKickNoRejoin(InspIRCd* Me)
                : Module(Me)
        {
-               
+
                kr = new KickRejoin(ServerInstance);
-               if (!ServerInstance->AddMode(kr))
+               if (!ServerInstance->Modes->AddMode(kr))
                        throw ModuleException("Could not add new modes!");
                Implementation eventlist[] = { I_OnCleanup, I_OnChannelDelete, I_OnUserPreJoin, I_OnUserKick };
                ServerInstance->Modules->Attach(eventlist, this, 4);
        }
 
-       virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs)
+       virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
        {
                if (chan)
                {
@@ -138,14 +138,14 @@ public:
                        if (chan->GetExt("norejoinusers", dl))
                        {
                                std::vector<User*> itemstoremove;
-                       
+
                                for (delaylist::iterator iter = dl->begin(); iter != dl->end(); iter++)
                                {
-                                       if (iter->second > time(NULL))
+                                       if (iter->second > ServerInstance->Time())
                                        {
-                                               if (iter->first == user)                                        
+                                               if (iter->first == user)
                                                {
-                                                       user->WriteServ( "495 %s %s :You cannot rejoin this channel yet after being kicked (+J)", user->nick, chan->name);
+                                                       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(), chan->GetModeParameter('J').c_str());
                                                        return 1;
                                                }
                                        }
@@ -155,10 +155,10 @@ public:
                                                itemstoremove.push_back(iter->first);
                                        }
                                }
-                               
+
                                for (unsigned int i = 0; i < itemstoremove.size(); i++)
                                        dl->erase(itemstoremove[i]);
-                                                                                                                                       
+
                                if (!dl->size())
                                {
                                        // Now it's empty..
@@ -169,7 +169,7 @@ public:
                }
                return 0;
        }
-               
+
        virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent)
        {
                if (chan->IsModeSet('J') && (source != user))
@@ -180,21 +180,21 @@ public:
                                dl = new delaylist;
                                chan->Extend("norejoinusers", dl);
                        }
-                       (*dl)[user] = time(NULL) + strtoint(chan->GetModeParameter('J'));
+                       (*dl)[user] = ServerInstance->Time() + strtoint(chan->GetModeParameter('J'));
                }
        }
-       
+
        virtual void OnChannelDelete(Channel* chan)
        {
                delaylist* dl;
-                       
+
                if (chan->GetExt("norejoinusers", dl))
                {
                        delete dl;
                        chan->Shrink("norejoinusers");
                }
        }
-       
+
        virtual void OnCleanup(int target_type, void* item)
        {
                if(target_type == TYPE_CHANNEL)
@@ -207,10 +207,10 @@ public:
                ServerInstance->Modes->DelMode(kr);
                delete kr;
        }
-       
+
        virtual Version GetVersion()
        {
-               return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
        }
 };