degesch: naively implement the unimplemented
This commit is contained in:
parent
310b9c31d3
commit
4016c387f8
121
degesch.c
121
degesch.c
|
@ -4794,6 +4794,8 @@ server_command_check (struct app_context *ctx, const char *action,
|
||||||
// as they may want to log buffer lines and use our current nickname
|
// as they may want to log buffer lines and use our current nickname
|
||||||
|
|
||||||
if (ctx->current_buffer->type == BUFFER_GLOBAL)
|
if (ctx->current_buffer->type == BUFFER_GLOBAL)
|
||||||
|
// XXX: couldn't we just pass the name of the user command here?
|
||||||
|
// That doesn't actually concern the function but rather its callers.
|
||||||
buffer_send_error (ctx, ctx->current_buffer,
|
buffer_send_error (ctx, ctx->current_buffer,
|
||||||
"Can't do this from a global buffer (%s)", action);
|
"Can't do this from a global buffer (%s)", action);
|
||||||
else
|
else
|
||||||
|
@ -5498,6 +5500,91 @@ handle_command_list (struct app_context *ctx, char *arguments)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
handle_command_names (struct app_context *ctx, char *arguments)
|
||||||
|
{
|
||||||
|
if (!server_command_check (ctx, "names", true))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
struct server *s = ctx->current_buffer->server;
|
||||||
|
char *channel_name = try_get_channel (ctx, &arguments);
|
||||||
|
if (!channel_name)
|
||||||
|
irc_send (s, "NAMES");
|
||||||
|
else
|
||||||
|
irc_send (s, "NAMES %s", channel_name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
handle_command_who (struct app_context *ctx, char *arguments)
|
||||||
|
{
|
||||||
|
if (!server_command_check (ctx, "who", true))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
struct server *s = ctx->current_buffer->server;
|
||||||
|
if (*arguments)
|
||||||
|
irc_send (s, "WHO %s", arguments);
|
||||||
|
else
|
||||||
|
irc_send (s, "WHO");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
handle_command_whois (struct app_context *ctx, char *arguments)
|
||||||
|
{
|
||||||
|
if (!server_command_check (ctx, "whois", true))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
struct server *s = ctx->current_buffer->server;
|
||||||
|
if (*arguments)
|
||||||
|
irc_send (s, "WHOIS %s", arguments);
|
||||||
|
else
|
||||||
|
irc_send (s, "WHOIS");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
handle_command_whowas (struct app_context *ctx, char *arguments)
|
||||||
|
{
|
||||||
|
if (!server_command_check (ctx, "whowas", true))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
struct server *s = ctx->current_buffer->server;
|
||||||
|
if (*arguments)
|
||||||
|
irc_send (s, "WHOWAS %s", arguments);
|
||||||
|
else
|
||||||
|
irc_send (s, "WHOWAS");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
handle_command_motd (struct app_context *ctx, char *arguments)
|
||||||
|
{
|
||||||
|
if (!server_command_check (ctx, "motd", true))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
struct server *s = ctx->current_buffer->server;
|
||||||
|
if (*arguments)
|
||||||
|
irc_send (s, "MOTD %s", arguments);
|
||||||
|
else
|
||||||
|
irc_send (s, "MOTD");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
handle_command_away (struct app_context *ctx, char *arguments)
|
||||||
|
{
|
||||||
|
if (!server_command_check (ctx, "away", true))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
struct server *s = ctx->current_buffer->server;
|
||||||
|
if (*arguments)
|
||||||
|
irc_send (s, "AWAY %s", arguments);
|
||||||
|
else
|
||||||
|
irc_send (s, "AWAY");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
handle_command_nick (struct app_context *ctx, char *arguments)
|
handle_command_nick (struct app_context *ctx, char *arguments)
|
||||||
{
|
{
|
||||||
|
@ -5526,8 +5613,6 @@ handle_command_quote (struct app_context *ctx, char *arguments)
|
||||||
|
|
||||||
static bool handle_command_help (struct app_context *, char *);
|
static bool handle_command_help (struct app_context *, char *);
|
||||||
|
|
||||||
#define NOT_IMPLEMENTED(name) { #name, "(Not implemented)", NULL, NULL },
|
|
||||||
|
|
||||||
static struct command_handler
|
static struct command_handler
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -5579,6 +5664,8 @@ g_command_handlers[] =
|
||||||
"[<channel>[,<channel>...]] [<reason>]",
|
"[<channel>[,<channel>...]] [<reason>]",
|
||||||
handle_command_cycle },
|
handle_command_cycle },
|
||||||
|
|
||||||
|
// TODO: /op, /voice, /hop
|
||||||
|
|
||||||
{ "mode", "Change mode",
|
{ "mode", "Change mode",
|
||||||
"[<channel>] [<mode>...]",
|
"[<channel>] [<mode>...]",
|
||||||
handle_command_mode },
|
handle_command_mode },
|
||||||
|
@ -5607,12 +5694,28 @@ g_command_handlers[] =
|
||||||
{ "list", "List channels and their topic",
|
{ "list", "List channels and their topic",
|
||||||
"[<channel>[,<channel>...]] [<server>]",
|
"[<channel>[,<channel>...]] [<server>]",
|
||||||
handle_command_list },
|
handle_command_list },
|
||||||
NOT_IMPLEMENTED (names)
|
// XXX: for NAMES with no arguments, how do we tell the end of it all?
|
||||||
NOT_IMPLEMENTED (who)
|
// Maybe we just surf through all channels and process the lists
|
||||||
NOT_IMPLEMENTED (whois)
|
// as they are.
|
||||||
|
{ "names", "List users on channel",
|
||||||
|
"[<channel>[,<channel>...]]",
|
||||||
|
handle_command_names },
|
||||||
|
{ "who", "List users",
|
||||||
|
"[<mask>]",
|
||||||
|
handle_command_who },
|
||||||
|
{ "whois", "Get user information",
|
||||||
|
"<mask>",
|
||||||
|
handle_command_whois },
|
||||||
|
{ "whowas", "Get user information",
|
||||||
|
"<mask>",
|
||||||
|
handle_command_whowas },
|
||||||
|
|
||||||
NOT_IMPLEMENTED (motd)
|
{ "motd", "Get the Message of The Day",
|
||||||
NOT_IMPLEMENTED (away)
|
NULL,
|
||||||
|
handle_command_motd },
|
||||||
|
{ "away", "Set away status",
|
||||||
|
"[<text>]",
|
||||||
|
handle_command_away },
|
||||||
{ "nick", "Change current nick",
|
{ "nick", "Change current nick",
|
||||||
"<nickname>",
|
"<nickname>",
|
||||||
handle_command_nick },
|
handle_command_nick },
|
||||||
|
@ -5754,10 +5857,6 @@ process_user_command (struct app_context *ctx, char *command)
|
||||||
if (!handler)
|
if (!handler)
|
||||||
buffer_send_error (ctx, ctx->global_buffer,
|
buffer_send_error (ctx, ctx->global_buffer,
|
||||||
"%s: %s", "No such command", name);
|
"%s: %s", "No such command", name);
|
||||||
// TODO: remove once everything is implemented
|
|
||||||
else if (!handler->handler)
|
|
||||||
buffer_send_error (ctx, ctx->global_buffer,
|
|
||||||
"%s: %s", "Not implemented", name);
|
|
||||||
else if (!handler->handler (ctx, command))
|
else if (!handler->handler (ctx, command))
|
||||||
buffer_send_error (ctx, ctx->global_buffer,
|
buffer_send_error (ctx, ctx->global_buffer,
|
||||||
"%s: /%s %s", "Usage", handler->name, handler->usage);
|
"%s: /%s %s", "Usage", handler->name, handler->usage);
|
||||||
|
|
Loading…
Reference in New Issue