]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_operprefix.cpp
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / src / modules / m_operprefix.cpp
index 4c63e53d1b109153d45560eacd2924c76a0c508b..c703d4d7936abcb1df0c0467d0077aae859c5f34 100644 (file)
@@ -1,6 +1,11 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2013, 2017 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012-2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009-2010 Craig Edwards <brain@inspircd.org>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
  *
@@ -32,9 +37,8 @@ class OperPrefixMode : public PrefixMode
                OperPrefixMode(Module* Creator)
                        : PrefixMode(Creator, "operprefix", 'y', OPERPREFIX_VALUE)
                {
-                       std::string pfx = ServerInstance->Config->ConfValue("operprefix")->getString("prefix", "!");
-                       prefix = pfx.empty() ? '!' : pfx[0];
-                       levelrequired = INT_MAX;
+                       prefix = ServerInstance->Config->ConfValue("operprefix")->getString("prefix", "!", 1, 1)[0];
+                       ranktoset = ranktounset = UINT_MAX;
                }
 };
 
@@ -45,7 +49,7 @@ class HideOperWatcher : public ModeWatcher
 
  public:
        HideOperWatcher(ModuleOperPrefixMode* parent);
-       void AfterMode(User* source, User* dest, Channel* channel, const std::string &parameter, bool adding);
+       void AfterMode(User* source, User* dest, Channel* channel, const std::string &parameter, bool adding) CXX11_OVERRIDE;
 };
 
 class ModuleOperPrefixMode : public Module
@@ -72,6 +76,20 @@ class ModuleOperPrefixMode : public Module
                return MOD_RES_PASSTHRU;
        }
 
+       void OnPostJoin(Membership* memb) CXX11_OVERRIDE
+       {
+               if ((!IS_LOCAL(memb->user)) || (!memb->user->IsOper()) || (memb->user->IsModeSet(hideopermode)))
+                       return;
+
+               if (memb->HasMode(&opm))
+                       return;
+
+               // The user was force joined and OnUserPreJoin() did not run. Set the operprefix now.
+               Modes::ChangeList changelist;
+               changelist.push_add(&opm, memb->user->nick);
+               ServerInstance->Modes.Process(ServerInstance->FakeClient, memb->chan, NULL, changelist);
+       }
+
        void SetOperPrefix(User* user, bool add)
        {
                Modes::ChangeList changelist;
@@ -88,10 +106,10 @@ class ModuleOperPrefixMode : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Gives opers cmode +y which provides a staff prefix.", VF_VENDOR);
+               return Version("Adds the server operator-only y (operprefix) channel prefix mode.", VF_VENDOR);
        }
 
-       void Prioritize()
+       void Prioritize() CXX11_OVERRIDE
        {
                // m_opermodes may set +H on the oper to hide him, we don't want to set the oper prefix in that case
                Module* opermodes = ServerInstance->Modules->Find("m_opermodes.so");