Add /on NOTICE_GROUP and /fset NOTICE_GROUP analogous to MSG_GROUP

This hook and format are used for NOTICEs where the destination isn't
a channel and isn't yourself - eg. global targets like $$*.org.  This was
already the case for PRIVMSGs (using the MSG_GROUP hook and format).

Previously these were being routed like a normal NOTICE, and those don't
display the target, so it looked exactly like a private NOTICE to you.

This will also catch server notices sent before you're registered.
This commit is contained in:
Kevin Easton
2016-03-31 23:55:14 +11:00
parent 05eb8d946f
commit b1277f75d4
7 changed files with 59 additions and 22 deletions

View File

@@ -1,5 +1,7 @@
[Changes 1.2.2]
* Add /on NOTICE_GROUP and /fset NOTICE_GROUP analogous to MSG_GROUP. (caf)
* Add configure check for <sys/sockio.h>. (caf)
* Improve /WINDOW DESCRIBE output a little. (caf)

View File

@@ -139,7 +139,8 @@
#define DEFAULT_FORMAT_IGNORE_NOTICE_FSET "%K-%P$2%K(%p$3%K)-%n $4-"
#define DEFAULT_FORMAT_IGNORE_WALL_FSET "%K%P$1%n $2-"
/* Done MSG */
#define DEFAULT_FORMAT_MSG_GROUP_FSET "%K-%P$1%K:%p$3%K-%n $4-"
#define DEFAULT_FORMAT_MSG_GROUP_FSET "%K-%P$1%K:%p$2%K-%n $3-"
#define DEFAULT_FORMAT_NOTICE_GROUP_FSET "%K=%P$1%K:%p$2%K=%n $3-"
/* Done NAMES */
#define DEFAULT_FORMAT_NAMES_BANNER_FSET "$G "
@@ -570,6 +571,7 @@
#define DEFAULT_FORMAT_IGNORE_NOTICE_FSET "%K-%P$2%K(%p$3%K)-%n $4-"
#define DEFAULT_FORMAT_IGNORE_WALL_FSET "%K%P$1%n $2-"
#define DEFAULT_FORMAT_MSG_GROUP_FSET "%K-%P$1%K:%p$2%K-%n $3-"
#define DEFAULT_FORMAT_NOTICE_GROUP_FSET "%K=%P$1%K:%p$2%K=%n $3-"
#define DEFAULT_FORMAT_NAMES_FSET ansi?"$G %K[%GUsers%K(%g$1%K:%g$2%K/%g$3%K)]%c $4":"$G [Users($1:$2/$3)] $4"
#define DEFAULT_FORMAT_NAMES_BOT_FSET ansi?"$G %K[%GBots%K(%g$1%K:%g$2%K/%g$3%K)]%c $4":"$G [Bots($1:$2/$3)] $4"

View File

@@ -260,6 +260,7 @@ FORMAT_NICK_MSG_FSET,
FORMAT_NONICK_FSET,
FORMAT_NOTE_FSET,
FORMAT_NOTICE_FSET,
FORMAT_NOTICE_GROUP_FSET,
FORMAT_NOTIFY_OFF_FSET,
FORMAT_NOTIFY_ON_FSET,
FORMAT_NOTIFY_SIGNOFF_FSET,

View File

@@ -90,6 +90,7 @@ enum HOOK_TYPES {
NICKNAME_LIST,
NOTE_LIST,
NOTICE_LIST,
NOTICE_GROUP_LIST,
NOTIFY_LIST,
NOTIFY_HEADER_LIST,
NOTIFY_SIGNOFF_LIST,

View File

@@ -141,6 +141,7 @@ IrcVariable fset_array[] =
{ "NONICK", 0,STR_TYPE_VAR, 0, NULL, NULL, 0, 0},
{ "NOTE", 0,STR_TYPE_VAR, 0, NULL, NULL, 0, 0},
{ "NOTICE", 0,STR_TYPE_VAR, 0, NULL, NULL, 0, 0},
{ "NOTICE_GROUP", 0,STR_TYPE_VAR, 0, NULL, NULL, 0, 0},
{ "NOTIFY_OFF", 0,STR_TYPE_VAR, 0, NULL, NULL, 0, 0},
{ "NOTIFY_ON", 0,STR_TYPE_VAR, 0, NULL, NULL, 0, 0},
{ "NOTIFY_SIGNOFF", 0,STR_TYPE_VAR, 0, NULL, NULL, 0, 0},
@@ -657,6 +658,7 @@ void create_fsets(Window *win, int ansi)
fset_string_var(FORMAT_NONICK_FSET, DEFAULT_FORMAT_NONICK_FSET);
fset_string_var(FORMAT_NOTE_FSET, DEFAULT_FORMAT_NOTE_FSET);
fset_string_var(FORMAT_NOTICE_FSET, DEFAULT_FORMAT_NOTICE_FSET);
fset_string_var(FORMAT_NOTICE_GROUP_FSET, DEFAULT_FORMAT_NOTICE_GROUP_FSET);
fset_string_var(FORMAT_REL_FSET, DEFAULT_FORMAT_REL_FSET);
fset_string_var(FORMAT_RELN_FSET, DEFAULT_FORMAT_RELN_FSET);
fset_string_var(FORMAT_RELM_FSET, DEFAULT_FORMAT_RELM_FSET);

View File

@@ -153,6 +153,7 @@ HookFunc hook_functions[] =
{ "NICKNAME", NULL, 2, 0, 0 },
{ "NOTE", NULL, 3, 0, 0 },
{ "NOTICE", NULL, 2, 0, 0 },
{ "NOTICE_GROUP", NULL, 3, 0, 0 },
{ "NOTIFY", NULL, 2, 0, 0 },
{ "NOTIFY_HEADER", NULL, 2, 0, 0 },
{ "NOTIFY_SIGNOFF", NULL, 1, 0, 0 },

View File

@@ -723,12 +723,14 @@ static int check_chanwall_notice(const char *from, const char *line, int type)
void parse_notice(char *from, char **Args)
{
int type;
int list_type;
unsigned long ignore_type = IGNORE_NOTICES;
unsigned long log_type = LOG_NOTICE;
int flood_type = NOTICE_FLOOD;
char *to,
*high = empty_string,
*target,
*line;
NickList *nick = NULL;
ChannelList *tmpc = NULL;
PasteArgs(Args, 1);
@@ -751,28 +753,40 @@ void parse_notice(char *from, char **Args)
if (is_channel(to))
{
target = to;
type = PUBLIC_NOTICE_LIST;
list_type = PUBLIC_NOTICE_LIST;
if ((tmpc = lookup_channel(to, from_server, CHAN_NOUNLINK)))
nick = find_nicklist_in_channellist(from, tmpc, 0);
{
NickList *nick = find_nicklist_in_channellist(from, tmpc, 0);
update_stats(NOTICELIST, nick, tmpc, 0);
}
}
else
{
target = from;
type = NOTICE_LIST;
if (my_stricmp(to, get_server_nickname(from_server)))
{
/* A NOTICE to a global destination like $$*.org */
log_type = LOG_WALL;
ignore_type = IGNORE_WALLS;
list_type = NOTICE_GROUP_LIST;
flood_type = WALL_FLOOD;
}
else
{
list_type = NOTICE_LIST;
}
}
update_stats(NOTICELIST, nick, tmpc, 0);
set_display_target(target, LOG_NOTICE);
set_display_target(target, log_type);
doing_notice = 1;
if ((check_ignore_notice(from, to, IGNORE_NOTICES, line, &high) == IGNORED))
if ((check_ignore_notice(from, to, ignore_type, line, &high) == IGNORED))
goto notice_cleanup;
if (!check_flooding(from, NOTICE_FLOOD, line, NULL))
if (!check_flooding(from, flood_type, line, NULL))
goto notice_cleanup;
if (!strchr(from, '.'))
if (!strchr(from, '.') && list_type != NOTICE_GROUP_LIST)
{
notify_mark(from, FromUserHost, 1, 0);
line = do_notice_ctcp(from, to, line);
@@ -789,29 +803,43 @@ void parse_notice(char *from, char **Args)
goto notice_cleanup;
}
if (!check_chanwall_notice(from, line, type))
if (!check_chanwall_notice(from, line, list_type))
{
char *s;
if (type == PUBLIC_NOTICE_LIST)
switch (list_type)
{
case PUBLIC_NOTICE_LIST:
s = convert_output_format(fget_string_var(check_auto_reply(line)?FORMAT_PUBLIC_NOTICE_AR_FSET:FORMAT_PUBLIC_NOTICE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, to, line);
if (do_hook(type, "%s %s %s", from, to, line))
put_it("%s", s);
}
else
{
break;
case NOTICE_GROUP_LIST:
s = convert_output_format(fget_string_var(FORMAT_NOTICE_GROUP_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, line);
break;
default:
s = convert_output_format(fget_string_var(FORMAT_NOTICE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, line);
if (do_hook(type, "%s %s", from, line))
}
switch (list_type)
{
case PUBLIC_NOTICE_LIST:
case NOTICE_GROUP_LIST:
if (do_hook(list_type, "%s %s %s", from, to, line))
put_it("%s", s);
break;
default:
if (do_hook(list_type, "%s %s", from, line))
put_it("%s", s);
}
if (tmpc)
add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler);
logmsg(LOG_NOTICE, from, 0, "%s", line);
logmsg(log_type, from, 0, "%s", line);
add_last_type(&last_notice[0], MAX_LAST_MSG, from, FromUserHost, to, line);
}
notice_cleanup:
if (beep_on_level & LOG_NOTICE)
if (beep_on_level & log_type)
beep_em(1);
reset_display_target();
doing_notice = 0;