- Srv->PartUserFromChannel(target, channel->name, reason);
- WriteServ(user->fd, "NOTICE %s :%s removed %s from the channel", channel->name, user->nick, target->nick);
- WriteServ(target->fd, "NOTICE %s :*** %s removed you from %s with the message:%s", target->nick, user->nick, channel->name, reason.c_str());
+ // 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(parameters.size() > 2)
+ {
+ /* Join params 2 ... pcnt - 1 (inclusive) into one */
+ irc::stringjoiner reason_join(" ", parameters, 2, parameters.size() - 1);
+ reasonparam = reason_join.GetJoined();
+ }
+
+ /* Build up the part reason string. */
+ reason = std::string("Removed by ") + user->nick + ": " + reasonparam;
+
+ channel->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s removed %s from the channel", channel->name.c_str(), user->nick.c_str(), target->nick.c_str());
+ target->WriteServ("NOTICE %s :*** %s removed you from %s with the message: %s", target->nick.c_str(), user->nick.c_str(), channel->name.c_str(), reasonparam.c_str());
+
+ if (!channel->PartUser(target, reason))
+ delete channel;