diff options
Diffstat (limited to 'src/fe-common/core')
-rw-r--r-- | src/fe-common/core/fe-channels.c | 5 | ||||
-rw-r--r-- | src/fe-common/core/fe-core-commands.c | 42 | ||||
-rw-r--r-- | src/fe-common/core/module-formats.c | 3 | ||||
-rw-r--r-- | src/fe-common/core/module-formats.h | 3 |
4 files changed, 52 insertions, 1 deletions
diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c index 8e6ec57b..27363e53 100644 --- a/src/fe-common/core/fe-channels.c +++ b/src/fe-common/core/fe-channels.c @@ -236,8 +236,11 @@ static void cmd_channel(const char *data, SERVER_REC *server, WI_ITEM_REC *item) { if (*data == '\0') cmd_channel_list_joined(); - else + else if (server_ischannel(server, data)) { + signal_emit("command join", 3, data, server, item); + } else { command_runsub("channel", data, server, item); + } } /* SYNTAX: CHANNEL ADD [-auto | -noauto] [-bots <masks>] [-botcmd <command>] diff --git a/src/fe-common/core/fe-core-commands.c b/src/fe-common/core/fe-core-commands.c index 87515f4d..dc1f121c 100644 --- a/src/fe-common/core/fe-core-commands.c +++ b/src/fe-common/core/fe-core-commands.c @@ -45,6 +45,7 @@ static int ret_texts[] = { TXT_NOT_JOINED, TXT_CHAN_NOT_FOUND, TXT_CHAN_NOT_SYNCED, + TXT_ILLEGAL_PROTO, TXT_NOT_GOOD_IDEA }; @@ -145,6 +146,43 @@ static void cmd_beep(void) signal_emit("beep", 0); } +static void cmd_nick(const char *data, SERVER_REC *server) +{ + g_return_if_fail(data != NULL); + + if (*data != '\0') return; + if (server == NULL || !server->connected) + cmd_return_error(CMDERR_NOT_CONNECTED); + + /* display current nick */ + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_YOUR_NICK, server->nick); + signal_stop(); +} + +static void cmd_join(const char *data, SERVER_REC *server) +{ + GHashTable *optlist; + char *channels; + void *free_arg; + + g_return_if_fail(data != NULL); + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | + PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, + "join", &optlist, &channels)) + return; + + server = cmd_options_get_server("join", optlist, server); + if (g_hash_table_lookup(optlist, "invite") && + server != NULL && server->last_invite == NULL) { + /* ..all this trouble just to print this error message */ + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_NOT_INVITED); + signal_stop(); + } + + cmd_params_free(free_arg); +} + static void sig_stop(void) { signal_stop(); @@ -277,6 +315,8 @@ void fe_core_commands_init(void) command_bind("version", NULL, (SIGNAL_FUNC) cmd_version); command_bind("cat", NULL, (SIGNAL_FUNC) cmd_cat); command_bind("beep", NULL, (SIGNAL_FUNC) cmd_beep); + command_bind_first("nick", NULL, (SIGNAL_FUNC) cmd_nick); + command_bind_first("join", NULL, (SIGNAL_FUNC) cmd_join); signal_add("send command", (SIGNAL_FUNC) event_command); signal_add_last("send command", (SIGNAL_FUNC) event_command_last); @@ -293,6 +333,8 @@ void fe_core_commands_deinit(void) command_unbind("version", (SIGNAL_FUNC) cmd_version); command_unbind("cat", (SIGNAL_FUNC) cmd_cat); command_unbind("beep", (SIGNAL_FUNC) cmd_beep); + command_unbind("nick", (SIGNAL_FUNC) cmd_nick); + command_unbind("join", (SIGNAL_FUNC) cmd_join); signal_remove("send command", (SIGNAL_FUNC) event_command); signal_remove("send command", (SIGNAL_FUNC) event_command_last); diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index 9ddd9fbe..ee34e495 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -82,6 +82,7 @@ FORMAT_REC fecommon_core_formats[] = { { "setupserver_added", "Server {server $0} saved", 2, { 0, 1 } }, { "setupserver_removed", "Server {server $0} removed", 2, { 0, 1 } }, { "setupserver_not_found", "Server {server $0} not found", 2, { 0, 1 } }, + { "your_nick", "Your nickname is {nick $0}", 1, { 0 } }, /* ---- */ { NULL, "Channels", 0 }, @@ -92,6 +93,7 @@ FORMAT_REC fecommon_core_formats[] = { { "quit", "{channick $0} {chanhost $1} has quit {reason $2}", 4, { 0, 0, 0, 0 } }, { "quit_once", "{channel $3} {channick $0} {chanhost $1} has quit {reason $2}", 4, { 0, 0, 0, 0 } }, { "invite", "{nick $0} invites you to {channel $1}", 2, { 0, 0 } }, + { "not_invited", "You have not been invited to a channel!", 0 }, { "new_topic", "{nick $0} changed the topic of {channel $1} to: $2", 3, { 0, 0, 0 } }, { "topic_unset", "Topic unset by {nick $0} on {channel $1}", 2, { 0, 0 } }, { "your_nick_changed", "You're now known as {nick $1}", 3, { 0, 0, 0 } }, @@ -202,6 +204,7 @@ FORMAT_REC fecommon_core_formats[] = { { "not_joined", "Not joined to any channel", 0 }, { "chan_not_found", "Not joined to such channel", 0 }, { "chan_not_synced", "Channel not fully synchronized yet, try again after a while", 0 }, + { "illegal_proto", "Command isn't designed for the chat protocol of the active server", 0 }, { "not_good_idea", "Doing this is not a good idea. Add -YES if you really mean it", 0 }, /* ---- */ diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index 40ff4ef4..a6156069 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -59,6 +59,7 @@ enum { TXT_SETUPSERVER_ADDED, TXT_SETUPSERVER_REMOVED, TXT_SETUPSERVER_NOT_FOUND, + TXT_YOUR_NICK, TXT_FILL_3, @@ -68,6 +69,7 @@ enum { TXT_QUIT, TXT_QUIT_ONCE, TXT_INVITE, + TXT_NOT_INVITED, TXT_NEW_TOPIC, TXT_TOPIC_UNSET, TXT_YOUR_NICK_CHANGED, @@ -171,6 +173,7 @@ enum { TXT_NOT_JOINED, TXT_CHAN_NOT_FOUND, TXT_CHAN_NOT_SYNCED, + TXT_ILLEGAL_PROTO, TXT_NOT_GOOD_IDEA, TXT_FILL_11, |