From 26a4a13cdff2933b77da986ccc38f3538beaaea7 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 30 Oct 2012 20:40:03 -0400 Subject: [PATCH] Made os_mode a bit smarter --- modules/commands/os_mode.cpp | 54 ++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index 2fa8e5f69..67ef1c8d4 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -34,9 +34,59 @@ class CommandOSMode : public Command source.Reply(_("Services is unable to change modes. Are your servers' U:lines configured correctly?")); else { - c->SetModes(source.service, false, modes.c_str()); + spacesepstream sep(modes); + Anope::string mode; + int add = 1; + Anope::string log_modes, log_params; - Log(LOG_ADMIN, source, this) << modes << " on " << target; + sep.GetToken(mode); + for (unsigned i = 0; i < mode.length(); ++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; + if (cm->Type != MODE_REGULAR) + { + if (!sep.GetToken(param)) + continue; + + if (cm->Type == MODE_STATUS) + { + User *targ = finduser(param); + if (targ == NULL || c->FindUser(targ) == NULL) + continue; + } + } + + log_modes += cm->ModeChar; + if (!param.empty()) + log_params += " " + param; + + 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->name; } }