]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_delayjoin.cpp
Include untranslated user/channel metadata in CHECK output
[user/henk/code/inspircd.git] / src / modules / m_delayjoin.cpp
index 116bdde10174286ece42d93501ef54e06bfcef89..8b5e83e88b5b6d3e82ced1e3929aec1ec0165857 100644 (file)
@@ -3,7 +3,7 @@
  *       +------------------------------------+
  *
  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *         the file COPYING for details.
@@ -20,7 +20,7 @@ class DelayJoinMode : public ModeHandler
        CUList empty;
        Module* Creator;
  public:
-       DelayJoinMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Instance, 'D', 0, 0, false, MODETYPE_CHANNEL, false), Creator(Parent) {};
+       DelayJoinMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Instance, 'D', 0, 0, false, MODETYPE_CHANNEL, false, 0, '@'), Creator(Parent) {};
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool);
 };
@@ -28,13 +28,12 @@ class DelayJoinMode : public ModeHandler
 class ModuleDelayJoin : public Module
 {
  private:
-       DelayJoinMode* djm;
+       DelayJoinMode djm;
        CUList nl;
  public:
-       ModuleDelayJoin(InspIRCd* Me) : Module(Me)
+       ModuleDelayJoin(InspIRCd* Me) : Module(Me), djm(Me, this)
        {
-               djm = new DelayJoinMode(ServerInstance, this);
-               if (!ServerInstance->Modes->AddMode(djm))
+               if (!ServerInstance->Modes->AddMode(&djm))
                        throw ModuleException("Could not add new modes!");
                Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnUserQuit, I_OnNamesListItem, I_OnText, I_OnHostCycle };
                ServerInstance->Modules->Attach(eventlist, this, 7);
@@ -42,7 +41,7 @@ class ModuleDelayJoin : public Module
        virtual ~ModuleDelayJoin();
        virtual Version GetVersion();
        virtual void OnNamesListItem(User* issuer, User* user, Channel* channel, std::string &prefixes, std::string &nick);
-       virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent);
+       virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created);
        void CleanUser(User* user);
        bool OnHostCycle(User* user);
        void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent);
@@ -56,39 +55,27 @@ class ModuleDelayJoin : public Module
 
 ModeAction DelayJoinMode::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
 {
-       if (channel->IsModeSet('D') != adding)
-       {
-               if (IS_LOCAL(source) && (channel->GetStatus(source) < STATUS_OP))
-               {
-                       source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Only channel operators may %sset channel mode +D", source->nick.c_str(), channel->name.c_str(), adding ? "" : "un");
-                       return MODEACTION_DENY;
-               }
-               else
-               {
-                       if (channel->IsModeSet('D'))
-                       {
-                               /*
-                                * Make all users visible, as +D is being removed. If we don't do this,
-                                * they remain permanently invisible on this channel!
-                                */
-                               CUList* names = channel->GetUsers();
-                               for (CUListIter n = names->begin(); n != names->end(); ++n)
-                                       Creator->OnText(n->first, channel, TYPE_CHANNEL, "", 0, empty);
-                       }
-                       channel->SetMode('D', adding);
-                       return MODEACTION_ALLOW;
-               }
-       }
-       else
-       {
+       /* no change */
+       if (channel->IsModeSet('D') == adding)
                return MODEACTION_DENY;
+
+       if (!adding)
+       {
+               /*
+                * Make all users visible, as +D is being removed. If we don't do this,
+                * they remain permanently invisible on this channel!
+                */
+               CUList* names = channel->GetUsers();
+               for (CUListIter n = names->begin(); n != names->end(); ++n)
+                       Creator->OnText(n->first, channel, TYPE_CHANNEL, "", 0, empty);
        }
+       channel->SetMode('D', adding);
+       return MODEACTION_ALLOW;
 }
 
 ModuleDelayJoin::~ModuleDelayJoin()
 {
-       ServerInstance->Modes->DelMode(djm);
-       delete djm;
+       ServerInstance->Modes->DelMode(&djm);
 }
 
 Version ModuleDelayJoin::GetVersion()
@@ -113,7 +100,7 @@ void ModuleDelayJoin::OnNamesListItem(User* issuer, User* user, Channel* channel
                nick.clear();
 }
 
-void ModuleDelayJoin::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
+void ModuleDelayJoin::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created)
 {
        if (channel->IsModeSet('D'))
        {