diff --git a/ChangeLog b/ChangeLog index bbd472750..05b2d7429 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,7 @@ ChangeLog - 2003-10-03 Version 0.0.2 (under dev!): - * alias for commands (new commands /alias and /unalias) + * alias for commands (new commands /alias and /unalias, new section in config file) * config is now saved automatically when quitting WeeChat * added new WeeChat commands: server, connect, disconnect, save * added autoconnect flag for each server in config file diff --git a/TODO b/TODO index cc590b41e..eb98f8231 100644 --- a/TODO +++ b/TODO @@ -27,7 +27,7 @@ v0.0.2: + "/set" command: allow the user to set the WeeChat variables under WeeChat without editing the config file (colours, time format, etc) - - "/alias" and "/unalias" commands + # "/alias" and "/unalias" commands - "/highlight" command: highlight a given word when it appears on channels/privates diff --git a/src/command.c b/src/command.c index 91463ea6d..8e9759b8e 100644 --- a/src/command.c +++ b/src/command.c @@ -166,6 +166,51 @@ index_command_insert_sorted (t_index_command *index) } } +/* + * index_command_new: create new index command and add it to index list + */ + +t_index_command * +index_command_new (char *command_name) +{ + t_index_command *new_index; + + if ((new_index = ((t_index_command *) malloc (sizeof (t_index_command))))) + { + new_index->command_name = strdup (command_name); + index_command_insert_sorted (new_index); + return new_index; + } + return NULL; +} + +/* + * index_command_build: build an index of commands (internal, irc and alias) + * This list will be sorted, and used for completion + */ + +void +index_command_build () +{ + int i; + + index_commands = NULL; + last_index_command = NULL; + i = 0; + while (weechat_commands[i].command_name) + { + index_command_new (weechat_commands[i].command_name); + i++; + } + i = 0; + while (irc_commands[i].command_name) + { + if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) + index_command_new (irc_commands[i].command_name); + i++; + } +} + /* * index_command_free: free an index command and reomve it from list */ @@ -196,44 +241,6 @@ index_command_free (t_index_command *index) index_commands = new_index_commands; } -/* - * index_command_build: build an index of commands (internal, irc and alias) - * This list will be sorted, and used for completion - */ - -void -index_command_build () -{ - int i; - t_index_command *new_index; - - index_commands = NULL; - last_index_command = NULL; - i = 0; - while (weechat_commands[i].command_name) - { - if ((new_index = ((t_index_command *) malloc (sizeof (t_index_command))))) - { - new_index->command_name = strdup (weechat_commands[i].command_name); - index_command_insert_sorted (new_index); - } - i++; - } - i = 0; - while (irc_commands[i].command_name) - { - if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) - { - if ((new_index = ((t_index_command *) malloc (sizeof (t_index_command))))) - { - new_index->command_name = strdup (irc_commands[i].command_name); - index_command_insert_sorted (new_index); - } - } - i++; - } -} - /* * alias_search: search an alias */ @@ -310,6 +317,28 @@ alias_insert_sorted (t_weechat_alias *alias) } } +/* + * alias_new: create new alias and add it to alias list + */ + +t_weechat_alias * +alias_new (char *alias_name, char *alias_command) +{ + t_weechat_alias *new_alias; + + if ((new_alias = ((t_weechat_alias *) malloc (sizeof (t_weechat_alias))))) + { + new_alias->alias_name = strdup (alias_name); + new_alias->alias_command = (char *)malloc (strlen (alias_command) + 2); + new_alias->alias_command[0] = '/'; + strcpy (new_alias->alias_command + 1, alias_command); + alias_insert_sorted (new_alias); + return new_alias; + } + else + return NULL; +} + /* * alias_free: free an alias and reomve it from list */ @@ -436,8 +465,8 @@ explode_string (char *string, char *separators, int num_items_max, int exec_weechat_command (t_irc_server *server, char *string) { - int i, j, argc, return_code; - char *pos, *ptr_args, **argv; + int i, j, argc, return_code, length1, length2; + char *pos, *ptr_args, **argv, *alias_command; t_weechat_alias *ptr_alias; if ((!string[0]) || (string[0] != '/')) @@ -574,7 +603,26 @@ exec_weechat_command (t_irc_server *server, char *string) { if (strcasecmp (ptr_alias->alias_name, string + 1) == 0) { - exec_weechat_command (server, ptr_alias->alias_command); + if (ptr_args) + { + length1 = strlen (ptr_alias->alias_command); + length2 = strlen (ptr_args); + alias_command = (char *)malloc (length1 + 1 + length2 + 1); + strcpy (alias_command, ptr_alias->alias_command); + alias_command[length1] = ' '; + strcpy (alias_command + length1 + 1, ptr_args); + } + else + alias_command = strdup (ptr_alias->alias_command); + exec_weechat_command (server, alias_command); + free (alias_command); + + if (argv) + { + for (j = 0; argv[j]; j++) + free (argv[j]); + free (argv); + } return 1; } } @@ -663,8 +711,7 @@ int weechat_cmd_alias (char *arguments) { char *pos, *pos2; - t_weechat_alias *ptr_alias, *new_alias; - t_index_command *new_index; + t_weechat_alias *ptr_alias; if (arguments && arguments[0]) { @@ -705,19 +752,9 @@ weechat_cmd_alias (char *arguments) } if (pos2) pos2[0] = ' '; - if ((new_index = ((t_index_command *) malloc (sizeof (t_index_command))))) - { - new_index->command_name = strdup (arguments); - index_command_insert_sorted (new_index); - } - if ((new_alias = ((t_weechat_alias *) malloc (sizeof (t_weechat_alias))))) - { - new_alias->alias_name = strdup (arguments); - new_alias->alias_command = (char *)malloc (strlen (pos) + 2); - new_alias->alias_command[0] = '/'; - strcpy (new_alias->alias_command + 1, pos); - alias_insert_sorted (new_alias); - } + index_command_new (arguments); + if (!alias_new (arguments, pos)) + return -1; gui_printf (NULL, _("Alias \"%s\" => \"%s\" created\n"), arguments, pos); } diff --git a/src/command.h b/src/command.h index ac248c526..1c9b43cd7 100644 --- a/src/command.h +++ b/src/command.h @@ -59,9 +59,12 @@ struct t_index_command t_index_command *next_index; }; +extern t_weechat_alias *weechat_alias; extern t_index_command *index_commands; +extern t_index_command *index_command_new (char *); extern void index_command_build (); +extern t_weechat_alias *alias_new (char *, char *); extern int exec_weechat_command (t_irc_server *, char *); extern void user_command (t_irc_server *, char *); extern int weechat_cmd_alias (char *); diff --git a/src/config.c b/src/config.c index 7c8418d24..1282b3620 100644 --- a/src/config.c +++ b/src/config.c @@ -31,6 +31,7 @@ #include "weechat.h" #include "config.h" +#include "command.h" #include "irc/irc.h" #include "gui/gui.h" @@ -44,6 +45,7 @@ t_config_section config_sections[CONFIG_NUMBER_SECTIONS] = { CONFIG_SECTION_LOG, "log" }, { CONFIG_SECTION_DCC, "dcc" }, { CONFIG_SECTION_PROXY, "proxy" }, + { CONFIG_SECTION_ALIAS, "alias" }, { CONFIG_SECTION_SERVER, "server" } }; @@ -485,7 +487,7 @@ t_config_option weechat_options_server[] = t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] = { weechat_options_look, weechat_options_colors, weechat_options_history, weechat_options_log, weechat_options_dcc, weechat_options_proxy, - weechat_options_server + NULL, weechat_options_server }; @@ -570,7 +572,7 @@ config_default_values () for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) { - if (i != CONFIG_SECTION_SERVER) + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) { for (j = 0; weechat_options[i][j].option_name; j++) { @@ -725,29 +727,35 @@ config_read () pos2 = strchr (pos, '\n'); if (pos2 != NULL) pos2[0] = '\0'; - option_number = -1; - for (i = 0; - weechat_options[section][i].option_name; i++) + + if (section == CONFIG_SECTION_ALIAS) { - if (strcmp - (weechat_options[section][i].option_name, - ptr_line) == 0) - { - option_number = i; - break; - } - } - if (option_number < 0) - { - gui_printf (NULL, - _("%s %s, line %d: invalid option \"%s\"\n"), - WEECHAT_WARNING, filename, line_number, ptr_line); - fclose (file); - free (filename); - return -2; + index_command_new (pos); + alias_new (line, pos); } else { + option_number = -1; + for (i = 0; + weechat_options[section][i].option_name; i++) + { + if (strcmp + (weechat_options[section][i].option_name, + ptr_line) == 0) + { + option_number = i; + break; + } + } + if (option_number < 0) + { + gui_printf (NULL, + _("%s %s, line %d: invalid option \"%s\"\n"), + WEECHAT_WARNING, filename, line_number, ptr_line); + fclose (file); + free (filename); + return -2; + } switch (weechat_options[section] [option_number].option_type) { @@ -923,7 +931,7 @@ config_create_default () for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) { - if (i != CONFIG_SECTION_SERVER) + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) { sprintf (line, "\n[%s]\n", config_sections[i].section_name); fputs (line, file); @@ -963,6 +971,10 @@ config_create_default () } } + /* default alias */ + fputs ("\n[alias]\n", file); + fputs ("say=msg *\n", file); + /* default server is freenode */ fputs ("\n[server]\n", file); fputs ("server_name=freenode\n", file); @@ -996,6 +1008,7 @@ config_write (char *config_name) int i, j; time_t current_time; t_irc_server *ptr_server; + t_weechat_alias *ptr_alias; if (config_name) filename = strdup (config_name); @@ -1023,7 +1036,7 @@ config_write (char *config_name) for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) { - if (i != CONFIG_SECTION_SERVER) + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) { sprintf (line, "\n[%s]\n", config_sections[i].section_name); fputs (line, file); @@ -1080,6 +1093,17 @@ config_write (char *config_name) } } + /* alias section */ + fputs ("\n[alias]\n", file); + for (ptr_alias = weechat_alias; ptr_alias; + ptr_alias = ptr_alias->next_alias) + { + sprintf (line, "%s=%s\n", + ptr_alias->alias_name, ptr_alias->alias_command + 1); + fputs (line, file); + } + + /* server section */ for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { diff --git a/src/config.h b/src/config.h index acb4f42c3..36eeb1616 100644 --- a/src/config.h +++ b/src/config.h @@ -32,8 +32,9 @@ #define CONFIG_SECTION_LOG 3 #define CONFIG_SECTION_DCC 4 #define CONFIG_SECTION_PROXY 5 -#define CONFIG_SECTION_SERVER 6 -#define CONFIG_NUMBER_SECTIONS 7 +#define CONFIG_SECTION_ALIAS 6 +#define CONFIG_SECTION_SERVER 7 +#define CONFIG_NUMBER_SECTIONS 8 #define OPTION_TYPE_BOOLEAN 1 /* values: on/off */ #define OPTION_TYPE_INT 2 /* values: from min to max */ diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c index fdab99b72..3391973a5 100644 --- a/src/irc/irc-commands.c +++ b/src/irc/irc-commands.c @@ -675,7 +675,7 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) } else gui_printf (server->window, - _("%s nick not found for \"privmsg\" command\n"), + _("%s nick not found for \"msg\" command\n"), WEECHAT_ERROR); server_sendf (server, "PRIVMSG %s :%s\r\n", ptr_channel->name, pos); } @@ -697,7 +697,7 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) } else gui_printf (server->window, - _("%s nick not found for \"privmsg\" command\n"), + _("%s nick not found for \"msg\" command\n"), WEECHAT_ERROR); } server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos); @@ -739,9 +739,12 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) } } else + { gui_printf (server->window, - _("%s wrong number of args for \"privmsg\" command\n"), + _("%s wrong argument count for \"msg\" command\n"), WEECHAT_ERROR); + return -1; + } return 0; } diff --git a/src/weechat.c b/src/weechat.c index e638b095a..b04549482 100644 --- a/src/weechat.c +++ b/src/weechat.c @@ -239,6 +239,9 @@ main (int argc, char *argv[]) /* init log file */ wee_init_log (); + /* build commands index (sorted), for completion */ + index_command_build (); + /* read configuration */ switch (config_read ()) { @@ -256,9 +259,6 @@ main (int argc, char *argv[]) /* init gui */ gui_init (); - /* build commands index (sorted), for completion */ - index_command_build (); - /* Welcome message - yeah! */ if (cfg_look_startup_logo) { diff --git a/weechat/ChangeLog b/weechat/ChangeLog index bbd472750..05b2d7429 100644 --- a/weechat/ChangeLog +++ b/weechat/ChangeLog @@ -5,7 +5,7 @@ ChangeLog - 2003-10-03 Version 0.0.2 (under dev!): - * alias for commands (new commands /alias and /unalias) + * alias for commands (new commands /alias and /unalias, new section in config file) * config is now saved automatically when quitting WeeChat * added new WeeChat commands: server, connect, disconnect, save * added autoconnect flag for each server in config file diff --git a/weechat/TODO b/weechat/TODO index cc590b41e..eb98f8231 100644 --- a/weechat/TODO +++ b/weechat/TODO @@ -27,7 +27,7 @@ v0.0.2: + "/set" command: allow the user to set the WeeChat variables under WeeChat without editing the config file (colours, time format, etc) - - "/alias" and "/unalias" commands + # "/alias" and "/unalias" commands - "/highlight" command: highlight a given word when it appears on channels/privates diff --git a/weechat/src/command.c b/weechat/src/command.c index 91463ea6d..8e9759b8e 100644 --- a/weechat/src/command.c +++ b/weechat/src/command.c @@ -166,6 +166,51 @@ index_command_insert_sorted (t_index_command *index) } } +/* + * index_command_new: create new index command and add it to index list + */ + +t_index_command * +index_command_new (char *command_name) +{ + t_index_command *new_index; + + if ((new_index = ((t_index_command *) malloc (sizeof (t_index_command))))) + { + new_index->command_name = strdup (command_name); + index_command_insert_sorted (new_index); + return new_index; + } + return NULL; +} + +/* + * index_command_build: build an index of commands (internal, irc and alias) + * This list will be sorted, and used for completion + */ + +void +index_command_build () +{ + int i; + + index_commands = NULL; + last_index_command = NULL; + i = 0; + while (weechat_commands[i].command_name) + { + index_command_new (weechat_commands[i].command_name); + i++; + } + i = 0; + while (irc_commands[i].command_name) + { + if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) + index_command_new (irc_commands[i].command_name); + i++; + } +} + /* * index_command_free: free an index command and reomve it from list */ @@ -196,44 +241,6 @@ index_command_free (t_index_command *index) index_commands = new_index_commands; } -/* - * index_command_build: build an index of commands (internal, irc and alias) - * This list will be sorted, and used for completion - */ - -void -index_command_build () -{ - int i; - t_index_command *new_index; - - index_commands = NULL; - last_index_command = NULL; - i = 0; - while (weechat_commands[i].command_name) - { - if ((new_index = ((t_index_command *) malloc (sizeof (t_index_command))))) - { - new_index->command_name = strdup (weechat_commands[i].command_name); - index_command_insert_sorted (new_index); - } - i++; - } - i = 0; - while (irc_commands[i].command_name) - { - if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) - { - if ((new_index = ((t_index_command *) malloc (sizeof (t_index_command))))) - { - new_index->command_name = strdup (irc_commands[i].command_name); - index_command_insert_sorted (new_index); - } - } - i++; - } -} - /* * alias_search: search an alias */ @@ -310,6 +317,28 @@ alias_insert_sorted (t_weechat_alias *alias) } } +/* + * alias_new: create new alias and add it to alias list + */ + +t_weechat_alias * +alias_new (char *alias_name, char *alias_command) +{ + t_weechat_alias *new_alias; + + if ((new_alias = ((t_weechat_alias *) malloc (sizeof (t_weechat_alias))))) + { + new_alias->alias_name = strdup (alias_name); + new_alias->alias_command = (char *)malloc (strlen (alias_command) + 2); + new_alias->alias_command[0] = '/'; + strcpy (new_alias->alias_command + 1, alias_command); + alias_insert_sorted (new_alias); + return new_alias; + } + else + return NULL; +} + /* * alias_free: free an alias and reomve it from list */ @@ -436,8 +465,8 @@ explode_string (char *string, char *separators, int num_items_max, int exec_weechat_command (t_irc_server *server, char *string) { - int i, j, argc, return_code; - char *pos, *ptr_args, **argv; + int i, j, argc, return_code, length1, length2; + char *pos, *ptr_args, **argv, *alias_command; t_weechat_alias *ptr_alias; if ((!string[0]) || (string[0] != '/')) @@ -574,7 +603,26 @@ exec_weechat_command (t_irc_server *server, char *string) { if (strcasecmp (ptr_alias->alias_name, string + 1) == 0) { - exec_weechat_command (server, ptr_alias->alias_command); + if (ptr_args) + { + length1 = strlen (ptr_alias->alias_command); + length2 = strlen (ptr_args); + alias_command = (char *)malloc (length1 + 1 + length2 + 1); + strcpy (alias_command, ptr_alias->alias_command); + alias_command[length1] = ' '; + strcpy (alias_command + length1 + 1, ptr_args); + } + else + alias_command = strdup (ptr_alias->alias_command); + exec_weechat_command (server, alias_command); + free (alias_command); + + if (argv) + { + for (j = 0; argv[j]; j++) + free (argv[j]); + free (argv); + } return 1; } } @@ -663,8 +711,7 @@ int weechat_cmd_alias (char *arguments) { char *pos, *pos2; - t_weechat_alias *ptr_alias, *new_alias; - t_index_command *new_index; + t_weechat_alias *ptr_alias; if (arguments && arguments[0]) { @@ -705,19 +752,9 @@ weechat_cmd_alias (char *arguments) } if (pos2) pos2[0] = ' '; - if ((new_index = ((t_index_command *) malloc (sizeof (t_index_command))))) - { - new_index->command_name = strdup (arguments); - index_command_insert_sorted (new_index); - } - if ((new_alias = ((t_weechat_alias *) malloc (sizeof (t_weechat_alias))))) - { - new_alias->alias_name = strdup (arguments); - new_alias->alias_command = (char *)malloc (strlen (pos) + 2); - new_alias->alias_command[0] = '/'; - strcpy (new_alias->alias_command + 1, pos); - alias_insert_sorted (new_alias); - } + index_command_new (arguments); + if (!alias_new (arguments, pos)) + return -1; gui_printf (NULL, _("Alias \"%s\" => \"%s\" created\n"), arguments, pos); } diff --git a/weechat/src/command.h b/weechat/src/command.h index ac248c526..1c9b43cd7 100644 --- a/weechat/src/command.h +++ b/weechat/src/command.h @@ -59,9 +59,12 @@ struct t_index_command t_index_command *next_index; }; +extern t_weechat_alias *weechat_alias; extern t_index_command *index_commands; +extern t_index_command *index_command_new (char *); extern void index_command_build (); +extern t_weechat_alias *alias_new (char *, char *); extern int exec_weechat_command (t_irc_server *, char *); extern void user_command (t_irc_server *, char *); extern int weechat_cmd_alias (char *); diff --git a/weechat/src/config.c b/weechat/src/config.c index 7c8418d24..1282b3620 100644 --- a/weechat/src/config.c +++ b/weechat/src/config.c @@ -31,6 +31,7 @@ #include "weechat.h" #include "config.h" +#include "command.h" #include "irc/irc.h" #include "gui/gui.h" @@ -44,6 +45,7 @@ t_config_section config_sections[CONFIG_NUMBER_SECTIONS] = { CONFIG_SECTION_LOG, "log" }, { CONFIG_SECTION_DCC, "dcc" }, { CONFIG_SECTION_PROXY, "proxy" }, + { CONFIG_SECTION_ALIAS, "alias" }, { CONFIG_SECTION_SERVER, "server" } }; @@ -485,7 +487,7 @@ t_config_option weechat_options_server[] = t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] = { weechat_options_look, weechat_options_colors, weechat_options_history, weechat_options_log, weechat_options_dcc, weechat_options_proxy, - weechat_options_server + NULL, weechat_options_server }; @@ -570,7 +572,7 @@ config_default_values () for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) { - if (i != CONFIG_SECTION_SERVER) + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) { for (j = 0; weechat_options[i][j].option_name; j++) { @@ -725,29 +727,35 @@ config_read () pos2 = strchr (pos, '\n'); if (pos2 != NULL) pos2[0] = '\0'; - option_number = -1; - for (i = 0; - weechat_options[section][i].option_name; i++) + + if (section == CONFIG_SECTION_ALIAS) { - if (strcmp - (weechat_options[section][i].option_name, - ptr_line) == 0) - { - option_number = i; - break; - } - } - if (option_number < 0) - { - gui_printf (NULL, - _("%s %s, line %d: invalid option \"%s\"\n"), - WEECHAT_WARNING, filename, line_number, ptr_line); - fclose (file); - free (filename); - return -2; + index_command_new (pos); + alias_new (line, pos); } else { + option_number = -1; + for (i = 0; + weechat_options[section][i].option_name; i++) + { + if (strcmp + (weechat_options[section][i].option_name, + ptr_line) == 0) + { + option_number = i; + break; + } + } + if (option_number < 0) + { + gui_printf (NULL, + _("%s %s, line %d: invalid option \"%s\"\n"), + WEECHAT_WARNING, filename, line_number, ptr_line); + fclose (file); + free (filename); + return -2; + } switch (weechat_options[section] [option_number].option_type) { @@ -923,7 +931,7 @@ config_create_default () for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) { - if (i != CONFIG_SECTION_SERVER) + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) { sprintf (line, "\n[%s]\n", config_sections[i].section_name); fputs (line, file); @@ -963,6 +971,10 @@ config_create_default () } } + /* default alias */ + fputs ("\n[alias]\n", file); + fputs ("say=msg *\n", file); + /* default server is freenode */ fputs ("\n[server]\n", file); fputs ("server_name=freenode\n", file); @@ -996,6 +1008,7 @@ config_write (char *config_name) int i, j; time_t current_time; t_irc_server *ptr_server; + t_weechat_alias *ptr_alias; if (config_name) filename = strdup (config_name); @@ -1023,7 +1036,7 @@ config_write (char *config_name) for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) { - if (i != CONFIG_SECTION_SERVER) + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) { sprintf (line, "\n[%s]\n", config_sections[i].section_name); fputs (line, file); @@ -1080,6 +1093,17 @@ config_write (char *config_name) } } + /* alias section */ + fputs ("\n[alias]\n", file); + for (ptr_alias = weechat_alias; ptr_alias; + ptr_alias = ptr_alias->next_alias) + { + sprintf (line, "%s=%s\n", + ptr_alias->alias_name, ptr_alias->alias_command + 1); + fputs (line, file); + } + + /* server section */ for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { diff --git a/weechat/src/config.h b/weechat/src/config.h index acb4f42c3..36eeb1616 100644 --- a/weechat/src/config.h +++ b/weechat/src/config.h @@ -32,8 +32,9 @@ #define CONFIG_SECTION_LOG 3 #define CONFIG_SECTION_DCC 4 #define CONFIG_SECTION_PROXY 5 -#define CONFIG_SECTION_SERVER 6 -#define CONFIG_NUMBER_SECTIONS 7 +#define CONFIG_SECTION_ALIAS 6 +#define CONFIG_SECTION_SERVER 7 +#define CONFIG_NUMBER_SECTIONS 8 #define OPTION_TYPE_BOOLEAN 1 /* values: on/off */ #define OPTION_TYPE_INT 2 /* values: from min to max */ diff --git a/weechat/src/irc/irc-commands.c b/weechat/src/irc/irc-commands.c index fdab99b72..3391973a5 100644 --- a/weechat/src/irc/irc-commands.c +++ b/weechat/src/irc/irc-commands.c @@ -675,7 +675,7 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) } else gui_printf (server->window, - _("%s nick not found for \"privmsg\" command\n"), + _("%s nick not found for \"msg\" command\n"), WEECHAT_ERROR); server_sendf (server, "PRIVMSG %s :%s\r\n", ptr_channel->name, pos); } @@ -697,7 +697,7 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) } else gui_printf (server->window, - _("%s nick not found for \"privmsg\" command\n"), + _("%s nick not found for \"msg\" command\n"), WEECHAT_ERROR); } server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos); @@ -739,9 +739,12 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) } } else + { gui_printf (server->window, - _("%s wrong number of args for \"privmsg\" command\n"), + _("%s wrong argument count for \"msg\" command\n"), WEECHAT_ERROR); + return -1; + } return 0; } diff --git a/weechat/src/weechat.c b/weechat/src/weechat.c index e638b095a..b04549482 100644 --- a/weechat/src/weechat.c +++ b/weechat/src/weechat.c @@ -239,6 +239,9 @@ main (int argc, char *argv[]) /* init log file */ wee_init_log (); + /* build commands index (sorted), for completion */ + index_command_build (); + /* read configuration */ switch (config_read ()) { @@ -256,9 +259,6 @@ main (int argc, char *argv[]) /* init gui */ gui_init (); - /* build commands index (sorted), for completion */ - index_command_build (); - /* Welcome message - yeah! */ if (cfg_look_startup_logo) {