]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_clearchan.cpp
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / src / modules / m_clearchan.cpp
index 27f8ec32f7584d1e322419d0c284e7b381144d5c..592559afc5470fbb320cc29276f27399f87051fe 100644 (file)
@@ -1,7 +1,9 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2017-2018 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2014, 2016 Attila Molnar <attilamolnar@hush.com>
  *
  * 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
@@ -28,14 +30,14 @@ class CommandClearChan : public Command
        CommandClearChan(Module* Creator)
                : Command(Creator, "CLEARCHAN", 1, 3)
        {
-               syntax = "<channel> [<KILL|KICK|G|Z>] [<reason>]";
+               syntax = "<channel> [KILL|KICK|G|Z] [:<reason>]";
                flags_needed = 'o';
 
                // Stop the linking mod from forwarding ENCAP'd CLEARCHAN commands, see below why
                force_manual_route = true;
        }
 
-       CmdResult Handle(const std::vector<std::string>& parameters, User* user)
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                Channel* chan = activechan = ServerInstance->FindChan(parameters[0]);
                if (!chan)
@@ -79,7 +81,7 @@ class CommandClearChan : public Command
                        // The idea is that by the time our QUITs reach the next hop, it has already removed all their
                        // clients from the channel, meaning victims on other servers won't see the victims on this
                        // server quitting.
-                       std::vector<std::string> eparams;
+                       CommandBase::Params eparams;
                        eparams.push_back(chan->name);
                        eparams.push_back(method);
                        eparams.push_back(":");
@@ -93,10 +95,11 @@ class CommandClearChan : public Command
 
                std::string mask;
                // Now remove all local non-opers from the channel
-               const UserMembList* users = chan->GetUsers();
-               for (UserMembCIter i = users->begin(); i != users->end(); )
+               Channel::MemberMap& users = chan->userlist;
+               for (Channel::MemberMap::iterator i = users.begin(); i != users.end(); )
                {
                        User* curr = i->first;
+                       const Channel::MemberMap::iterator currit = i;
                        ++i;
 
                        if (!IS_LOCAL(curr) || curr->IsOper())
@@ -105,7 +108,7 @@ class CommandClearChan : public Command
                        // If kicking users, remove them and skip the QuitUser()
                        if (kick)
                        {
-                               chan->KickUser(ServerInstance->FakeClient, curr, reason);
+                               chan->KickUser(ServerInstance->FakeClient, currit, reason);
                                continue;
                        }
 
@@ -115,10 +118,10 @@ class CommandClearChan : public Command
                                XLine* xline;
                                try
                                {
-                                       mask = ((method[0] == 'Z') ? curr->GetIPString() : "*@" + curr->host);
+                                       mask = ((method[0] == 'Z') ? curr->GetIPString() : "*@" + curr->GetRealHost());
                                        xline = xlf->Generate(ServerInstance->Time(), 60*60, user->nick, reason, mask);
                                }
-                               catch (ModuleException& ex)
+                               catch (ModuleException&)
                                {
                                        // Nothing, move on to the next user
                                        continue;
@@ -149,7 +152,7 @@ class ModuleClearChan : public Module
        {
        }
 
-       void init()
+       void init() CXX11_OVERRIDE
        {
                // Only attached while we are working; don't react to events otherwise
                ServerInstance->Modules->DetachAll(this);
@@ -169,8 +172,8 @@ class ModuleClearChan : public Module
                        }
                }
 
-               const UserMembList* users = cmd.activechan->GetUsers();
-               for (UserMembCIter i = users->begin(); i != users->end(); ++i)
+               const Channel::MemberMap& users = cmd.activechan->GetUsers();
+               for (Channel::MemberMap::const_iterator i = users.begin(); i != users.end(); ++i)
                {
                        LocalUser* curr = IS_LOCAL(i->first);
                        if (!curr)
@@ -199,8 +202,8 @@ class ModuleClearChan : public Module
        {
                // Hide the KICK from all non-opers
                User* leaving = memb->user;
-               const UserMembList* users = memb->chan->GetUsers();
-               for (UserMembCIter i = users->begin(); i != users->end(); ++i)
+               const Channel::MemberMap& users = memb->chan->GetUsers();
+               for (Channel::MemberMap::const_iterator i = users.begin(); i != users.end(); ++i)
                {
                        User* curr = i->first;
                        if ((IS_LOCAL(curr)) && (!curr->IsOper()) && (curr != leaving))
@@ -210,7 +213,7 @@ class ModuleClearChan : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Adds /CLEARCHAN that allows opers to masskick, masskill or mass-G/ZLine users on a channel", VF_VENDOR|VF_OPTCOMMON);
+               return Version("Adds the /CLEARCHAN command which allows server operators to mass-punish the members of a channel.", VF_VENDOR|VF_OPTCOMMON);
        }
 };