]> jfr.im git - irc/evilnet/znc.git/commitdiff
autovoice: Check for autovoices when we are opped.
authorKindOne <redacted>
Thu, 17 Sep 2015 12:55:27 +0000 (08:55 -0400)
committerJ-P Nurmi <redacted>
Thu, 17 Sep 2015 21:17:00 +0000 (23:17 +0200)
Fixes #120

modules/autovoice.cpp

index ec21d1fba83a08eed7f373e12cad67d48c026b36..9027a2f71db350e52f1f7bc2c4248e7c25c74319 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <znc/IRCNetwork.h>
 #include <znc/Modules.h>
 #include <znc/Chan.h>
 
@@ -172,6 +173,28 @@ public:
                }
        }
 
+       void OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange) override {
+               if (Nick.NickEquals(GetNetwork()->GetNick())) {
+                       const map<CString,CNick>& msNicks = Channel.GetNicks();
+
+                       for (const auto& it : msNicks) {
+                               if (!it.second.HasPerm(CChan::Voice)) {
+                                       CheckAutoVoice(it.second, Channel);
+                               }
+                       }
+               }
+       }
+
+       bool CheckAutoVoice(const CNick& Nick, CChan& Channel) {
+               CAutoVoiceUser *pUser = FindUserByHost(Nick.GetHostMask(), Channel.GetName());
+               if (!pUser) {
+                       return false;
+               }
+
+               PutIRC("MODE " + Channel.GetName() + " +v " + Nick.GetNick());
+               return true;
+       }
+
        void OnAddUserCommand(const CString& sLine) {
                CString sUser = sLine.Token(1);
                CString sHost = sLine.Token(2);