]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_timedbans.cpp
m_ssl_openssl Fix debug message
[user/henk/code/inspircd.git] / src / modules / m_timedbans.cpp
index 90e814a187d2af00c5e42e341fe16d6768593a6b..497ac2569d94ad80528656a1c4a1de345ab339d4 100644 (file)
@@ -62,12 +62,8 @@ class CommandTban : public Command
                        user->WriteNumeric(482, "%s %s :You do not have permission to set bans on this channel",
                                user->nick.c_str(), channel->name.c_str());
                        return CMD_FAILURE;
-               }
-               if (!ServerInstance->IsValidMask(parameters[2]))
-               {
-                       user->WriteServ("NOTICE "+user->nick+" :Invalid ban mask");
-                       return CMD_FAILURE;
-               }
+               }               
+
                TimedBan T;
                std::string channelname = parameters[0];
                long duration = ServerInstance->Duration(parameters[1]);
@@ -81,7 +77,15 @@ class CommandTban : public Command
                std::vector<std::string> setban;
                setban.push_back(parameters[0]);
                setban.push_back("+b");
-               setban.push_back(parameters[2]);
+               bool isextban = ((mask.size() > 2) && (mask[1] == ':'));
+               if (!isextban && !ServerInstance->IsValidMask(mask))
+                       mask.append("!*@*");
+               if ((mask.length() > 250) || (!ServerInstance->IsValidMask(mask) && !isextban))
+               {
+                       user->WriteServ("NOTICE "+user->nick+" :Invalid ban mask");
+                       return CMD_FAILURE;
+               }
+               setban.push_back(mask);
                // use CallHandler to make it so that the user sets the mode
                // themselves
                ServerInstance->Parser->CallHandler("MODE",setban,user);
@@ -95,7 +99,12 @@ found:
                T.mask = mask;
                T.expire = expire + (IS_REMOTE(user) ? 5 : 0);
                TimedBanList.push_back(T);
-               channel->WriteAllExcept(ServerInstance->FakeClient, true, '@', tmp, "NOTICE %s :%s added a timed ban on %s lasting for %ld seconds.", channel->name.c_str(), user->nick.c_str(), mask.c_str(), duration);
+
+               // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
+               ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
+               char pfxchar = (mh && mh->name == "halfop") ? '%' : '@';
+
+               channel->WriteAllExcept(ServerInstance->FakeClient, true, pfxchar, tmp, "NOTICE %s :%s added a timed ban on %s lasting for %ld seconds.", channel->name.c_str(), user->nick.c_str(), mask.c_str(), duration);
                return CMD_SUCCESS;
        }