void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &target = params[0]; const Anope::string &modes = params[1]; Reference<Channel> c = Channel::Find(target); if (!c) source.Reply(_("Channel \002{0}\002 doesn't exist."), target); 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 && 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) { ChanUserContainer *uc = it->second; if (uc->user->HasMode("OPER")) continue; for (size_t i = uc->status.Modes().length(); i > 0; --i) c->RemoveMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i - 1]), uc->user->GetUID(), false); } source.Reply(_("All modes cleared on \002{0}\002."), c->name); } else source.Reply(_("Non-status modes cleared on \002{0}\002."), c->name); } else { spacesepstream sep(modes + (params.size() > 2 ? " " + params[2] : "")); Anope::string mode; int add = 1; Anope::string log_modes, log_params; sep.GetToken(mode); for (unsigned i = 0; i < mode.length() && c; ++i) { char ch = mode[i]; if (ch == '+') { add = 1; log_modes += "+"; continue; } else if (ch == '-') { add = 0; log_modes += "-"; continue; } ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) continue; Anope::string param, param_log; if (cm->type != MODE_REGULAR) { if (cm->type == MODE_PARAM && !add && anope_dynamic_static_cast<ChannelModeParam *>(cm)->minus_no_arg) ; else if (!sep.GetToken(param)) continue; param_log = param; if (cm->type == MODE_STATUS) { User *targ = User::Find(param, true); if (targ == NULL || c->FindUser(targ) == NULL) continue; param = targ->GetUID(); } } log_modes += cm->mchar; if (!param.empty()) log_params += " " + param_log; if (add) c->SetMode(source.service, cm, param, false); else c->RemoveMode(source.service, cm, param, false); } if (!log_modes.replace_all_cs("+", "").replace_all_cs("-", "").empty()) Log(LOG_ADMIN, source, this) << log_modes << log_params << " on " << (c ? c->name : target); } }