summaryrefslogtreecommitdiff
path: root/modules/commands/os_mode.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2015-02-05 20:16:36 -0500
committerAdam <Adam@anope.org>2015-02-05 20:16:43 -0500
commit9834518b28e3bb6ec62000c26be4e5927ca92979 (patch)
tree3da3d12ffd7ba97b105325d1c451a2f2ca8eaff9 /modules/commands/os_mode.cpp
parent64ca357b136bc190e5fec32269b34b85bf9cf610 (diff)
Fix os_mode to handle channels going away due to mode changes, and maybe cs_mode
Diffstat (limited to 'modules/commands/os_mode.cpp')
-rw-r--r--modules/commands/os_mode.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp
index 379879844..b6f26c7b3 100644
--- a/modules/commands/os_mode.cpp
+++ b/modules/commands/os_mode.cpp
@@ -26,7 +26,7 @@ class CommandOSMode : public Command
const Anope::string &target = params[0];
const Anope::string &modes = params[1];
- Channel *c = Channel::Find(target);
+ Reference<Channel> c = Channel::Find(target);
if (!c)
source.Reply(CHAN_X_NOT_IN_USE, target.c_str());
else if (c->bouncy_modes)
@@ -36,9 +36,15 @@ class CommandOSMode : public Command
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)
+ for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end && c; ++it)
c->RemoveMode(c->ci->WhoSends(), it->first, it->second, false);
+ if (!c)
+ {
+ source.Reply(_("Modes cleared on %s and the channel destroyed."), target.c_str());
+ return;
+ }
+
if (all)
{
for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
@@ -65,7 +71,7 @@ class CommandOSMode : public Command
Anope::string log_modes, log_params;
sep.GetToken(mode);
- for (unsigned i = 0; i < mode.length(); ++i)
+ for (unsigned i = 0; i < mode.length() && c; ++i)
{
char ch = mode[i];
@@ -116,7 +122,7 @@ class CommandOSMode : public Command
}
if (!log_modes.replace_all_cs("+", "").replace_all_cs("-", "").empty())
- Log(LOG_ADMIN, source, this) << log_modes << log_params << " on " << c->name;
+ Log(LOG_ADMIN, source, this) << log_modes << log_params << " on " << (c ? c->name : target);
}
}