aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-10 01:45:39 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-10 01:45:39 +0200
commit5da45877d6e5abd5e42da331f9371e8ae1bcece8 (patch)
tree7c82df85a949cd9d6d8188d8fa3b25159c10aa80
parent0fd53af0d102af83db18801cceb78bdd55d7c0a6 (diff)
downloadxK-5da45877d6e5abd5e42da331f9371e8ae1bcece8.tar.gz
xK-5da45877d6e5abd5e42da331f9371e8ae1bcece8.tar.xz
xK-5da45877d6e5abd5e42da331f9371e8ae1bcece8.zip
degesch: add /alias that only lists aliases
-rw-r--r--degesch.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/degesch.c b/degesch.c
index 35e7891..041fa4f 100644
--- a/degesch.c
+++ b/degesch.c
@@ -6807,6 +6807,45 @@ handle_command_save (struct handler_args *a)
}
static bool
+show_aliases_list (struct app_context *ctx)
+{
+ log_global_indent (ctx, "");
+ log_global_indent (ctx, "Aliases:");
+
+ struct str_map_iter iter;
+ str_map_iter_init (&iter, get_aliases_config (ctx));
+
+ struct config_item_ *alias;
+ while ((alias = str_map_iter_next (&iter)))
+ {
+ if (!config_item_type_is_string (alias->type))
+ continue;
+
+ struct str definition;
+ str_init (&definition);
+ config_item_write_string (&definition, &alias->value.string);
+ log_global_indent (ctx, " /#s: #s", iter.link->key, definition.str);
+ str_free (&definition);
+ }
+ return true;
+}
+
+static bool
+handle_command_alias (struct handler_args *a)
+{
+ char *name = cut_word (&a->arguments);
+ if (!*name)
+ return show_aliases_list (a->ctx);
+
+ char *definition = cut_word (&a->arguments);
+ if (!*definition)
+ return false;
+
+ // TODO: set the alias "name" to "definition"
+ return true;
+}
+
+static bool
handle_command_msg (struct handler_args *a)
{
if (!*a->arguments)
@@ -7402,6 +7441,10 @@ g_command_handlers[] =
NULL,
handle_command_save, 0 },
+ { "alias", "List or set aliases",
+ "[<name> <definition>]",
+ handle_command_alias, 0 },
+
{ "msg", "Send message to a nick or channel",
"<target> <message>",
handle_command_msg, HANDLER_SERVER | HANDLER_NEEDS_REG },