aboutsummaryrefslogtreecommitdiffstats
path: root/irc_commands.c
diff options
context:
space:
mode:
authorjgeboski <jgeboski@gmail.com>2015-01-28 18:40:47 -0500
committerjgeboski <jgeboski@gmail.com>2015-01-29 14:24:17 -0500
commit7821ee89fef7bae353b06fc4c23f3ab23093e5cc (patch)
treef406d02909d53bd8023a3653018ce9d95e38aea6 /irc_commands.c
parent7b8238d0c9f409deaa15147bc76fc77101cb52c3 (diff)
irc_commands: implemented KICK support
With similar commands being supported, such as INVITE, the KICK command should be supported as well. The key motivation behind supporting KICK is having for having a way to remove users from group chats. As of now, there is no way for a bitlbee user to remove a user from a group chat. With no current KICK implementation, it made using this command a prime candidate for the UI side of this implementation. In addition, the KICK command has been supported in the control channel as well. This is to keep the INVITE/KICK pair consistent.
Diffstat (limited to 'irc_commands.c')
-rw-r--r--irc_commands.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/irc_commands.c b/irc_commands.c
index 6be756ff..f438193c 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -499,6 +499,30 @@ static void irc_cmd_invite( irc_t *irc, char **cmd )
irc_send_num( irc, 341, "%s %s", iu->nick, ic->name );
}
+static void irc_cmd_kick( irc_t *irc, char **cmd )
+{
+ irc_channel_t *ic;
+ irc_user_t *iu;
+
+ if( ( iu = irc_user_by_name( irc, cmd[2] ) ) == NULL )
+ {
+ irc_send_num( irc, 401, "%s :No such nick", cmd[2] );
+ return;
+ }
+ else if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL )
+ {
+ irc_send_num( irc, 403, "%s :No such channel", cmd[1] );
+ return;
+ }
+ else if( !ic->f->kick )
+ {
+ irc_send_num( irc, 482, "%s :Can't kick people here", cmd[1] );
+ return;
+ }
+
+ ic->f->kick( ic, iu, cmd[3] ? cmd[3] : NULL );
+}
+
static void irc_cmd_userhost( irc_t *irc, char **cmd )
{
int i;
@@ -745,6 +769,7 @@ static const command_t irc_commands[] = {
{ "ison", 1, irc_cmd_ison, IRC_CMD_LOGGED_IN },
{ "watch", 1, irc_cmd_watch, IRC_CMD_LOGGED_IN },
{ "invite", 2, irc_cmd_invite, IRC_CMD_LOGGED_IN },
+ { "kick", 2, irc_cmd_kick, IRC_CMD_LOGGED_IN },
{ "topic", 1, irc_cmd_topic, IRC_CMD_LOGGED_IN },
{ "oper", 2, irc_cmd_oper, IRC_CMD_LOGGED_IN },
{ "list", 0, irc_cmd_list, IRC_CMD_LOGGED_IN },