summaryrefslogtreecommitdiff
path: root/modules/commands/os_mode.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-02-19 03:58:54 -0500
committerAdam <Adam@anope.org>2013-02-19 04:07:53 -0500
commit32592987c8f5c2edf347d2312b426ed5c3170e6f (patch)
tree5ed5ca949219b27b997ea6035d2d0b0d6519a5f4 /modules/commands/os_mode.cpp
parenta1f92638e3c34266c65779df5e353931c0fa1d9d (diff)
Allow /os mode clear [all] to unset modes, similar to old clearmodes
Diffstat (limited to 'modules/commands/os_mode.cpp')
-rw-r--r--modules/commands/os_mode.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp
index cc779bed2..d20c88d4e 100644
--- a/modules/commands/os_mode.cpp
+++ b/modules/commands/os_mode.cpp
@@ -16,10 +16,11 @@
class CommandOSMode : public Command
{
public:
- CommandOSMode(Module *creator) : Command(creator, "operserv/mode", 2, 2)
+ CommandOSMode(Module *creator) : Command(creator, "operserv/mode", 2, 3)
{
this->SetDesc(_("Change channel modes"));
this->SetSyntax(_("\037channel\037 \037modes\037"));
+ this->SetSyntax(_("\037channel\037 CLEAR [ALL]"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
@@ -32,6 +33,32 @@ class CommandOSMode : public Command
source.Reply(CHAN_X_NOT_IN_USE, target.c_str());
else if (c->bouncy_modes)
source.Reply(_("Services is unable to change modes. Are your servers' U:lines configured correctly?"));
+ else if (modes.equals_ci("CLEAR"))
+ {
+ bool all = params.size() > 2 && params[2].equals_ci("ALL");
+
+ const Channel::ModeList chmodes = c->GetModes();
+ for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end; ++it)
+ c->RemoveMode(c->ci->WhoSends(), it->first, it->second, false);
+
+ if (all)
+ {
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ {
+ ChanUserContainer *uc = *it;
+
+ if (uc->user->HasMode("OPER"))
+ continue;
+
+ for (std::set<Anope::string>::iterator it2 = uc->status.modes.begin(), it2_end = uc->status.modes.end(); it2 != it2_end; ++it2)
+ c->RemoveMode(c->ci->WhoSends(), *it2, uc->user->GetUID(), false);
+ }
+
+ source.Reply(_("All modes cleared on %s."), c->name.c_str());
+ }
+ else
+ source.Reply(_("Non-status modes cleared on %s."), c->name.c_str());
+ }
else
{
spacesepstream sep(modes);
@@ -98,7 +125,9 @@ class CommandOSMode : public Command
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Allows Services Operators to change modes for any channel.\n"
- "Parameters are the same as for the standard /MODE command."));
+ "Parameters are the same as for the standard /MODE command.\n"
+ "Alternatively, CLEAR may be given to clear all modes on the channel.\n"
+ "If CLEAR ALL is given then all modes, including user status, is removed.\n"));
return true;
}
};