Changeset 7821ee8


Ignore:
Timestamp:
2015-01-29T19:24:17Z (6 years ago)
Author:
jgeboski <jgeboski@…>
Branches:
master
Children:
e41cc40
Parents:
7b8238d
git-author:
jgeboski <jgeboski@…> (28-01-15 23:40:47)
git-committer:
jgeboski <jgeboski@…> (29-01-15 19:24:17)
Message:

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.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • irc.h

    r7b8238d r7821ee8  
    188188        gboolean (*topic)( irc_channel_t *ic, const char *new_topic );
    189189        gboolean (*invite)( irc_channel_t *ic, irc_user_t *iu );
     190        void (*kick)( irc_channel_t *ic, irc_user_t *iu, const char *msg );
    190191       
    191192        gboolean (*_init)( irc_channel_t *ic );
  • irc_channel.c

    r7b8238d r7821ee8  
    626626}
    627627
     628static void control_channel_kick( irc_channel_t *ic, irc_user_t *iu, const char *msg )
     629{
     630        struct irc_control_channel *icc = ic->data;
     631        bee_user_t *bu = iu->bu;
     632       
     633        if( bu == NULL )
     634                return;
     635       
     636        if( icc->type != IRC_CC_TYPE_GROUP )
     637        {
     638                irc_send_num( ic->irc, 482, "%s :Kicks are only possible to fill_by=group channels", ic->name );
     639                return;
     640        }
     641       
     642        bu->ic->acc->prpl->remove_buddy( bu->ic, bu->handle,
     643                                         icc->group ? icc->group->name : NULL );
     644}
     645
    628646static char *set_eval_by_account( set_t *set, char *value );
    629647static char *set_eval_fill_by( set_t *set, char *value );
     
    844862        NULL,
    845863        control_channel_invite,
     864        control_channel_kick,
    846865       
    847866        control_channel_init,
  • irc_commands.c

    r7b8238d r7821ee8  
    498498        else if( ic->f->invite( ic, iu ) )
    499499                irc_send_num( irc, 341, "%s %s", iu->nick, ic->name );
     500}
     501
     502static void irc_cmd_kick( irc_t *irc, char **cmd )
     503{
     504        irc_channel_t *ic;
     505        irc_user_t *iu;
     506       
     507        if( ( iu = irc_user_by_name( irc, cmd[2] ) ) == NULL )
     508        {
     509                irc_send_num( irc, 401, "%s :No such nick", cmd[2] );
     510                return;
     511        }
     512        else if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL )
     513        {
     514                irc_send_num( irc, 403, "%s :No such channel", cmd[1] );
     515                return;
     516        }
     517        else if( !ic->f->kick )
     518        {
     519                irc_send_num( irc, 482, "%s :Can't kick people here", cmd[1] );
     520                return;
     521        }
     522       
     523        ic->f->kick( ic, iu, cmd[3] ? cmd[3] : NULL );
    500524}
    501525
     
    746770        { "watch",       1, irc_cmd_watch,       IRC_CMD_LOGGED_IN },
    747771        { "invite",      2, irc_cmd_invite,      IRC_CMD_LOGGED_IN },
     772        { "kick",        2, irc_cmd_kick,        IRC_CMD_LOGGED_IN },
    748773        { "topic",       1, irc_cmd_topic,       IRC_CMD_LOGGED_IN },
    749774        { "oper",        2, irc_cmd_oper,        IRC_CMD_LOGGED_IN },
  • irc_im.c

    r7b8238d r7821ee8  
    972972}
    973973
     974static void bee_irc_channel_chat_kick( irc_channel_t *ic, irc_user_t *iu, const char *msg )
     975{
     976        struct groupchat *c = ic->data;
     977        bee_user_t *bu = iu->bu;
     978       
     979        if( ( c == NULL ) || ( bu == NULL ) )
     980                return;
     981       
     982        if( !c->ic->acc->prpl->chat_kick )
     983        {
     984                irc_send_num( ic->irc, 482, "%s :IM protocol does not support room kicking", ic->name );
     985                return;
     986        }
     987       
     988        c->ic->acc->prpl->chat_kick( c, iu->bu->handle, msg );
     989}
     990
    974991static char *set_eval_room_account( set_t *set, char *value );
    975992static char *set_eval_chat_type( set_t *set, char *value );
     
    10561073        bee_irc_channel_chat_topic,
    10571074        bee_irc_channel_chat_invite,
     1075        bee_irc_channel_chat_kick,
    10581076
    10591077        bee_irc_channel_init,
  • protocols/nogaim.h

    r7b8238d r7821ee8  
    213213         */
    214214        void (* chat_invite)    (struct groupchat *, char *who, char *message);
     215        /* This is called when the user uses the /kick IRC command.
     216         * - 'who' is a handle to kick
     217         * - 'message' is a kick message or NULL
     218         */
     219        void (* chat_kick)      (struct groupchat *, char *who, const char *message);
    215220        /* This is called when the user uses the /part IRC command in a group
    216221         * chat. You just should tell the user about it, nothing more. */
Note: See TracChangeset for help on using the changeset viewer.