1
0
Fork 0

add new PUBNOTICES level

separating private notices and channel notices
This commit is contained in:
Ailin Nemui 2022-04-19 10:52:27 +02:00
parent ae5a9283ee
commit 7360944900
12 changed files with 83 additions and 52 deletions

View File

@ -20,9 +20,10 @@
MODES A channel mode is modified.
MSGS Private messages.
NICKS A nickname changes to another nickname.
NOTICES Notices sent from a nickname.
NOTICES Private notices.
PARTS A nickname leaves a channel.
PUBLIC Public messages in a channel.
PUBNOTICES Public notices in a channel.
QUITS A nickname disconnects from IRC.
SNOTES Notices sent from a server.
TOPICS A channel topic is modified.

View File

@ -6,7 +6,7 @@
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
#define IRSSI_ABI_VERSION 46
#define IRSSI_ABI_VERSION 47
#define DEFAULT_SERVER_ADD_PORT 6667
#define DEFAULT_SERVER_ADD_TLS_PORT 6697

View File

@ -23,10 +23,12 @@
/* the order of these levels must match the bits in levels.h */
static const char *levels[] = {
/* clang-format off */
"CRAP",
"MSGS",
"PUBLICS",
"NOTICES",
"PUBNOTICES",
"SNOTES",
"CTCPS",
"ACTIONS",
@ -46,6 +48,7 @@ static const char *levels[] = {
"CLIENTERRORS",
"HILIGHTS",
NULL
/* clang-format on */
};
int level_get(const char *level)

View File

@ -13,26 +13,27 @@ enum {
MSGLEVEL_MSGS = 0x0000002,
MSGLEVEL_PUBLIC = 0x0000004,
MSGLEVEL_NOTICES = 0x0000008,
MSGLEVEL_SNOTES = 0x0000010,
MSGLEVEL_CTCPS = 0x0000020,
MSGLEVEL_ACTIONS = 0x0000040,
MSGLEVEL_JOINS = 0x0000080,
MSGLEVEL_PARTS = 0x0000100,
MSGLEVEL_QUITS = 0x0000200,
MSGLEVEL_KICKS = 0x0000400,
MSGLEVEL_MODES = 0x0000800,
MSGLEVEL_TOPICS = 0x0001000,
MSGLEVEL_WALLOPS = 0x0002000,
MSGLEVEL_INVITES = 0x0004000,
MSGLEVEL_NICKS = 0x0008000,
MSGLEVEL_DCC = 0x0010000,
MSGLEVEL_DCCMSGS = 0x0020000,
MSGLEVEL_CLIENTNOTICE = 0x0040000,
MSGLEVEL_CLIENTCRAP = 0x0080000,
MSGLEVEL_CLIENTERROR = 0x0100000,
MSGLEVEL_HILIGHT = 0x0200000,
MSGLEVEL_PUBNOTICES = 0x0000010,
MSGLEVEL_SNOTES = 0x0000020,
MSGLEVEL_CTCPS = 0x0000040,
MSGLEVEL_ACTIONS = 0x0000080,
MSGLEVEL_JOINS = 0x0000100,
MSGLEVEL_PARTS = 0x0000200,
MSGLEVEL_QUITS = 0x0000400,
MSGLEVEL_KICKS = 0x0000800,
MSGLEVEL_MODES = 0x0001000,
MSGLEVEL_TOPICS = 0x0002000,
MSGLEVEL_WALLOPS = 0x0004000,
MSGLEVEL_INVITES = 0x0008000,
MSGLEVEL_NICKS = 0x0010000,
MSGLEVEL_DCC = 0x0020000,
MSGLEVEL_DCCMSGS = 0x0040000,
MSGLEVEL_CLIENTNOTICE = 0x0080000,
MSGLEVEL_CLIENTCRAP = 0x0100000,
MSGLEVEL_CLIENTERROR = 0x0200000,
MSGLEVEL_HILIGHT = 0x0400000,
MSGLEVEL_ALL = 0x03fffff,
MSGLEVEL_ALL = 0x07fffff,
MSGLEVEL_NOHILIGHT = 0x1000000, /* Don't highlight this message */
MSGLEVEL_NO_ACT = 0x2000000, /* Don't trigger channel activity */

View File

@ -355,7 +355,7 @@ static void read_settings(void)
void fe_queries_init(void)
{
settings_add_level("lookandfeel", "autocreate_query_level", "MSGS DCCMSGS");
settings_add_level("lookandfeel", "autocreate_query_level", "MSGS DCCMSGS NOTICES");
settings_add_bool("lookandfeel", "autocreate_own_query", TRUE);
settings_add_time("lookandfeel", "autoclose_query", "0");

View File

@ -921,10 +921,10 @@ char *format_add_lineend(const char *text, const char *linestart)
#define LINE_START_IRSSI_LEVEL \
(MSGLEVEL_CLIENTERROR | MSGLEVEL_CLIENTNOTICE)
#define NOT_LINE_START_LEVEL \
(MSGLEVEL_NEVER | MSGLEVEL_LASTLOG | MSGLEVEL_CLIENTCRAP | \
MSGLEVEL_MSGS | MSGLEVEL_PUBLIC | MSGLEVEL_DCC | MSGLEVEL_DCCMSGS | \
MSGLEVEL_ACTIONS | MSGLEVEL_NOTICES | MSGLEVEL_SNOTES | MSGLEVEL_CTCPS)
#define NOT_LINE_START_LEVEL \
(MSGLEVEL_NEVER | MSGLEVEL_LASTLOG | MSGLEVEL_CLIENTCRAP | MSGLEVEL_MSGS | \
MSGLEVEL_PUBLIC | MSGLEVEL_DCC | MSGLEVEL_DCCMSGS | MSGLEVEL_ACTIONS | MSGLEVEL_NOTICES | \
MSGLEVEL_PUBNOTICES | MSGLEVEL_SNOTES | MSGLEVEL_CTCPS)
/* return the "-!- " text at the start of the line */
char *format_get_level_tag(THEME_REC *theme, TEXT_DEST_REC *dest)

View File

@ -143,7 +143,7 @@ void window_activity_init(void)
{
settings_add_str("lookandfeel", "activity_hide_targets", "");
settings_add_level("lookandfeel", "activity_hide_level", "");
settings_add_level("lookandfeel", "activity_msg_level", "PUBLIC");
settings_add_level("lookandfeel", "activity_msg_level", "PUBLIC NOTICES");
settings_add_level("lookandfeel", "activity_hilight_level", "MSGS DCCMSGS");
signal_window_hilight_check = signal_get_uniq_id("window hilight check");

View File

@ -269,13 +269,22 @@ static char *notice_channel_context(SERVER_REC *server, const char *msg)
static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg, const char *target)
{
char *channel;
gboolean is_public;
const char *cleantarget;
char *context_channel;
cleantarget = fe_channel_skip_prefix(server, target);
is_public = server_ischannel(SERVER(server), cleantarget);
/* check if this is a cnotice */
channel = notice_channel_context((SERVER_REC *) server, msg);
printformat(server, channel != NULL ? channel : fe_channel_skip_prefix(server, target),
MSGLEVEL_NOTICES | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, IRCTXT_OWN_NOTICE,
target, msg);
g_free(channel);
context_channel = is_public ? NULL : notice_channel_context((SERVER_REC *) server, msg);
printformat(
server, context_channel != NULL ? context_channel : cleantarget,
(is_public || context_channel != NULL ? MSGLEVEL_PUBNOTICES : MSGLEVEL_NOTICES) |
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
IRCTXT_OWN_NOTICE, target, msg);
g_free(context_channel);
}
static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
@ -283,7 +292,9 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
const char *target)
{
const char *oldtarget;
int level = MSGLEVEL_NOTICES;
char *context_channel;
int level;
gboolean is_public;
oldtarget = target;
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
@ -299,29 +310,32 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
return;
}
if (ignore_check_plus(server, nick, address,
server_ischannel(SERVER(server), target) ? target : NULL,
msg, &level, TRUE))
is_public = server_ischannel(SERVER(server), target);
/* check if this is a cnotice */
context_channel = is_public ? NULL : notice_channel_context(server, msg);
level = (is_public || context_channel != NULL) ? MSGLEVEL_PUBNOTICES : MSGLEVEL_NOTICES;
if (ignore_check_plus(server, nick, address, is_public ? target : context_channel, msg,
&level, TRUE)) {
g_free(context_channel);
return;
}
if (server_ischannel(SERVER(server), target)) {
if (is_public) {
/* notice in some channel */
printformat(server, target, level,
IRCTXT_NOTICE_PUBLIC, nick, oldtarget, msg);
char *nickmode;
nickmode = channel_get_nickmode(channel_find(server, target), nick);
printformat(server, target, level, IRCTXT_NOTICE_PUBLIC, nick, oldtarget, msg,
nickmode);
} else {
char *channel;
/* check if this is a cnotice */
channel = notice_channel_context(server, msg);
if (channel == NULL) {
if (context_channel == NULL) {
/* private notice */
privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_NOTICES);
}
printformat(server, channel == NULL ? nick : channel, level, IRCTXT_NOTICE_PRIVATE,
nick, address, msg);
g_free(channel);
printformat(server, context_channel == NULL ? nick : context_channel, level,
IRCTXT_NOTICE_PRIVATE, nick, address, msg);
}
g_free(context_channel);
}
static void sig_message_own_ctcp(IRC_SERVER_REC *server, const char *cmd,

View File

@ -137,8 +137,8 @@ FORMAT_REC fecommon_irc_formats[] = {
{ NULL, "Received messages", 0 },
{ "notice_server", "{servernotice $0}$1", 2, { 0, 0 } },
{ "notice_public", "{notice $0{pubnotice_channel $1}}$2", 3, { 0, 0, 0 } },
{ "notice_private", "{notice $0{pvtnotice_host $1}}$2", 3, { 0, 0, 0 } },
{ "notice_public", "{pubnotice $3 $0}$2", 4, { 0, 0, 0, 0 } },
{ "notice_private", "{notice $0}$2", 3, { 0, 0, 0 } },
{ "action_private", "{pvtaction $0}$2", 3, { 0, 0, 0 } },
{ "action_private_query", "{pvtaction_query $0}$2", 3, { 0, 0, 0 } },
{ "action_public", "{pubaction $0}$1", 2, { 0, 0 } },

View File

@ -27,7 +27,11 @@ executable('irssi',
'textbuffer-view.c',
'textbuffer.c',
)
+ [ irssi_version_h ],
+ [
irssi_version_h,
default_config_h,
default_theme_h,
],
include_directories : rootinc,
implicit_include_directories : false,
export_dynamic : true,

View File

@ -322,6 +322,13 @@ CODE:
OUTPUT:
RETVAL
int
MSGLEVEL_PUBNOTICES()
CODE:
RETVAL = MSGLEVEL_PUBNOTICES;
OUTPUT:
RETVAL
int
MSGLEVEL_SNOTES()
CODE:

View File

@ -202,6 +202,7 @@ abstracts = {
# notices
ownnotice = "[%r$0%K(%R$1-%K)]%n ";
notice = "%K-%M$*%K-%n ";
pubnotice = "%K-%M$0$1-%K-%n %|";
pubnotice_channel = "%K:%m$*";
pvtnotice_host = "%K(%m$*%K)";
servernotice = "%g!$*%n ";