summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/degesch.c b/degesch.c
index d064812..da80577 100644
--- a/degesch.c
+++ b/degesch.c
@@ -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)