- Srv->PartUserFromChannel(target,std::string(parameters[1]), "Remove by "+std::string(user->nick)+":"+result);
- Srv->SendTo(NULL,user,"NOTICE "+std::string(channel->name)+" : "+std::string(user->nick)+" removed "+std::string(target->nick)+ " from the channel");
- Srv->SendTo(NULL,target,"NOTICE "+std::string(target->nick)+" :*** "+std::string(user->nick)+" removed you from "+std::string(channel->name)+" with the message:"+std::string(result));
- } else {
- Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** You do not have access to remove "+std::string(target->nick)+" from the "+std::string(channel->name));
+ // no you can't just go from a std::ostringstream to a std::string, Om. -nenolod
+ // but you can do this, nenolod -brain
+
+ std::string reasonparam("No reason given");
+
+ /* If a reason is given, use it */
+ if(pcnt > 2)
+ {
+ /* Join params 2 ... pcnt - 1 (inclusive) into one */
+ irc::stringjoiner reason_join(" ", parameters, 2, pcnt - 1);
+ reasonparam = reason_join.GetJoined();
+ }
+
+ /* Build up the part reason string. */
+ reason = std::string("Removed by ") + user->nick + ": " + reasonparam;
+
+ channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s removed %s from the channel", channel->name, user->nick, target->nick);
+ target->WriteServ("NOTICE %s :*** %s removed you from %s with the message: %s", target->nick, user->nick, channel->name, reasonparam.c_str());
+
+ if (!channel->PartUser(target, reason.c_str()))
+ delete channel;
+ }
+ else
+ {
+ user->WriteServ( "NOTICE %s :*** You do not have access to /remove %s from %s", user->nick, target->nick, channel->name);
+ return CMD_FAILURE;