- /* zap it from the channel list of the user */
- if (user->chans[i]->channel == this)
- {
- if (reason)
- {
- FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason));
- this->WriteChannel(user, "PART %s :%s", this->name, reason);
- }
- else
- {
- FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, ""));
- this->WriteChannel(user, "PART :%s", this->name);
- }
- user->chans[i]->uc_modes = 0;
- user->chans[i]->channel = NULL;
- this->RemoveAllPrefixes(user);
- break;
- }
+ FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : "", silent));
+
+ if (!silent)
+ this->WriteChannel(user, "PART %s%s%s", this->name, reason ? " :" : "", reason ? reason : "");
+
+ user->chans.erase(i);
+ this->RemoveAllPrefixes(user);