diff options
author | Timo Sirainen <cras@irssi.org> | 2001-01-01 16:57:25 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-01-01 16:57:25 +0000 |
commit | 2ae679be088b0c726bf1c482fd22ee3231c94349 (patch) | |
tree | 804506241870ee73d6506c731a4e72f7f7d90e1b /src/fe-common/irc | |
parent | 219c83ae6ab83e546fe18bc697ef3a1ab3d12caa (diff) | |
download | irssi-2ae679be088b0c726bf1c482fd22ee3231c94349.zip |
added "message own_public" and "message own_private" events that are
sent when /msg command is used. this way we don't need to parse the
/msg's options everywhere. also efnet @#channels support works now better.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1041 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/irc')
-rw-r--r-- | src/fe-common/irc/Makefile.am | 1 | ||||
-rw-r--r-- | src/fe-common/irc/fe-common-irc.c | 5 | ||||
-rw-r--r-- | src/fe-common/irc/fe-events.c | 12 | ||||
-rw-r--r-- | src/fe-common/irc/fe-irc-messages.c | 81 |
4 files changed, 96 insertions, 3 deletions
diff --git a/src/fe-common/irc/Makefile.am b/src/fe-common/irc/Makefile.am index 0abc41f9..b69499f1 100644 --- a/src/fe-common/irc/Makefile.am +++ b/src/fe-common/irc/Makefile.am @@ -14,6 +14,7 @@ INCLUDES = \ libfe_common_irc_a_SOURCES = \ fe-irc-channels.c \ fe-irc-commands.c \ + fe-irc-messages.c \ fe-irc-queries.c \ fe-irc-server.c \ fe-ircnet.c \ diff --git a/src/fe-common/irc/fe-common-irc.c b/src/fe-common/irc/fe-common-irc.c index e3d23556..a0169299 100644 --- a/src/fe-common/irc/fe-common-irc.c +++ b/src/fe-common/irc/fe-common-irc.c @@ -39,6 +39,9 @@ void fe_irc_channels_deinit(void); void fe_irc_queries_init(void); void fe_irc_queries_deinit(void); +void fe_irc_messages_init(void); +void fe_irc_messages_deinit(void); + void fe_irc_commands_init(void); void fe_irc_commands_deinit(void); @@ -99,6 +102,7 @@ void fe_common_irc_init(void) fe_irc_channels_init(); fe_irc_queries_init(); + fe_irc_messages_init(); fe_irc_commands_init(); fe_ircnet_init(); fe_irc_server_init(); @@ -119,6 +123,7 @@ void fe_common_irc_deinit(void) fe_irc_channels_deinit(); fe_irc_queries_deinit(); + fe_irc_messages_deinit(); fe_irc_commands_deinit(); fe_ircnet_deinit(); fe_irc_server_deinit(); diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c index 4ebc40b5..b03c2ca5 100644 --- a/src/fe-common/irc/fe-events.c +++ b/src/fe-common/irc/fe-events.c @@ -51,9 +51,15 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data, if (nick == NULL) nick = server->real_address; if (addr == NULL) addr = ""; - signal_emit(ischannel(*target) ? - "message public" : "message private", 5, - server, msg, nick, addr, target); + if (*target == '@' && ischannel(target[1])) { + /* Hybrid 6 feature, send msg to all ops in channel */ + signal_emit("message irc op_public", 5, + server, msg, nick, addr, target+1); + } else { + signal_emit(ischannel(*target) ? + "message public" : "message private", 5, + server, msg, nick, addr, target); + } g_free(params); } diff --git a/src/fe-common/irc/fe-irc-messages.c b/src/fe-common/irc/fe-irc-messages.c new file mode 100644 index 00000000..1d33c9c2 --- /dev/null +++ b/src/fe-common/irc/fe-irc-messages.c @@ -0,0 +1,81 @@ +/* + fe-irc-messages.c : irssi + + Copyright (C) 2001 Timo Sirainen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" +#include "levels.h" +#include "channels.h" + +#include "irc.h" + +/* FIXME: hmm. there's should be some better way to use other module's + formats than this since now we can't use this module's formats.. */ +#include "../core/module-formats.h" +#include "printtext.h" +#include "fe-messages.h" + +static void sig_message_own_public(SERVER_REC *server, const char *msg, + const char *target, const char *origtarget) +{ + char *nickmode; + + if (IS_IRC_SERVER(server) && target != NULL && + *target == '@' && ischannel(target[1])) { + /* Hybrid 6 feature, send msg to all ops in channel */ + nickmode = channel_get_nickmode(channel_find(server, target+1), + server->nick); + + printformat_module("fe-common/core", server, target+1, + MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | + MSGLEVEL_NO_ACT, + IRCTXT_OWN_MSG_CHANNEL, + server->nick, target, msg, nickmode); + signal_stop(); + } +} + +static void sig_message_irc_op_public(SERVER_REC *server, const char *msg, + const char *nick, const char *address, + const char *target) +{ + char *nickmode, *optarget; + + nickmode = channel_get_nickmode(channel_find(server, target), + server->nick); + + optarget = g_strconcat("@", target, NULL); + printformat_module("fe-common/core", server, target, + MSGLEVEL_PUBLIC | MSGLEVEL_HILIGHT, + IRCTXT_PUBMSG_ME_CHANNEL, + nick, optarget, msg, nickmode); + g_free(optarget); +} + +void fe_irc_messages_init(void) +{ + signal_add("message own_public", (SIGNAL_FUNC) sig_message_own_public); + signal_add("message irc op_public", (SIGNAL_FUNC) sig_message_irc_op_public); +} + +void fe_irc_messages_deinit(void) +{ + signal_remove("message own_public", (SIGNAL_FUNC) sig_message_own_public); + signal_remove("message irc op_public", (SIGNAL_FUNC) sig_message_irc_op_public); +} |