]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_deaf.cpp
Fix the cloaking module on C++98 compilers.
[user/henk/code/inspircd.git] / src / modules / m_deaf.cpp
index 2f7221313679fb09c2f765ade43438dd6667adf6..80e50e07e6c0fb5581780b121fde54e3d51b59ca 100644 (file)
@@ -1,10 +1,15 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2006, 2008 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
+ *   Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
+ *   Copyright (C) 2013, 2017, 2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012-2014, 2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2008, 2010 Craig Edwards <brain@inspircd.org>
  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
  *   Copyright (C) 2006-2007 Dennis Friis <peavey@inspircd.org>
- *   Copyright (C) 2012 satmd <satmd@satmd.dyndns.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -34,7 +39,7 @@ class DeafMode : public ModeHandler
                        return MODEACTION_DENY;
 
                if (adding)
-                       dest->WriteNotice("*** You have enabled usermode +d, deaf mode. This mode means you WILL NOT receive any messages from any channels you are in. If you did NOT mean to do this, use /mode " + dest->nick + " -d.");
+                       dest->WriteNotice("*** You have enabled user mode +d, deaf mode. This mode means you WILL NOT receive any messages from any channels you are in. If you did NOT mean to do this, use /mode " + dest->nick + " -d.");
 
                dest->SetMode(this, adding);
                return MODEACTION_ALLOW;
@@ -57,7 +62,7 @@ class PrivDeafMode : public ModeHandler
                        return MODEACTION_DENY;
 
                if (adding)
-                       dest->WriteNotice("*** You have enabled usermode +D, private deaf mode. This mode means you WILL NOT receive any messages and notices from any nicks. If you did NOT mean to do this, use /mode " + dest->nick + " -D.");
+                       dest->WriteNotice("*** You have enabled user mode +D, private deaf mode. This mode means you WILL NOT receive any messages and notices from any nicks. If you did NOT mean to do this, use /mode " + dest->nick + " -D.");
 
                dest->SetMode(this, adding);
                return MODEACTION_ALLOW;
@@ -89,50 +94,58 @@ class ModuleDeaf : public Module
 
        ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
        {
-               if (target.type == MessageTarget::TYPE_CHANNEL)
+               switch (target.type)
                {
-                       Channel* chan = target.Get<Channel>();
-                       bool is_bypasschar = (deaf_bypasschars.find(details.text[0]) != std::string::npos);
-                       bool is_bypasschar_uline = (deaf_bypasschars_uline.find(details.text[0]) != std::string::npos);
-
-                       // If we have no bypasschars_uline in config, and this is a bypasschar (regular)
-                       // Then it is obviously going to get through +d, no exemption list required
-                       if (deaf_bypasschars_uline.empty() && is_bypasschar)
-                               return MOD_RES_PASSTHRU;
-                       // If it matches both bypasschar and bypasschar_uline, it will get through.
-                       if (is_bypasschar && is_bypasschar_uline)
-                               return MOD_RES_PASSTHRU;
-
-                       const Channel::MemberMap& ulist = chan->GetUsers();
-                       for (Channel::MemberMap::const_iterator i = ulist.begin(); i != ulist.end(); ++i)
+                       case MessageTarget::TYPE_CHANNEL:
                        {
-                               // not +d
-                               if (!i->first->IsModeSet(deafmode))
-                                       continue;
-
-                               bool is_a_uline = i->first->server->IsULine();
-                               // matched a U-line only bypass
-                               if (is_bypasschar_uline && is_a_uline)
-                                       continue;
-                               // matched a regular bypass
-                               if (is_bypasschar && !is_a_uline)
-                                       continue;
-
-                               // don't deliver message!
-                               details.exemptions.insert(i->first);
+                               Channel* chan = target.Get<Channel>();
+                               bool is_bypasschar = (deaf_bypasschars.find(details.text[0]) != std::string::npos);
+                               bool is_bypasschar_uline = (deaf_bypasschars_uline.find(details.text[0]) != std::string::npos);
+
+                               // If we have no bypasschars_uline in config, and this is a bypasschar (regular)
+                               // Then it is obviously going to get through +d, no exemption list required
+                               if (deaf_bypasschars_uline.empty() && is_bypasschar)
+                                       return MOD_RES_PASSTHRU;
+                               // If it matches both bypasschar and bypasschar_uline, it will get through.
+                               if (is_bypasschar && is_bypasschar_uline)
+                                       return MOD_RES_PASSTHRU;
+
+                               const Channel::MemberMap& ulist = chan->GetUsers();
+                               for (Channel::MemberMap::const_iterator i = ulist.begin(); i != ulist.end(); ++i)
+                               {
+                                       // not +d
+                                       if (!i->first->IsModeSet(deafmode))
+                                               continue;
+
+                                       bool is_a_uline = i->first->server->IsULine();
+                                       // matched a U-line only bypass
+                                       if (is_bypasschar_uline && is_a_uline)
+                                               continue;
+                                       // matched a regular bypass
+                                       if (is_bypasschar && !is_a_uline)
+                                               continue;
+
+                                       // don't deliver message!
+                                       details.exemptions.insert(i->first);
+                               }
+                               break;
                        }
-               }
-               else if (target.type == MessageTarget::TYPE_USER)
-               {
-                       User* targ = target.Get<User>();
-                       if (!targ->IsModeSet(privdeafmode))
-                               return MOD_RES_PASSTHRU;
+                       case MessageTarget::TYPE_USER:
+                       {
+                               User* targ = target.Get<User>();
+                               if (!targ->IsModeSet(privdeafmode))
+                                       return MOD_RES_PASSTHRU;
 
-                       if (!privdeafuline && user->server->IsULine())
-                               return MOD_RES_DENY;
+                               if (!privdeafuline && user->server->IsULine())
+                                       return MOD_RES_DENY;
 
-                       if (!user->HasPrivPermission("users/privdeaf-override"))
-                               return MOD_RES_DENY;
+                               if (!user->HasPrivPermission("users/ignore-privdeaf"))
+                                       return MOD_RES_DENY;
+
+                               break;
+                       }
+                       case MessageTarget::TYPE_SERVER:
+                               break;
                }
 
                return MOD_RES_PASSTHRU;
@@ -140,7 +153,7 @@ class ModuleDeaf : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides usermodes +dD to block channel and/or user messages and notices", VF_VENDOR);
+               return Version("Adds user mode d (deaf) which prevents users from receiving channel messages.", VF_VENDOR);
        }
 };