]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_operprefix.cpp
m_timedbans Notice user when trying to set a ban that's already set
[user/henk/code/inspircd.git] / src / modules / m_operprefix.cpp
index b6e6b893b73481ee801cdb741fccb3f848b881a9..9f1f6cc5e8f3f25863a940abde3513d133767d46 100644 (file)
@@ -51,7 +51,7 @@ class OperPrefixMode : public ModeHandler
                                return MODEACTION_ALLOW;
                        else
                        {
-                               if (source && channel)
+                               if (channel)
                                        source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Only servers are permitted to change channel mode '%c'", source->nick.c_str(), channel->name.c_str(), 'y');
                                return MODEACTION_DENY;
                        }
@@ -85,7 +85,7 @@ class ModuleOperPrefixMode : public Module
        {
                ServerInstance->Modules->AddService(opm);
 
-               Implementation eventlist[] = { I_OnUserPreJoin, I_OnPostOper, I_OnLoadModule, I_OnUnloadModule };
+               Implementation eventlist[] = { I_OnUserPreJoin, I_OnPostOper, I_OnLoadModule, I_OnUnloadModule, I_OnPostJoin };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
 
                /* To give clients a chance to learn about the new prefix we don't give +y to opers
@@ -110,6 +110,22 @@ class ModuleOperPrefixMode : public Module
                return MOD_RES_PASSTHRU;
        }
 
+       void OnPostJoin(Membership* memb)
+       {
+               if ((!IS_LOCAL(memb->user)) || (!IS_OPER(memb->user)) || (((mw_added) && (memb->user->IsModeSet('H')))))
+                       return;
+
+               if (memb->hasMode(opm.GetModeChar()))
+                       return;
+
+               // The user was force joined and OnUserPreJoin() did not run. Set the operprefix now.
+               std::vector<std::string> modechange;
+               modechange.push_back(memb->chan->name);
+               modechange.push_back("+y");
+               modechange.push_back(memb->user->nick);
+               ServerInstance->SendGlobalMode(modechange, ServerInstance->FakeClient);
+       }
+
        void SetOperPrefix(User* user, bool add)
        {
                std::vector<std::string> modechange;
@@ -162,7 +178,8 @@ class ModuleOperPrefixMode : public Module
 
 void HideOperWatcher::AfterMode(User* source, User* dest, Channel* channel, const std::string& parameter, bool adding, ModeType type)
 {
-       if (IS_LOCAL(dest))
+       // If hideoper is being unset because the user is deopering, don't set +y
+       if (IS_LOCAL(dest) && IS_OPER(dest))
                parentmod->SetOperPrefix(dest, !adding);
 }