Default event handler now prints the server name where it received the

event, unless it's the server we're connected to. /FORMAT default_event can
be used to modify where/if the server name is printed.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2409 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-02-10 10:51:14 +00:00 committed by cras
commit 9a3af7072a
3 changed files with 34 additions and 17 deletions

View file

@ -33,7 +33,8 @@
#include "printtext.h" #include "printtext.h"
#include "fe-channels.h" #include "fe-channels.h"
static void event_received(IRC_SERVER_REC *server, const char *data); static void event_received(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr);
static char *last_away_nick = NULL; static char *last_away_nick = NULL;
static char *last_away_msg = NULL; static char *last_away_msg = NULL;
@ -398,7 +399,8 @@ static void event_whois_oper(IRC_SERVER_REC *server, const char *data)
g_free(params); g_free(params);
} }
static void event_whois_registered(IRC_SERVER_REC *server, const char *data) static void event_whois_registered(IRC_SERVER_REC *server, const char *data,
const char *orignick, const char *addr)
{ {
char *params, *nick, *txt_identified; char *params, *nick, *txt_identified;
@ -410,7 +412,7 @@ static void event_whois_registered(IRC_SERVER_REC *server, const char *data)
IRCTXT_WHOIS_REGISTERED, nick); IRCTXT_WHOIS_REGISTERED, nick);
} else { } else {
/* or /USERIP reply in undernet.. */ /* or /USERIP reply in undernet.. */
event_received(server, data); event_received(server, data, orignick, addr);
} }
g_free(params); g_free(params);
} }
@ -440,7 +442,8 @@ static void event_whois_modes(IRC_SERVER_REC *server, const char *data)
g_free(params); g_free(params);
} }
static void event_whois_realhost(IRC_SERVER_REC *server, const char *data) static void event_whois_realhost(IRC_SERVER_REC *server, const char *data,
const char *orignick, const char *addr)
{ {
char *params, *nick, *txt_real, *txt_hostname, *hostname; char *params, *nick, *txt_real, *txt_hostname, *hostname;
@ -464,7 +467,7 @@ static void event_whois_realhost(IRC_SERVER_REC *server, const char *data)
IRCTXT_WHOIS_REALHOST, nick, hostname, ""); IRCTXT_WHOIS_REALHOST, nick, hostname, "");
} else { } else {
/* OPN's dancer uses for end of /MAP */ /* OPN's dancer uses for end of /MAP */
event_received(server, data); event_received(server, data, orignick, addr);
} }
g_free(params); g_free(params);
} }
@ -482,7 +485,8 @@ static void event_whois_usermode326(IRC_SERVER_REC *server, const char *data)
g_free(params); g_free(params);
} }
static void event_whois_realhost327(IRC_SERVER_REC *server, const char *data) static void event_whois_realhost327(IRC_SERVER_REC *server, const char *data,
const char *orignick, const char *addr)
{ {
char *params, *nick, *hostname, *ip, *text; char *params, *nick, *hostname, *ip, *text;
@ -494,12 +498,13 @@ static void event_whois_realhost327(IRC_SERVER_REC *server, const char *data)
printformat(server, nick, MSGLEVEL_CRAP, printformat(server, nick, MSGLEVEL_CRAP,
IRCTXT_WHOIS_REALHOST, nick, hostname, ip); IRCTXT_WHOIS_REALHOST, nick, hostname, ip);
} else { } else {
event_received(server, data); event_received(server, data, orignick, addr);
} }
g_free(params); g_free(params);
} }
static void event_whois_usermode(IRC_SERVER_REC *server, const char *data) static void event_whois_usermode(IRC_SERVER_REC *server, const char *data,
const char *orignick, const char *addr)
{ {
char *params, *txt_usermodes, *nick, *usermode; char *params, *txt_usermodes, *nick, *usermode;
@ -515,7 +520,7 @@ static void event_whois_usermode(IRC_SERVER_REC *server, const char *data)
} else { } else {
/* some servers use this as motd too.. /* some servers use this as motd too..
and OPN's dancer for /MAP */ and OPN's dancer for /MAP */
event_received(server, data); event_received(server, data, orignick, addr);
} }
g_free(params); g_free(params);
} }
@ -617,7 +622,8 @@ static void event_end_of_whowas(IRC_SERVER_REC *server, const char *data)
g_free(params); g_free(params);
} }
static void event_target_unavailable(IRC_SERVER_REC *server, const char *data) static void event_target_unavailable(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{ {
IRC_CHANNEL_REC *chanrec; IRC_CHANNEL_REC *chanrec;
char *params, *target; char *params, *target;
@ -633,7 +639,7 @@ static void event_target_unavailable(IRC_SERVER_REC *server, const char *data)
chanrec = irc_channel_find(server, target); chanrec = irc_channel_find(server, target);
if (chanrec != NULL && chanrec->joined) { if (chanrec != NULL && chanrec->joined) {
/* dalnet - can't change nick while being banned */ /* dalnet - can't change nick while being banned */
event_received(server, data); event_received(server, data, nick, addr);
} else { } else {
/* channel is unavailable. */ /* channel is unavailable. */
printformat(server, NULL, MSGLEVEL_CRAP, printformat(server, NULL, MSGLEVEL_CRAP,
@ -750,14 +756,16 @@ static void event_not_chanop(IRC_SERVER_REC *server, const char *data)
g_free(params); g_free(params);
} }
static void event_numeric(IRC_SERVER_REC *server, const char *data) static void event_numeric(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{ {
data = strchr(data, ' '); data = strchr(data, ' ');
if (data != NULL) if (data != NULL)
event_received(server, data+1); event_received(server, data+1, nick, addr);
} }
static void event_received(IRC_SERVER_REC *server, const char *data) static void event_received(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{ {
char *args, *ptr; char *args, *ptr;
@ -780,11 +788,18 @@ static void event_received(IRC_SERVER_REC *server, const char *data)
g_memmove(ptr+1, ptr+2, strlen(ptr+1)); g_memmove(ptr+1, ptr+2, strlen(ptr+1));
} }
printtext(server, NULL, MSGLEVEL_CRAP, "%s", args); if (nick == NULL || server->real_address == NULL ||
strcmp(nick, server->real_address) == 0)
printtext(server, NULL, MSGLEVEL_CRAP, args);
else {
printformat(server, NULL, MSGLEVEL_CRAP,
IRCTXT_DEFAULT_EVENT, nick, args);
}
g_free(args); g_free(args);
} }
static void event_motd(IRC_SERVER_REC *server, const char *data) static void event_motd(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{ {
/* don't ignore motd anymore after 3 seconds of connection time - /* don't ignore motd anymore after 3 seconds of connection time -
we might have called /MOTD */ we might have called /MOTD */
@ -792,7 +807,7 @@ static void event_motd(IRC_SERVER_REC *server, const char *data)
time(NULL)-3 <= server->real_connect_time) time(NULL)-3 <= server->real_connect_time)
return; return;
event_received(server, data); event_received(server, data, nick, addr);
} }
static void sig_empty(void) static void sig_empty(void)

View file

@ -152,6 +152,7 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "error", "{error ERROR} $0", 1, { 0 } }, { "error", "{error ERROR} $0", 1, { 0 } },
{ "unknown_mode", "Unknown mode character $0", 1, { 0 } }, { "unknown_mode", "Unknown mode character $0", 1, { 0 } },
{ "not_chanop", "You're not channel operator in {channel $0}", 1, { 0 } }, { "not_chanop", "You're not channel operator in {channel $0}", 1, { 0 } },
{ "default_event", "[$0] $1", 2, { 0, 0 } },
/* ---- */ /* ---- */
{ NULL, "Misc", 0 }, { NULL, "Misc", 0 },

View file

@ -123,6 +123,7 @@ enum {
IRCTXT_ERROR, IRCTXT_ERROR,
IRCTXT_UNKNOWN_MODE, IRCTXT_UNKNOWN_MODE,
IRCTXT_NOT_CHANOP, IRCTXT_NOT_CHANOP,
IRCTXT_DEFAULT_EVENT,
IRCTXT_FILL_11, IRCTXT_FILL_11,