aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c123
1 files changed, 111 insertions, 12 deletions
diff --git a/degesch.c b/degesch.c
index 52414de..b5fc556 100644
--- a/degesch.c
+++ b/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
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,
"Can't do this from a global buffer (%s)", action);
else
@@ -5499,6 +5501,91 @@ handle_command_list (struct app_context *ctx, char *arguments)
}
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
handle_command_nick (struct app_context *ctx, char *arguments)
{
if (!server_command_check (ctx, "change nickname", false))
@@ -5526,8 +5613,6 @@ handle_command_quote (struct app_context *ctx, char *arguments)
static bool handle_command_help (struct app_context *, char *);
-#define NOT_IMPLEMENTED(name) { #name, "(Not implemented)", NULL, NULL },
-
static struct command_handler
{
const char *name;
@@ -5579,6 +5664,8 @@ g_command_handlers[] =
"[<channel>[,<channel>...]] [<reason>]",
handle_command_cycle },
+ // TODO: /op, /voice, /hop
+
{ "mode", "Change mode",
"[<channel>] [<mode>...]",
handle_command_mode },
@@ -5607,12 +5694,28 @@ g_command_handlers[] =
{ "list", "List channels and their topic",
"[<channel>[,<channel>...]] [<server>]",
handle_command_list },
- NOT_IMPLEMENTED (names)
- NOT_IMPLEMENTED (who)
- NOT_IMPLEMENTED (whois)
-
- NOT_IMPLEMENTED (motd)
- NOT_IMPLEMENTED (away)
+ // XXX: for NAMES with no arguments, how do we tell the end of it all?
+ // Maybe we just surf through all channels and process the lists
+ // 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 },
+
+ { "motd", "Get the Message of The Day",
+ NULL,
+ handle_command_motd },
+ { "away", "Set away status",
+ "[<text>]",
+ handle_command_away },
{ "nick", "Change current nick",
"<nickname>",
handle_command_nick },
@@ -5754,10 +5857,6 @@ process_user_command (struct app_context *ctx, char *command)
if (!handler)
buffer_send_error (ctx, ctx->global_buffer,
"%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))
buffer_send_error (ctx, ctx->global_buffer,
"%s: /%s %s", "Usage", handler->name, handler->usage);