diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-17 16:25:52 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-17 16:43:58 +0200 |
commit | f2ab9f393779830ae45e1c66ef2d136879fa5ac6 (patch) | |
tree | 4a5b54222d01859b672c1ceea6b5dbc835bb12a8 | |
parent | 02160c897a37cfd33cf7151b32f79f8192339663 (diff) | |
download | xK-f2ab9f393779830ae45e1c66ef2d136879fa5ac6.tar.gz xK-f2ab9f393779830ae45e1c66ef2d136879fa5ac6.tar.xz xK-f2ab9f393779830ae45e1c66ef2d136879fa5ac6.zip |
degesch: implement /cycle
-rw-r--r-- | degesch.c | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -5227,6 +5227,41 @@ handle_command_part (struct app_context *ctx, char *arguments) } static bool +handle_command_cycle (struct app_context *ctx, char *arguments) +{ + if (!server_command_check (ctx, "cycle", true)) + return true; + + struct server *s = ctx->current_buffer->server; + if (*arguments) + { + // TODO: check if the arguments are in the form of "channel(,channel)*" + char *channels = cut_word (&arguments); + if (*arguments) + irc_send (s, "PART %s :%s", channels, arguments); + else + irc_send (s, "PART %s", channels); + // TODO: send the key if known + irc_send (s, "JOIN %s", channels); + } + else if (ctx->current_buffer->type != BUFFER_CHANNEL) + buffer_send_error (ctx, ctx->current_buffer, + "%s: %s", "Can't cycle", + "no argument given and this buffer is not a channel"); + // TODO: have a better way of checking if we're on the channel + else if (!ctx->current_buffer->channel->users) + buffer_send_error (ctx, ctx->current_buffer, + "%s: %s", "Can't cycle", "you're not on the channel"); + else + { + irc_send (s, "PART %s", ctx->current_buffer->channel->name); + // TODO: send the key if known + irc_send (s, "JOIN %s", ctx->current_buffer->channel->name); + } + return true; +} + +static bool handle_command_connect (struct app_context *ctx, char *arguments) { struct server *s = NULL; @@ -5377,7 +5412,9 @@ g_command_handlers[] = { "part", "Leave channels", "[<channel>[,<channel>...]] [reason]", handle_command_part }, - NOT_IMPLEMENTED (cycle) + { "cycle", "Rejoin channels", + "[<channel>[,<channel>...]] [reason]", + handle_command_cycle }, NOT_IMPLEMENTED (mode) NOT_IMPLEMENTED (topic) |