Enable KICK to be handled from remote servers and from services.
This commit is contained in:
parent
ec0b405d9d
commit
f92a614a35
|
@ -251,16 +251,20 @@ Channel_Part(CLIENT * Client, CLIENT * Origin, const char *Name, const char *Rea
|
||||||
} /* Channel_Part */
|
} /* Channel_Part */
|
||||||
|
|
||||||
|
|
||||||
/* Kick user from Channel */
|
/**
|
||||||
|
* Kick user from Channel
|
||||||
|
*/
|
||||||
GLOBAL void
|
GLOBAL void
|
||||||
Channel_Kick( CLIENT *Client, CLIENT *Origin, const char *Name, const char *Reason )
|
Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
|
||||||
|
const char *Reason )
|
||||||
{
|
{
|
||||||
CHANNEL *chan;
|
CHANNEL *chan;
|
||||||
|
|
||||||
assert( Client != NULL );
|
assert(Peer != NULL);
|
||||||
assert( Origin != NULL );
|
assert(Target != NULL);
|
||||||
assert( Name != NULL );
|
assert(Origin != NULL);
|
||||||
assert( Reason != NULL );
|
assert(Name != NULL);
|
||||||
|
assert(Reason != NULL);
|
||||||
|
|
||||||
/* Check that channel exists */
|
/* Check that channel exists */
|
||||||
chan = Channel_Search( Name );
|
chan = Channel_Search( Name );
|
||||||
|
@ -270,29 +274,32 @@ Channel_Kick( CLIENT *Client, CLIENT *Origin, const char *Name, const char *Reas
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that user is on the specified channel */
|
if (Client_Type(Peer) != CLIENT_SERVER &&
|
||||||
if( ! Channel_IsMemberOf( chan, Origin ))
|
Client_Type(Origin) != CLIENT_SERVICE) {
|
||||||
{
|
/* Check that user is on the specified channel */
|
||||||
IRC_WriteStrClient( Origin, ERR_NOTONCHANNEL_MSG, Client_ID( Origin ), Name );
|
if (!Channel_IsMemberOf(chan, Origin)) {
|
||||||
return;
|
IRC_WriteStrClient( Origin, ERR_NOTONCHANNEL_MSG,
|
||||||
}
|
Client_ID(Origin), Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if user has operator status */
|
/* Check if user has operator status */
|
||||||
if( ! strchr( Channel_UserModes( chan, Origin ), 'o' ))
|
if (!strchr(Channel_UserModes(chan, Origin), 'o')) {
|
||||||
{
|
IRC_WriteStrClient(Origin, ERR_CHANOPRIVSNEEDED_MSG,
|
||||||
IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Name);
|
Client_ID(Origin), Name);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that the client to be kicked is on the specified channel */
|
/* Check that the client to be kicked is on the specified channel */
|
||||||
if( ! Channel_IsMemberOf( chan, Client ))
|
if (!Channel_IsMemberOf(chan, Target)) {
|
||||||
{
|
IRC_WriteStrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
|
||||||
IRC_WriteStrClient( Origin, ERR_USERNOTINCHANNEL_MSG, Client_ID( Origin ), Client_ID( Client ), Name );
|
Client_ID(Origin), Client_ID(Target), Name );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Kick Client from channel */
|
/* Kick Client from channel */
|
||||||
Remove_Client( REMOVE_KICK, chan, Client, Origin, Reason, true);
|
Remove_Client( REMOVE_KICK, chan, Target, Origin, Reason, true);
|
||||||
} /* Channel_Kick */
|
} /* Channel_Kick */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,8 @@ GLOBAL bool Channel_Part PARAMS(( CLIENT *Client, CLIENT *Origin, const char *Na
|
||||||
|
|
||||||
GLOBAL void Channel_Quit PARAMS(( CLIENT *Client, char *Reason ));
|
GLOBAL void Channel_Quit PARAMS(( CLIENT *Client, char *Reason ));
|
||||||
|
|
||||||
GLOBAL void Channel_Kick PARAMS(( CLIENT *Client, CLIENT *Origin, const char *Name, const char *Reason ));
|
GLOBAL void Channel_Kick PARAMS((CLIENT *Peer, CLIENT *Target, CLIENT *Origin,
|
||||||
|
const char *Name, const char *Reason));
|
||||||
|
|
||||||
GLOBAL unsigned long Channel_Count PARAMS(( void ));
|
GLOBAL unsigned long Channel_Count PARAMS(( void ));
|
||||||
GLOBAL unsigned long Channel_MemberCount PARAMS(( CHANNEL *Chan ));
|
GLOBAL unsigned long Channel_MemberCount PARAMS(( CHANNEL *Chan ));
|
||||||
|
|
|
@ -34,14 +34,15 @@
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
try_kick(CLIENT* from, const char *nick, const char *channel, const char *reason)
|
try_kick(CLIENT *peer, CLIENT* from, const char *nick, const char *channel,
|
||||||
|
const char *reason)
|
||||||
{
|
{
|
||||||
CLIENT *target = Client_Search(nick);
|
CLIENT *target = Client_Search(nick);
|
||||||
|
|
||||||
if (!target)
|
if (!target)
|
||||||
return IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG, Client_ID(from), nick);
|
return IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG, Client_ID(from), nick);
|
||||||
|
|
||||||
Channel_Kick(target, from, channel, reason);
|
Channel_Kick(peer, target, from, channel, reason);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +94,8 @@ IRC_KICK(CLIENT *Client, REQUEST *Req)
|
||||||
currentChannel = Req->argv[0];
|
currentChannel = Req->argv[0];
|
||||||
if (channelCount == 1) {
|
if (channelCount == 1) {
|
||||||
while (nickCount > 0) {
|
while (nickCount > 0) {
|
||||||
if (!try_kick(from, currentNick, currentChannel, reason))
|
if (!try_kick(Client, from, currentNick,
|
||||||
|
currentChannel, reason))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (*currentNick)
|
while (*currentNick)
|
||||||
|
@ -104,7 +106,8 @@ IRC_KICK(CLIENT *Client, REQUEST *Req)
|
||||||
}
|
}
|
||||||
} else if (channelCount == nickCount) {
|
} else if (channelCount == nickCount) {
|
||||||
while (nickCount > 0) {
|
while (nickCount > 0) {
|
||||||
if (!try_kick(from, currentNick, currentChannel, reason))
|
if (!try_kick(Client, from, currentNick,
|
||||||
|
currentChannel, reason))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (*currentNick)
|
while (*currentNick)
|
||||||
|
|
Loading…
Reference in New Issue