/** Part a user from this channel with the given reason.
* If the reason field is NULL, no reason will be sent.
* @param user The user who is parting (must be on this channel)
- * @param reason The (optional) part reason
+ * @param reason The part reason
* @return The number of users left on the channel. If this is zero
* when the method returns, you MUST delete the Channel immediately!
*/
- long PartUser(User *user, const char* reason = NULL);
+ long PartUser(User *user, std::string &reason);
/* Join a user to a channel. May be a channel that doesnt exist yet.
* @param user The user to join to the channel.
*
* XXX: bleh, string copy of reason, fixme! -- w00t
*/
-long Channel::PartUser(User *user, const char* reason)
+long Channel::PartUser(User *user, std::string &reason)
{
bool silent = false;
- std::string freason;
-
- if (reason)
- freason = reason;
- else
- freason = "";
if (!user)
return this->GetUserCounter();
UCListIter i = user->chans.find(this);
if (i != user->chans.end())
{
- FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, freason, silent));
+ FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason, silent));
if (!silent)
- this->WriteChannel(user, "PART %s%s%s", this->name.c_str(), reason ? " :" : "", reason ? reason : "");
+ this->WriteChannel(user, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : ":", reason.c_str());
user->chans.erase(i);
this->RemoveAllPrefixes(user);
if (c)
{
- const char *rreason = reason.empty() ? NULL : reason.c_str();
- if (!c->PartUser(user, rreason))
+ if (!c->PartUser(user, reason))
/* Arse, who stole our channel! :/ */
delete c;
}
}
/* XXX in the future, this may move to a static Channel method (the delete.) -- w00t */
- if (!channel->PartUser(user, reason.c_str()))
+ if (!channel->PartUser(user, reason))
delete channel;
Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), true, "", false, ServerInstance->Time());
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->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.c_str()))
+ if (!channel->PartUser(target, reason))
delete channel;
}
else
{
User* dest = ServerInstance->FindNick(parameters[0]);
Channel* channel = ServerInstance->FindChan(parameters[1]);
- std::string reason;
+ std::string reason = "";
if (dest && channel)
{
*/
if (IS_LOCAL(dest))
{
- if (!channel->PartUser(dest, reason.empty() ? NULL : reason.c_str()))
+ if (!channel->PartUser(dest, reason))
delete channel;
Channel* n = ServerInstance->FindChan(parameters[1]);
if (params.size() < 2)
return true;
+ std::string reason = "Services forced part";
+
+ if (params.size() == 3)
+ reason = params[2];
+
User* u = this->Instance->FindNick(params[0]);
Channel* c = this->Instance->FindChan(params[1]);
{
/* only part if it's local, otherwise just pass it on! */
if (IS_LOCAL(u))
- if (!c->PartUser(u, "Services forced part"))
+ if (!c->PartUser(u, reason))
delete c;
Utils->DoOneToAllButSender(prefix,"SVSPART",params,prefix);
}