1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

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
This commit is contained in:
Timo Sirainen 2001-01-28 10:16:43 +00:00 committed by cras
parent 5e3aa6f077
commit 669c2c18d8
6 changed files with 190 additions and 98 deletions

View File

@ -195,9 +195,6 @@ abstracts = {
ownctcp = "[%r$0%K(%R$1-%K)] "; ownctcp = "[%r$0%K(%R$1-%K)] ";
ctcp = "%g$0-%n"; ctcp = "%g$0-%n";
# wall
ownwall = "[%W$0%K/%c$1-] ";
# wallops # wallops
wallop = "%W$0-%n: "; wallop = "%W$0-%n: ";
wallop_nick = "%n$0-"; wallop_nick = "%n$0-";

View File

@ -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 *nick, const char *addr,
const char *target) const char *target)
{ {
void *item;
int level;
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
if (g_strncasecmp(data, "ACTION ", 7) != 0) if (g_strncasecmp(data, "ACTION ", 7) == 0) {
return; signal_emit("message irc action", 5,
data += 7; server, data+7, nick, addr, target);
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);
} }
} }
@ -110,7 +82,6 @@ static void event_notice(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr) const char *nick, const char *addr)
{ {
char *params, *target, *msg; char *params, *target, *msg;
int op_notice;
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
@ -121,30 +92,7 @@ static void event_notice(IRC_SERVER_REC *server, const char *data,
server->real_address; server->real_address;
} }
if (addr == NULL) { signal_emit("message irc notice", 5, server, msg, nick, addr, target);
/* 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);
}
}
g_free(params); g_free(params);
} }

View File

@ -41,7 +41,7 @@
#include "keyboard.h" #include "keyboard.h"
/* SYNTAX: ME <message> */ /* 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); 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) if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED); cmd_return_error(CMDERR_NOT_CONNECTED);
printformat(server, item->name, MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT | signal_emit("message irc own_action", 3, server, data, item->name);
(ischannel(*item->name) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
IRCTXT_OWN_ME, server->nick, data);
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> */ /* SYNTAX: ACTION [<target>] <message> */
@ -68,14 +67,14 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
if (server == NULL || !server->connected) if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_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; return;
if (*target == '\0' || *text == '\0') if (*target == '\0' || *text == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
printformat(server, target, MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT | signal_emit("message irc own_action", 3, server, text, target);
(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
IRCTXT_OWN_ME, server->nick, text);
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, text); irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, text);
cmd_params_free(free_arg); cmd_params_free(free_arg);
} }
@ -86,18 +85,21 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server)
void *free_arg; void *free_arg;
g_return_if_fail(data != NULL); 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; return;
if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*target == '\0' || *msg == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
if (*target == '@' && ischannel(target[1])) if (*target == '@' && ischannel(target[1])) {
target++; /* Hybrid 6 feature, send notice to all ops in channel */ /* Hybrid 6 feature, send notice to all ops in channel */
target++;
printformat(server, target, MSGLEVEL_NOTICES | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, }
IRCTXT_OWN_NOTICE, target, msg);
signal_emit("message irc own_notice", 3, server, msg, target);
cmd_params_free(free_arg); cmd_params_free(free_arg);
} }
@ -107,11 +109,14 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
void *free_arg; void *free_arg;
g_return_if_fail(data != NULL); 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; 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 == '=') { if (*target == '=') {
/* don't handle DCC CTCPs */ /* don't handle DCC CTCPs */
@ -119,37 +124,44 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
return; return;
} }
if (*target == '@' && ischannel(target[1])) if (*target == '@' && ischannel(target[1])) {
target++; /* Hybrid 6 feature, send ctcp to all ops in channel */ /* Hybrid 6 feature, send ctcp to all ops in channel */
target++;
}
g_strup(ctcpcmd); 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); cmd_params_free(free_arg);
} }
static void cmd_nctcp(const char *data, IRC_SERVER_REC *server) static void cmd_nctcp(const char *data, IRC_SERVER_REC *server)
{ {
char *target, *ctcpcmd, *ctcpdata; char *target, *text;
void *free_arg; void *free_arg;
g_return_if_fail(data != NULL); 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; return;
if (*target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*target == '\0' || *text == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
if (*target == '@' && ischannel(target[1])) if (*target == '@' && ischannel(target[1])) {
target++; /* Hybrid 6 feature, send notice to all ops in channel */ /* Hybrid 6 feature, send notice to all ops in channel */
target++;
g_strup(ctcpcmd); }
printformat(server, target, MSGLEVEL_NOTICES, IRCTXT_OWN_NOTICE, target, ctcpcmd, ctcpdata);
signal_emit("message irc own_notice", 3, server, text, target);
cmd_params_free(free_arg); 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; IRC_CHANNEL_REC *chanrec;
char *channame, *msg; 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)) if (server == NULL || !server->connected || !IS_IRC_SERVER(server))
cmd_return_error(CMDERR_NOT_CONNECTED); 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; return;
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
chanrec = irc_channel_find(server, channame); chanrec = irc_channel_find(server, channame);
if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND); 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); cmd_params_free(free_arg);
} }

View File

@ -22,14 +22,19 @@
#include "signals.h" #include "signals.h"
#include "levels.h" #include "levels.h"
#include "channels.h" #include "channels.h"
#include "ignore.h"
#include "irc.h" #include "irc.h"
#include "irc-channels.h"
#include "../core/module-formats.h" #include "../core/module-formats.h"
#include "module-formats.h" #include "module-formats.h"
#include "printtext.h" #include "printtext.h"
#include "fe-messages.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, static void sig_message_own_public(SERVER_REC *server, const char *msg,
const char *target, const char *origtarget) 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, static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
const char *nick, const char *address, const char *nick, const char *address,
const char *target) const char *target)
@ -67,6 +73,124 @@ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
g_free(optarget); 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, static void sig_message_irc_ctcp(IRC_SERVER_REC *server, const char *msg,
const char *nick, const char *addr, const char *nick, const char *addr,
const char *target) 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 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 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); 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 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 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); signal_remove("message irc ctcp", (SIGNAL_FUNC) sig_message_irc_ctcp);
} }

View File

@ -118,7 +118,6 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "own_notice", "{ownnotice notice $0}$1", 2, { 0, 0 } }, { "own_notice", "{ownnotice notice $0}$1", 2, { 0, 0 } },
{ "own_action", "{ownaction $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_ctcp", "{ownctcp ctcp $0}$1 $2", 3, { 0, 0, 0 } },
{ "own_wall", "{ownwall Wall $0}$1", 2, { 0, 0 } },
/* ---- */ /* ---- */
{ NULL, "Received messages", 0 }, { NULL, "Received messages", 0 },

View File

@ -92,7 +92,6 @@ enum {
IRCTXT_OWN_NOTICE, IRCTXT_OWN_NOTICE,
IRCTXT_OWN_ME, IRCTXT_OWN_ME,
IRCTXT_OWN_CTCP, IRCTXT_OWN_CTCP,
IRCTXT_OWN_WALL,
IRCTXT_FILL_7, IRCTXT_FILL_7,