Separate parsing of channel WALLs into a function and clean it up
Channel WALL notices now have to match "[%Wall%/%] *", and have to be for a channel that the client is actually on. Otherwise, they just appear as ordinary NOTICEs.
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
[Changes 1.2.2]
|
[Changes 1.2.2]
|
||||||
|
|
||||||
|
* Tighten up the handling of channel WALLs. (caf)
|
||||||
|
|
||||||
* Don't mangle ANSI sequences in NOTICEs. (caf)
|
* Don't mangle ANSI sequences in NOTICEs. (caf)
|
||||||
|
|
||||||
* Use BitchX.kill in all cases for random /KILL messages, and install a
|
* Use BitchX.kill in all cases for random /KILL messages, and install a
|
||||||
|
|||||||
129
source/notice.c
129
source/notice.c
@@ -649,16 +649,15 @@ done1:
|
|||||||
reset_display_target();
|
reset_display_target();
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_ignore_notice(char *from, char *to, unsigned long type, char *line, char **high)
|
static int check_ignore_notice(char *from, char *to, unsigned long type, char *line, char **high)
|
||||||
{
|
{
|
||||||
int flag;
|
int flag = check_ignore(from, FromUserHost, to, type, line);
|
||||||
switch ((flag = check_ignore(from, FromUserHost, to, type, line)))
|
|
||||||
|
switch (flag)
|
||||||
{
|
{
|
||||||
case IGNORED:
|
case IGNORED:
|
||||||
{
|
|
||||||
doing_notice = 0;
|
doing_notice = 0;
|
||||||
return flag;
|
break;
|
||||||
}
|
|
||||||
case HIGHLIGHTED:
|
case HIGHLIGHTED:
|
||||||
*high = highlight_char;
|
*high = highlight_char;
|
||||||
break;
|
break;
|
||||||
@@ -668,6 +667,60 @@ int flag;
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if a notice is a BitchX /WALL, and if so handle it as such. */
|
||||||
|
static int check_chanwall_notice(const char *from, const char *line, int type)
|
||||||
|
{
|
||||||
|
ChannelList *chan = NULL;
|
||||||
|
char *line_copy;
|
||||||
|
char *newline;
|
||||||
|
char *channel = NULL, *p;
|
||||||
|
|
||||||
|
if (!wild_match("[%Wall%/%] *", line))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
line_copy = m_strdup(line);
|
||||||
|
p = next_arg(line_copy, &newline);
|
||||||
|
|
||||||
|
if ((p = strchr(p, '/')))
|
||||||
|
{
|
||||||
|
p++;
|
||||||
|
if (*p == BOLD_TOG)
|
||||||
|
p++;
|
||||||
|
|
||||||
|
channel = p;
|
||||||
|
|
||||||
|
if ((p = strrchr(channel, ']')))
|
||||||
|
{
|
||||||
|
*p = 0;
|
||||||
|
if (p > channel && *(p-1) == BOLD_TOG)
|
||||||
|
*(p-1) = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel && *channel)
|
||||||
|
chan = lookup_channel(channel, from_server, CHAN_NOUNLINK);
|
||||||
|
|
||||||
|
if (!chan)
|
||||||
|
{
|
||||||
|
new_free(&line_copy);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_display_target(channel, LOG_WALL);
|
||||||
|
|
||||||
|
if (do_hook(type, "%s %s", from, line))
|
||||||
|
{
|
||||||
|
char *s = convert_output_format(fget_string_var(FORMAT_BWALL_FSET), "%s %s %s %s %s", update_clock(GET_TIME), channel, from, FromUserHost, newline);
|
||||||
|
add_to_log(chan->msglog_fp, now, s, logfile_line_mangler);
|
||||||
|
put_it("%s", s);
|
||||||
|
}
|
||||||
|
add_last_type(&last_wall[0], 1, from, FromUserHost, NULL, line);
|
||||||
|
logmsg(LOG_WALL, from, 0, "%s", line);
|
||||||
|
/* addtabkey(from, "wall", 0);*/
|
||||||
|
new_free(&line_copy);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void parse_notice(char *from, char **Args)
|
void parse_notice(char *from, char **Args)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
@@ -675,7 +728,6 @@ void parse_notice(char *from, char **Args)
|
|||||||
*high = empty_string,
|
*high = empty_string,
|
||||||
*target,
|
*target,
|
||||||
*line;
|
*line;
|
||||||
|
|
||||||
NickList *nick = NULL;
|
NickList *nick = NULL;
|
||||||
ChannelList *tmpc = NULL;
|
ChannelList *tmpc = NULL;
|
||||||
|
|
||||||
@@ -696,8 +748,6 @@ void parse_notice(char *from, char **Args)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (is_channel(to))
|
if (is_channel(to))
|
||||||
{
|
{
|
||||||
target = to;
|
target = to;
|
||||||
@@ -739,64 +789,25 @@ void parse_notice(char *from, char **Args)
|
|||||||
goto notice_cleanup;
|
goto notice_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_chanwall_notice(from, line, type))
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
if (wild_match("[*Wall*", line))
|
if (type == PUBLIC_NOTICE_LIST)
|
||||||
{
|
{
|
||||||
char *free_me = stripansi(line);
|
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);
|
||||||
char *newline = free_me;
|
if (do_hook(type, "%s %s %s", from, to, line))
|
||||||
char *channel = NULL, *p, *q;
|
|
||||||
q = p = next_arg(newline, &newline);
|
|
||||||
if ((p = strchr(p, '/')))
|
|
||||||
{
|
|
||||||
p++;
|
|
||||||
if (*p && *p == '\002')
|
|
||||||
p++;
|
|
||||||
channel = m_strdup(p);
|
|
||||||
if ((p = strchr(channel, ']')))
|
|
||||||
*p++ = 0;
|
|
||||||
q = channel;
|
|
||||||
if (*q && q[strlen(q)-1] == '\002')
|
|
||||||
q[strlen(q)-1] = 0;
|
|
||||||
}
|
|
||||||
if (channel && *channel)
|
|
||||||
set_display_target(channel, LOG_WALL);
|
|
||||||
else
|
|
||||||
set_display_target(target, LOG_WALL);
|
|
||||||
if (do_hook(type, "%s %s", from, line))
|
|
||||||
{
|
|
||||||
s = convert_output_format(fget_string_var(FORMAT_BWALL_FSET), "%s %s %s %s %s", update_clock(GET_TIME), q, from, FromUserHost, newline);
|
|
||||||
if (tmpc)
|
|
||||||
add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler);
|
|
||||||
put_it("%s", s);
|
put_it("%s", s);
|
||||||
}
|
|
||||||
add_last_type(&last_wall[0], 1, from, FromUserHost, NULL, line);
|
|
||||||
logmsg(LOG_WALL, from, 0, "%s", line);
|
|
||||||
/* addtabkey(from, "wall", 0);*/
|
|
||||||
new_free(&channel);
|
|
||||||
new_free(&free_me);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (type == PUBLIC_NOTICE_LIST)
|
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))
|
||||||
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);
|
put_it("%s", s);
|
||||||
if (do_hook(type, "%s %s %s", from, to, line))
|
|
||||||
put_it("%s", s);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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))
|
|
||||||
put_it("%s", s);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (tmpc)
|
|
||||||
add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler);
|
|
||||||
logmsg(LOG_NOTICE, from, 0, "%s", line);
|
|
||||||
add_last_type(&last_notice[0], MAX_LAST_MSG, from, FromUserHost, to, line);
|
|
||||||
}
|
}
|
||||||
|
if (tmpc)
|
||||||
|
add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler);
|
||||||
|
logmsg(LOG_NOTICE, from, 0, "%s", line);
|
||||||
|
add_last_type(&last_notice[0], MAX_LAST_MSG, from, FromUserHost, to, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
notice_cleanup:
|
notice_cleanup:
|
||||||
|
|||||||
Reference in New Issue
Block a user