diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-07-16 23:26:01 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-07-16 23:26:01 +0000 |
commit | 1eac6d8fdd2d3d3df8e2ae2358bc390a39c257f6 (patch) | |
tree | 87305fa3f1adcb0595a1b01525b3ef1fd9e4ec45 /src | |
parent | 23696b44da8724eefb39554f04bb9c27d7811164 (diff) | |
download | weechat-1eac6d8fdd2d3d3df8e2ae2358bc390a39c257f6.zip |
Added /amsg command (send text to all channels of all connected servers)
Diffstat (limited to 'src')
-rw-r--r-- | src/irc/irc-commands.c | 4 | ||||
-rw-r--r-- | src/irc/irc-send.c | 55 | ||||
-rw-r--r-- | src/irc/irc.h | 1 |
3 files changed, 60 insertions, 0 deletions
diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c index a43e2900d..4c95fcc74 100644 --- a/src/irc/irc-commands.c +++ b/src/irc/irc-commands.c @@ -35,6 +35,10 @@ t_irc_command irc_commands[] = N_("[target]"), N_("target: server"), 0, 1, 1, NULL, irc_cmd_send_admin, NULL }, + { "amsg", N_("send message to all channels of all connected servers"), + N_("text"), + N_("text: text to send"), + 1, MAX_ARGS, 1, NULL, irc_cmd_send_amsg, NULL }, { "away", N_("toggle away status"), N_("[-all] [message]"), N_("-all: toggle away status on all connected servers\n" diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c index 266ea67d0..7f14b1689 100644 --- a/src/irc/irc-send.c +++ b/src/irc/irc-send.c @@ -82,6 +82,61 @@ irc_cmd_send_admin (t_irc_server *server, char *arguments) } /* + * irc_cmd_send_amsg: send message to all channels of all connected servers + */ + +int +irc_cmd_send_amsg (t_irc_server *server, char *arguments) +{ + t_irc_server *ptr_server; + t_irc_channel *ptr_channel; + t_irc_nick *ptr_nick; + + /* make gcc happy */ + (void) server; + + if (arguments) + { + gui_add_hotlist = 0; + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + if (ptr_server->is_connected) + { + for (ptr_channel = ptr_server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + if (ptr_channel->type == CHAT_CHANNEL) + { + server_sendf (ptr_server, "PRIVMSG %s :%s\r\n", + ptr_channel->name, arguments); + ptr_nick = nick_search (ptr_channel, ptr_server->nick); + if (ptr_nick) + { + irc_display_nick (ptr_channel->buffer, ptr_nick, NULL, + MSG_TYPE_NICK, 1, 1, 0); + gui_printf_color (ptr_channel->buffer, + COLOR_WIN_CHAT, "%s\n", arguments); + } + else + { + irc_display_prefix (ptr_server->buffer, PREFIX_ERROR); + gui_printf (ptr_server->buffer, + _("%s cannot find nick for sending message\n"), + WEECHAT_ERROR); + } + } + } + } + } + gui_add_hotlist = 1; + } + else + return -1; + return 0; +} + +/* * irc_cmd_send_away: toggle away status */ diff --git a/src/irc/irc.h b/src/irc/irc.h index e958b8a96..d20dff257 100644 --- a/src/irc/irc.h +++ b/src/irc/irc.h @@ -355,6 +355,7 @@ extern int irc_recv_command (t_irc_server *, char *, char *, char *, char *); extern void irc_login (t_irc_server *); /* IRC commands issued by user */ extern int irc_cmd_send_admin (t_irc_server *, char *); +extern int irc_cmd_send_amsg (t_irc_server *, char *); extern int irc_cmd_send_away (t_irc_server *, char *); extern int irc_cmd_send_ban (t_irc_server *, char *); extern int irc_cmd_send_ctcp (t_irc_server *, char *); |