degesch: implement /cycle

This commit is contained in:
Přemysl Eric Janouch 2015-05-17 16:25:52 +02:00
parent 02160c897a
commit f2ab9f3937
1 changed files with 38 additions and 1 deletions

View File

@ -5226,6 +5226,41 @@ handle_command_part (struct app_context *ctx, char *arguments)
return true;
}
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)
{
@ -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)