-void Channel::PartUser(User *user, std::string &reason)
-{
- if (!user)
- return;
-
- Membership* memb = GetUser(user);
-
- if (memb)
- {
- CUList except_list;
- FOREACH_MOD(I_OnUserPart,OnUserPart(memb, reason, except_list));
-
- WriteAllExcept(user, false, 0, except_list, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : " :", reason.c_str());
-
- user->chans.erase(this);
- this->RemoveAllPrefixes(user);
- }
-
- this->DelUser(user);
-}
-
-void Channel::KickUser(User *src, User *user, const char* reason)
-{
- if (!src || !user || !reason)
- return;
-
- Membership* memb = GetUser(user);
- if (IS_LOCAL(src))
- {
- if (!memb)
- {
- src->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s %s :They are not on that channel",src->nick.c_str(), user->nick.c_str(), this->name.c_str());
- return;
- }
- if ((ServerInstance->ULine(user->server)) && (!ServerInstance->ULine(src->server)))
- {
- src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Only a u-line may kick a u-line from a channel.",src->nick.c_str(), this->name.c_str());
- return;
- }
-
- ModResult res;
- if (ServerInstance->ULine(src->server))
- res = MOD_RES_ALLOW;
- else
- FIRST_MOD_RESULT(OnUserPreKick, res, (src,memb,reason));
-
- if (res == MOD_RES_DENY)
- return;
-
- if (res == MOD_RES_PASSTHRU)
- {
- int them = this->GetPrefixValue(src);
- int us = this->GetPrefixValue(user);
- if ((them < HALFOP_VALUE) || (them < us))
- {
- src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator",src->nick.c_str(), this->name.c_str(), them >= HALFOP_VALUE ? "" : "half-");
- return;
- }
- }
- }
-
- if (memb)
- {
- CUList except_list;
- FOREACH_MOD(I_OnUserKick,OnUserKick(src, memb, reason, except_list));
-
- WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), user->nick.c_str(), reason);
-
- user->chans.erase(this);
- this->RemoveAllPrefixes(user);
- }
-
- this->DelUser(user);
-}
-
-void Channel::WriteChannel(User* user, const char* text, ...)
-{
- char textbuffer[MAXBUF];
- va_list argsPtr;
-
- if (!user || !text)
- return;
-
- va_start(argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
-
- this->WriteChannel(user, std::string(textbuffer));
-}
-
-void Channel::WriteChannel(User* user, const std::string &text)
-{
- char tb[MAXBUF];
-
- if (!user)
- return;
-
- snprintf(tb,MAXBUF,":%s %s", user->GetFullHost().c_str(), text.c_str());
- std::string out = tb;
-
- for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
- {
- if (IS_LOCAL(i->first))
- i->first->Write(out);
- }
-}
-
-void Channel::WriteChannelWithServ(const std::string& ServName, const char* text, ...)
-{
- char textbuffer[MAXBUF];
- va_list argsPtr;
-
- if (!text)
- return;
-
- va_start(argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
-
- this->WriteChannelWithServ(ServName, std::string(textbuffer));
-}
-
-void Channel::WriteChannelWithServ(const std::string& ServName, const std::string &text)