+ /* We'll let everyone remove their level and below, eg:
+ * ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1)
+ * a ulined target will get a higher level than it's possible for a /remover to get..so they're safe.
+ * Nobody may remove people with >= protectedrank rank.
+ */
+ unsigned int ulevel = channel->GetPrefixValue(user);
+ unsigned int tlevel = channel->GetPrefixValue(target);
+ if ((!IS_LOCAL(user)) || ((ulevel > VOICE_VALUE) && (ulevel >= tlevel) && ((protectedrank == 0) || (tlevel < protectedrank))))
+ {
+ // REMOVE will be sent to the target's server and it will reply with a PART (or do nothing if it doesn't understand the command)
+ if (!IS_LOCAL(target))
+ {
+ // Send an ENCAP REMOVE with parameters being in the old <user> <chan> order which is
+ // compatible with both 2.0 and 2.2. This also turns FPART into REMOVE.
+ std::vector<std::string> p;
+ p.push_back(target->uuid);
+ p.push_back(channel->name);
+ if (parameters.size() > 2)
+ p.push_back(":" + parameters[2]);
+ ServerInstance->PI->SendEncapsulatedData(target->server->GetName(), "REMOVE", p, user);
+
+ return CMD_SUCCESS;
+ }
+
+ std::string reasonparam;
+
+ /* If a reason is given, use it */
+ if(parameters.size() > 2)
+ reasonparam = parameters[2];
+ else
+ reasonparam = "No reason given";
+
+ /* Build up the part reason string. */
+ reason = "Removed by " + user->nick + ": " + reasonparam;
+
+ channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s removed %s from the channel", channel->name.c_str(), user->nick.c_str(), target->nick.c_str());
+ target->WriteNotice("*** " + user->nick + " removed you from " + channel->name + " with the message: " + reasonparam);
+
+ channel->PartUser(target, reason);
+ }
+ else