- ModResult res;
- FIRST_MOD_RESULT(ServerInstance, OnChannelPreDelete, res, (this));
- if (res == MOD_RES_DENY)
- return 1; // delete halted by module
- FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
- ServerInstance->chanlist->erase(iter);
- }
- return 0;
- }
-
- return this->GetUserCounter();
-}
-
-long Channel::ServerKickUser(User* user, const char* reason, const char* servername)
-{
- if (servername == NULL || *ServerInstance->Config->HideWhoisServer)
- servername = ServerInstance->Config->ServerName;
-
- ServerInstance->FakeClient->server = servername;
- return this->KickUser(ServerInstance->FakeClient, user, reason);
-}
-
-long Channel::KickUser(User *src, User *user, const char* reason)
-{
- bool silent = false;
-
- if (!src || !user || !reason)
- return this->GetUserCounter();
-
- if (IS_LOCAL(src))
- {
- if (!this->HasUser(user))
- {
- 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 this->GetUserCounter();
- }
- 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 this->GetUserCounter();
- }
-
- ModResult res;
- if (ServerInstance->ULine(src->server))
- res = MOD_RES_ALLOW;
- if (res == MOD_RES_PASSTHRU)
- FIRST_MOD_RESULT(ServerInstance, OnUserPreKick, res, (src,user,this,reason));
- if (res == MOD_RES_PASSTHRU)
- FIRST_MOD_RESULT(ServerInstance, OnAccessCheck, res, (src,user,this,AC_KICK));
-
- if (res == MOD_RES_DENY)
- return this->GetUserCounter();
-
- 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 this->GetUserCounter();
- }
- }
- }
-
- FOREACH_MOD(I_OnUserKick,OnUserKick(src, user, this, reason, silent));
-
- UCListIter i = user->chans.find(this);
- if (i != user->chans.end())
- {
- /* zap it from the channel list of the user */
- if (!silent)
- this->WriteChannel(src, "KICK %s %s :%s", this->name.c_str(), user->nick.c_str(), reason);
-
- user->chans.erase(i);
- this->RemoveAllPrefixes(user);
- }
-
- if (!this->DelUser(user))
- /* if there are no users left on the channel */
- {
- chan_hash::iterator iter = ServerInstance->chanlist->find(this->name.c_str());