diff options
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/irc-commands.c | 19 | ||||
-rw-r--r-- | src/irc/irc-send.c | 86 | ||||
-rw-r--r-- | src/irc/irc.h | 3 |
3 files changed, 88 insertions, 20 deletions
diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c index 8889718e2..6fbd005b8 100644 --- a/src/irc/irc-commands.c +++ b/src/irc/irc-commands.c @@ -125,15 +125,15 @@ t_irc_command irc_commands[] = " w: user receives wallops\n" " o: operator flag\n"), 1, MAX_ARGS, 1, NULL, irc_cmd_send_mode, irc_cmd_recv_mode }, - { "msg", N_("send message to a nick or channel"), - N_("receiver[,receiver] text"), - N_("receiver: nick or channel (may be mask, '*' = current channel)" - "\ntext: text to send"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_msg, NULL }, { "motd", N_("get the \"Message Of The Day\""), N_("[target]"), N_("target: server name"), 0, 1, 1, NULL, irc_cmd_send_motd, NULL }, + { "msg", N_("send message to a nick or channel"), + N_("receiver[,receiver] text"), + N_("receiver: nick or channel (may be mask, '*' = current channel)" + "\ntext: text to send"), + 2, MAX_ARGS, 1, NULL, irc_cmd_send_msg, NULL }, { "names", N_("list nicknames on channels"), N_("[channel[,channel]]"), N_("channel: channel name"), 0, MAX_ARGS, 1, NULL, irc_cmd_send_names, NULL }, @@ -164,6 +164,11 @@ t_irc_command irc_commands[] = { "privmsg", N_("message received"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_privmsg }, + { "query", N_("send a private message to a nick"), + N_("nickname [text]"), + N_("nickname: nickname for private conversation" + "\ntext: text to send"), + 1, MAX_ARGS, 1, NULL, irc_cmd_send_query, NULL }, { "quit", N_("close all connections & quit " PACKAGE_NAME), N_("[quit_message]"), N_("quit_message: quit message (displayed to other users)"), @@ -391,6 +396,10 @@ t_irc_command irc_commands[] = "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, { "475", N_("cannot join channel (bad channel key)"), "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "476", N_("bad channel mask"), + "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "477", N_("channel doesn't support modes"), + "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, { "481", N_("you're not an IRC operator"), "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, { "482", N_("you're not channel operator"), diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c index ff7c9bc52..565598c87 100644 --- a/src/irc/irc-send.c +++ b/src/irc/irc-send.c @@ -417,6 +417,20 @@ irc_cmd_send_mode (t_irc_server *server, char *arguments) } /* + * irc_cmd_send_motd: get the "Message Of The Day" + */ + +int +irc_cmd_send_motd (t_irc_server *server, char *arguments) +{ + if (arguments) + server_sendf (server, "MOTD %s\r\n", arguments); + else + server_sendf (server, "MOTD\r\n"); + return 0; +} + +/* * irc_cmd_send_msg: send a message to a nick or channel */ @@ -538,20 +552,6 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) } /* - * irc_cmd_send_motd: get the "Message Of The Day" - */ - -int -irc_cmd_send_motd (t_irc_server *server, char *arguments) -{ - if (arguments) - server_sendf (server, "MOTD %s\r\n", arguments); - else - server_sendf (server, "MOTD\r\n"); - return 0; -} - -/* * irc_cmd_send_names: list nicknames on channels */ @@ -726,6 +726,64 @@ irc_cmd_send_pong (t_irc_server *server, char *arguments) } /* + * irc_cmd_send_query: start private conversation with a nick + */ + +int +irc_cmd_send_query (t_irc_server *server, char *arguments) +{ + char *pos; + t_irc_channel *ptr_channel; + + pos = strchr (arguments, ' '); + if (pos) + { + pos[0] = '\0'; + pos++; + while (pos[0] == ' ') + pos++; + if (!pos[0]) + pos = NULL; + } + + /* create private window if not already opened */ + ptr_channel = channel_search (server, arguments); + if (!ptr_channel) + { + ptr_channel = channel_new (server, CHAT_PRIVATE, arguments, 1); + if (!ptr_channel) + { + gui_printf (server->window, + _("%s cannot create new private window \"%s\"\n"), + WEECHAT_ERROR, + arguments); + return -1; + } + gui_redraw_window_title (ptr_channel->window); + } + + /* display text if given */ + if (pos) + { + gui_printf_color_type (ptr_channel->window, + MSG_TYPE_NICK, + COLOR_WIN_CHAT_DARK, "<"); + gui_printf_color_type (ptr_channel->window, + MSG_TYPE_NICK, + COLOR_WIN_NICK_SELF, + "%s", server->nick); + gui_printf_color_type (ptr_channel->window, + MSG_TYPE_NICK, + COLOR_WIN_CHAT_DARK, "> "); + gui_printf_color_type (ptr_channel->window, + MSG_TYPE_MSG, + COLOR_WIN_CHAT, "%s\n", pos); + server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos); + } + return 0; +} + +/* * irc_cmd_send_quit: disconnect from all servers and quit WeeChat */ diff --git a/src/irc/irc.h b/src/irc/irc.h index 1279f7444..3a3517c10 100644 --- a/src/irc/irc.h +++ b/src/irc/irc.h @@ -232,8 +232,8 @@ extern int irc_cmd_send_list (t_irc_server *, char *); extern int irc_cmd_send_lusers (t_irc_server *, char *); extern int irc_cmd_send_me (t_irc_server *, char *); extern int irc_cmd_send_mode (t_irc_server *, char *); -extern int irc_cmd_send_msg (t_irc_server *, char *); extern int irc_cmd_send_motd (t_irc_server *, char *); +extern int irc_cmd_send_msg (t_irc_server *, char *); extern int irc_cmd_send_names (t_irc_server *, char *); extern int irc_cmd_send_nick (t_irc_server *, int, char **); extern int irc_cmd_send_notice (t_irc_server *, char *); @@ -242,6 +242,7 @@ extern int irc_cmd_send_oper (t_irc_server *, char *); extern int irc_cmd_send_part (t_irc_server *, char *); extern int irc_cmd_send_ping (t_irc_server *, char *); extern int irc_cmd_send_pong (t_irc_server *, char *); +extern int irc_cmd_send_query (t_irc_server *, char *); extern int irc_cmd_send_quit (t_irc_server *, char *); extern int irc_cmd_send_quote (t_irc_server *, char *); extern int irc_cmd_send_rehash (t_irc_server *, char *); |