diff options
author | Timo Sirainen <cras@irssi.org> | 2001-01-28 10:16:43 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-01-28 10:16:43 +0000 |
commit | 669c2c18d8a906ea5863cf2dc03878e774902c3f (patch) | |
tree | e997679474550cba3fe145a0ceee58192b4ec03c /src | |
parent | 5e3aa6f07787bd2c2d37eb70afa2b804407be07e (diff) | |
download | irssi-669c2c18d8a906ea5863cf2dc03878e774902c3f.zip |
Removed own_wall msg format, using now the same as @#channel messages.
Added printing of ctcps, notices, actions and /WALLs to
fe-irc-messages.c
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1158 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-common/irc/fe-events.c | 60 | ||||
-rw-r--r-- | src/fe-common/irc/fe-irc-commands.c | 85 | ||||
-rw-r--r-- | src/fe-common/irc/fe-irc-messages.c | 136 | ||||
-rw-r--r-- | src/fe-common/irc/module-formats.c | 1 | ||||
-rw-r--r-- | src/fe-common/irc/module-formats.h | 3 |
5 files changed, 190 insertions, 95 deletions
diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c index 3797acd2..97b62491 100644 --- a/src/fe-common/irc/fe-events.c +++ b/src/fe-common/irc/fe-events.c @@ -70,39 +70,11 @@ static void ctcp_msg_check_action(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr, const char *target) { - void *item; - int level; - g_return_if_fail(data != NULL); - if (g_strncasecmp(data, "ACTION ", 7) != 0) - return; - data += 7; - - level = MSGLEVEL_ACTIONS | - (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS); - if (ignore_check(SERVER(server), nick, addr, target, data, level)) - return; - - if (ischannel(*target)) { - /* channel action */ - item = irc_channel_find(server, target); - - if (window_item_is_active(item)) { - /* message to active channel in window */ - printformat(server, target, level, - IRCTXT_ACTION_PUBLIC, nick, data); - } else { - /* message to not existing/active channel */ - printformat(server, target, level, - IRCTXT_ACTION_PUBLIC_CHANNEL, nick, target, data); - } - } else { - /* private action */ - item = privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_MSGS); - printformat(server, nick, level, - item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY, - nick, addr == NULL ? "" : addr, data); + if (g_strncasecmp(data, "ACTION ", 7) == 0) { + signal_emit("message irc action", 5, + server, data+7, nick, addr, target); } } @@ -110,7 +82,6 @@ static void event_notice(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr) { char *params, *target, *msg; - int op_notice; g_return_if_fail(data != NULL); @@ -121,30 +92,7 @@ static void event_notice(IRC_SERVER_REC *server, const char *data, server->real_address; } - if (addr == NULL) { - /* notice from server */ - if (*msg != 1 && !ignore_check(SERVER(server), nick, "", target, msg, MSGLEVEL_SNOTES)) - printformat(server, target, MSGLEVEL_SNOTES, IRCTXT_NOTICE_SERVER, nick, msg); - } else { - op_notice = *target == '@' && ischannel(target[1]); - if (op_notice) target++; - - if (ignore_check(SERVER(server), nick, addr, ischannel(*target) ? - target : NULL, msg, MSGLEVEL_NOTICES)) - return; - - if (ischannel(*target)) { - /* notice in some channel */ - printformat(server, target, MSGLEVEL_NOTICES, - op_notice ? IRCTXT_NOTICE_PUBLIC_OPS : IRCTXT_NOTICE_PUBLIC, - nick, target, msg); - } else { - /* private notice */ - privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_NOTICES); - printformat(server, nick, MSGLEVEL_NOTICES, IRCTXT_NOTICE_PRIVATE, nick, addr, msg); - } - } - + signal_emit("message irc notice", 5, server, msg, nick, addr, target); g_free(params); } diff --git a/src/fe-common/irc/fe-irc-commands.c b/src/fe-common/irc/fe-irc-commands.c index 8d739c8b..94a7e774 100644 --- a/src/fe-common/irc/fe-irc-commands.c +++ b/src/fe-common/irc/fe-irc-commands.c @@ -41,7 +41,7 @@ #include "keyboard.h" /* SYNTAX: ME <message> */ -static void cmd_me(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) +static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) { g_return_if_fail(data != NULL); @@ -51,11 +51,10 @@ static void cmd_me(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED); - printformat(server, item->name, MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT | - (ischannel(*item->name) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS), - IRCTXT_OWN_ME, server->nick, data); + signal_emit("message irc own_action", 3, server, data, item->name); - irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", item->name, data); + irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", + item->name, data); } /* SYNTAX: ACTION [<target>] <message> */ @@ -68,14 +67,14 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server) if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED); - if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &text)) + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, + &target, &text)) return; if (*target == '\0' || *text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - printformat(server, target, MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT | - (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS), - IRCTXT_OWN_ME, server->nick, text); + signal_emit("message irc own_action", 3, server, text, target); + irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, text); cmd_params_free(free_arg); } @@ -86,18 +85,21 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server) void *free_arg; g_return_if_fail(data != NULL); - if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED); + if (server == NULL || !server->connected) + cmd_return_error(CMDERR_NOT_CONNECTED); - if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &msg)) + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, + &target, &msg)) return; - if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - - if (*target == '@' && ischannel(target[1])) - target++; /* Hybrid 6 feature, send notice to all ops in channel */ + if (*target == '\0' || *msg == '\0') + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - printformat(server, target, MSGLEVEL_NOTICES | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, - IRCTXT_OWN_NOTICE, target, msg); + if (*target == '@' && ischannel(target[1])) { + /* Hybrid 6 feature, send notice to all ops in channel */ + target++; + } + signal_emit("message irc own_notice", 3, server, msg, target); cmd_params_free(free_arg); } @@ -107,11 +109,14 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server) void *free_arg; g_return_if_fail(data != NULL); - if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED); + if (server == NULL || !server->connected) + cmd_return_error(CMDERR_NOT_CONNECTED); - if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, &target, &ctcpcmd, &ctcpdata)) + if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, + &target, &ctcpcmd, &ctcpdata)) return; - if (*target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + if (*target == '\0' || *ctcpcmd == '\0') + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*target == '=') { /* don't handle DCC CTCPs */ @@ -119,37 +124,44 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server) return; } - if (*target == '@' && ischannel(target[1])) - target++; /* Hybrid 6 feature, send ctcp to all ops in channel */ + if (*target == '@' && ischannel(target[1])) { + /* Hybrid 6 feature, send ctcp to all ops in channel */ + target++; + } g_strup(ctcpcmd); - printformat(server, target, MSGLEVEL_CTCPS, IRCTXT_OWN_CTCP, target, ctcpcmd, ctcpdata); + signal_emit("message irc own_ctcp", 4, + server, ctcpcmd, ctcpdata, target); cmd_params_free(free_arg); } static void cmd_nctcp(const char *data, IRC_SERVER_REC *server) { - char *target, *ctcpcmd, *ctcpdata; + char *target, *text; void *free_arg; g_return_if_fail(data != NULL); - if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED); + if (server == NULL || !server->connected) + cmd_return_error(CMDERR_NOT_CONNECTED); - if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, &target, &ctcpcmd, &ctcpdata)) + if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, + &target, &text)) return; - if (*target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - - if (*target == '@' && ischannel(target[1])) - target++; /* Hybrid 6 feature, send notice to all ops in channel */ + if (*target == '\0' || *text == '\0') + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - g_strup(ctcpcmd); - printformat(server, target, MSGLEVEL_NOTICES, IRCTXT_OWN_NOTICE, target, ctcpcmd, ctcpdata); + if (*target == '@' && ischannel(target[1])) { + /* Hybrid 6 feature, send notice to all ops in channel */ + target++; + } + signal_emit("message irc own_notice", 3, server, text, target); cmd_params_free(free_arg); } -static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) +static void cmd_wall(const char *data, IRC_SERVER_REC *server, + WI_ITEM_REC *item) { IRC_CHANNEL_REC *chanrec; char *channame, *msg; @@ -159,14 +171,15 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item if (server == NULL || !server->connected || !IS_IRC_SERVER(server)) cmd_return_error(CMDERR_NOT_CONNECTED); - if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST, item, &channame, &msg)) + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN | + PARAM_FLAG_GETREST, item, &channame, &msg)) return; if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); chanrec = irc_channel_find(server, channame); if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND); - printformat(server, chanrec->name, MSGLEVEL_NOTICES, IRCTXT_OWN_WALL, chanrec->name, msg); + signal_emit("message irc own_wall", 3, server, msg, chanrec->name); cmd_params_free(free_arg); } @@ -338,7 +351,7 @@ static void cmd_topic(const char *data, SERVER_REC *server, WI_ITEM_REC *item) channel = *data != '\0' ? channel_find(server, data) : CHANNEL(item); if (channel == NULL) return; - + printformat(server, channel->name, MSGLEVEL_CRAP, channel->topic == NULL ? IRCTXT_NO_TOPIC : IRCTXT_TOPIC, channel->name, channel->topic); diff --git a/src/fe-common/irc/fe-irc-messages.c b/src/fe-common/irc/fe-irc-messages.c index 8c9707cf..ae1df824 100644 --- a/src/fe-common/irc/fe-irc-messages.c +++ b/src/fe-common/irc/fe-irc-messages.c @@ -22,14 +22,19 @@ #include "signals.h" #include "levels.h" #include "channels.h" +#include "ignore.h" #include "irc.h" +#include "irc-channels.h" #include "../core/module-formats.h" #include "module-formats.h" #include "printtext.h" #include "fe-messages.h" +#include "fe-queries.h" +#include "window-items.h" + static void sig_message_own_public(SERVER_REC *server, const char *msg, const char *target, const char *origtarget) { @@ -50,6 +55,7 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg, } } +/* received msg to all ops in channel */ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg, const char *nick, const char *address, const char *target) @@ -67,6 +73,124 @@ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg, g_free(optarget); } +static void sig_message_own_wall(SERVER_REC *server, const char *msg, + 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_NOHILIGHT | + MSGLEVEL_NO_ACT, + TXT_OWN_MSG_CHANNEL, + server->nick, optarget, msg, nickmode); + g_free(optarget); +} + +static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg, + const char *target) +{ + printformat(server, target, MSGLEVEL_ACTIONS | + (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS) | + MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, + IRCTXT_OWN_ME, server->nick, msg); +} + +static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg, + const char *nick, const char *address, + const char *target) +{ + void *item; + int level; + + level = MSGLEVEL_ACTIONS | + (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS); + + if (ignore_check(SERVER(server), nick, address, target, msg, level)) + return; + + if (ischannel(*target)) { + /* channel action */ + item = irc_channel_find(server, target); + + if (window_item_is_active(item)) { + /* message to active channel in window */ + printformat(server, target, level, + IRCTXT_ACTION_PUBLIC, nick, msg); + } else { + /* message to not existing/active channel */ + printformat(server, target, level, + IRCTXT_ACTION_PUBLIC_CHANNEL, + nick, target, msg); + } + } else { + /* private action */ + item = privmsg_get_query(SERVER(server), nick, FALSE, + MSGLEVEL_MSGS); + printformat(server, nick, MSGLEVEL_ACTIONS | MSGLEVEL_MSGS, + item == NULL ? IRCTXT_ACTION_PRIVATE : + IRCTXT_ACTION_PRIVATE_QUERY, + nick, address == NULL ? "" : address, msg); + } +} + +static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg, + const char *target) +{ + printformat(server, target, MSGLEVEL_NOTICES | + MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, + IRCTXT_OWN_NOTICE, target, msg); +} + +static void sig_message_irc_notice(SERVER_REC *server, const char *msg, + const char *nick, const char *address, + const char *target) +{ + int op_notice; + + if (address == NULL) { + /* notice from server */ + if (!ignore_check(server, nick, "", + target, msg, MSGLEVEL_SNOTES)) { + printformat(server, target, MSGLEVEL_SNOTES, + IRCTXT_NOTICE_SERVER, nick, msg); + } + return; + } + + op_notice = *target == '@' && ischannel(target[1]); + if (op_notice) target++; + + if (ignore_check(server, nick, address, + ischannel(*target) ? target : NULL, + msg, MSGLEVEL_NOTICES)) + return; + + if (ischannel(*target)) { + /* notice in some channel */ + printformat(server, target, MSGLEVEL_NOTICES, + op_notice ? IRCTXT_NOTICE_PUBLIC_OPS : + IRCTXT_NOTICE_PUBLIC, nick, target, msg); + } else { + /* private notice */ + privmsg_get_query(SERVER(server), nick, FALSE, + MSGLEVEL_NOTICES); + printformat(server, nick, MSGLEVEL_NOTICES, + IRCTXT_NOTICE_PRIVATE, nick, address, msg); + } +} + +static void sig_message_own_ctcp(IRC_SERVER_REC *server, const char *cmd, + const char *data, const char *target) +{ + printformat(server, target, MSGLEVEL_CTCPS | + MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, + IRCTXT_OWN_CTCP, target, cmd, data); +} + static void sig_message_irc_ctcp(IRC_SERVER_REC *server, const char *msg, const char *nick, const char *addr, const char *target) @@ -79,6 +203,12 @@ 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); + signal_add("message irc own_wall", (SIGNAL_FUNC) sig_message_own_wall); + signal_add("message irc own_action", (SIGNAL_FUNC) sig_message_own_action); + signal_add("message irc action", (SIGNAL_FUNC) sig_message_irc_action); + signal_add("message irc own_notice", (SIGNAL_FUNC) sig_message_own_notice); + signal_add("message irc notice", (SIGNAL_FUNC) sig_message_irc_notice); + signal_add("message irc own_ctcp", (SIGNAL_FUNC) sig_message_own_ctcp); signal_add("message irc ctcp", (SIGNAL_FUNC) sig_message_irc_ctcp); } @@ -86,5 +216,11 @@ 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); + signal_remove("message irc own_wall", (SIGNAL_FUNC) sig_message_own_wall); + signal_remove("message irc own_action", (SIGNAL_FUNC) sig_message_own_action); + signal_remove("message irc action", (SIGNAL_FUNC) sig_message_irc_action); + signal_remove("message irc own_notice", (SIGNAL_FUNC) sig_message_own_notice); + signal_remove("message irc notice", (SIGNAL_FUNC) sig_message_irc_notice); + signal_remove("message irc own_ctcp", (SIGNAL_FUNC) sig_message_own_ctcp); signal_remove("message irc ctcp", (SIGNAL_FUNC) sig_message_irc_ctcp); } diff --git a/src/fe-common/irc/module-formats.c b/src/fe-common/irc/module-formats.c index cc55f231..acf4fea1 100644 --- a/src/fe-common/irc/module-formats.c +++ b/src/fe-common/irc/module-formats.c @@ -118,7 +118,6 @@ FORMAT_REC fecommon_irc_formats[] = { { "own_notice", "{ownnotice notice $0}$1", 2, { 0, 0 } }, { "own_action", "{ownaction $0}$1", 2, { 0, 0 } }, { "own_ctcp", "{ownctcp ctcp $0}$1 $2", 3, { 0, 0, 0 } }, - { "own_wall", "{ownwall Wall $0}$1", 2, { 0, 0 } }, /* ---- */ { NULL, "Received messages", 0 }, diff --git a/src/fe-common/irc/module-formats.h b/src/fe-common/irc/module-formats.h index 48df0aa2..a6886332 100644 --- a/src/fe-common/irc/module-formats.h +++ b/src/fe-common/irc/module-formats.h @@ -92,8 +92,7 @@ enum { IRCTXT_OWN_NOTICE, IRCTXT_OWN_ME, IRCTXT_OWN_CTCP, - IRCTXT_OWN_WALL, - + IRCTXT_FILL_7, IRCTXT_NOTICE_SERVER, |