From 2db9dfbb4604fc528295021fb7cf85cfcdcb9201 Mon Sep 17 00:00:00 2001 From: David Schultz Date: Sun, 26 Mar 2023 16:34:24 -0500 Subject: [PATCH 1/8] properly format listmodes and their timestamps --- src/fe-common/irc/fe-events-numeric.c | 52 ++++++++++++++++++--------- src/fe-common/irc/module-formats.c | 8 +++-- src/fe-common/irc/module-formats.h | 2 ++ 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c index 34ba3fe7..0051d3bf 100644 --- a/src/fe-common/irc/fe-events-numeric.c +++ b/src/fe-common/irc/fe-events-numeric.c @@ -143,15 +143,13 @@ static void event_ban_list(IRC_SERVER_REC *server, const char *data) IRC_CHANNEL_REC *chanrec; BAN_REC *banrec; const char *channel; - char *params, *ban, *setby, *tims; - long secs; + char *params, *ban, *setby, *tims, *timestr; g_return_if_fail(data != NULL); params = event_get_params(data, 5, NULL, &channel, &ban, &setby, &tims); - secs = *tims == '\0' ? 0 : - (long) (time(NULL) - atol(tims)); + timestr = my_asctime((time_t) atol(tims)); chanrec = irc_channel_find(server, channel); banrec = chanrec == NULL ? NULL : banlist_find(chanrec->banlist, ban); @@ -160,29 +158,49 @@ static void event_ban_list(IRC_SERVER_REC *server, const char *data) printformat(server, channel, MSGLEVEL_CRAP, *setby == '\0' ? IRCTXT_BANLIST : IRCTXT_BANLIST_LONG, banrec == NULL ? 0 : g_slist_index(chanrec->banlist, banrec)+1, - channel, ban, setby, secs); + channel, ban, setby, timestr); + g_free(timestr); g_free(params); } static void event_eban_list(IRC_SERVER_REC *server, const char *data) { const char *channel; - char *params, *ban, *setby, *tims; - long secs; + char *params, *ban, *setby, *tims, *timestr; g_return_if_fail(data != NULL); params = event_get_params(data, 5, NULL, &channel, &ban, &setby, &tims); - secs = *tims == '\0' ? 0 : - (long) (time(NULL) - atol(tims)); + timestr = my_asctime((time_t) atol(tims)); channel = get_visible_target(server, channel); printformat(server, channel, MSGLEVEL_CRAP, *setby == '\0' ? IRCTXT_EBANLIST : IRCTXT_EBANLIST_LONG, - channel, ban, setby, secs); + channel, ban, setby, timestr); + g_free(timestr); + g_free(params); +} + +static void event_quiet_list(IRC_SERVER_REC *server, const char *data) +{ + const char *channel; + char *params, *ban, *setby, *tims, *timestr; + + g_return_if_fail(data != NULL); + + params = event_get_params(data, 6, NULL, &channel, + NULL, &ban, &setby, &tims); + timestr = my_asctime((time_t) atol(tims)); + + channel = get_visible_target(server, channel); + printformat(server, channel, MSGLEVEL_CRAP, + *setby == '\0' ? IRCTXT_QUIETLIST : IRCTXT_QUIETLIST_LONG, + channel, ban, setby, timestr); + + g_free(timestr); g_free(params); } @@ -214,20 +232,20 @@ static void event_accept_list(IRC_SERVER_REC *server, const char *data) static void event_invite_list(IRC_SERVER_REC *server, const char *data) { const char *channel; - char *params, *invite, *setby, *tims; - long secs; + char *params, *invite, *setby, *tims, *timestr; g_return_if_fail(data != NULL); params = event_get_params(data, 5, NULL, &channel, &invite, &setby, &tims); - secs = *tims == '\0' ? 0 : - (long) (time(NULL) - atol(tims)); + timestr = my_asctime((time_t) atol(tims)); channel = get_visible_target(server, channel); printformat(server, channel, MSGLEVEL_CRAP, *setby == '\0' ? IRCTXT_INVITELIST : IRCTXT_INVITELIST_LONG, - channel, invite, setby, secs); + channel, invite, setby, timestr); + + g_free(timestr); g_free(params); } @@ -727,6 +745,7 @@ void fe_events_numeric_init(void) signal_add("event 281", (SIGNAL_FUNC) event_accept_list); signal_add("event 367", (SIGNAL_FUNC) event_ban_list); signal_add("event 348", (SIGNAL_FUNC) event_eban_list); + signal_add("event 728", (SIGNAL_FUNC) event_quiet_list); signal_add("event 346", (SIGNAL_FUNC) event_invite_list); signal_add("event 433", (SIGNAL_FUNC) event_nick_in_use); signal_add("event 332", (SIGNAL_FUNC) event_topic_get); @@ -804,7 +823,6 @@ void fe_events_numeric_init(void) signal_add("event 506", (SIGNAL_FUNC) event_target_received); /* cannot send (+R) */ signal_add("event 716", (SIGNAL_FUNC) event_target_received); /* cannot /msg (+g) */ signal_add("event 717", (SIGNAL_FUNC) event_target_received); /* +g notified */ - signal_add("event 728", (SIGNAL_FUNC) event_target_received); /* quiet (or other) list */ signal_add("event 729", (SIGNAL_FUNC) event_target_received); /* end of quiet (or other) list */ /* clang-format on */ } @@ -825,6 +843,7 @@ void fe_events_numeric_deinit(void) signal_remove("event 281", (SIGNAL_FUNC) event_accept_list); signal_remove("event 367", (SIGNAL_FUNC) event_ban_list); signal_remove("event 348", (SIGNAL_FUNC) event_eban_list); + signal_remove("event 728", (SIGNAL_FUNC) event_quiet_list); signal_remove("event 346", (SIGNAL_FUNC) event_invite_list); signal_remove("event 433", (SIGNAL_FUNC) event_nick_in_use); signal_remove("event 332", (SIGNAL_FUNC) event_topic_get); @@ -898,6 +917,5 @@ void fe_events_numeric_deinit(void) signal_remove("event 506", (SIGNAL_FUNC) event_target_received); signal_remove("event 716", (SIGNAL_FUNC) event_target_received); signal_remove("event 717", (SIGNAL_FUNC) event_target_received); - signal_remove("event 728", (SIGNAL_FUNC) event_target_received); signal_remove("event 729", (SIGNAL_FUNC) event_target_received); } diff --git a/src/fe-common/irc/module-formats.c b/src/fe-common/irc/module-formats.c index 9432c5f9..2cd87e04 100644 --- a/src/fe-common/irc/module-formats.c +++ b/src/fe-common/irc/module-formats.c @@ -81,12 +81,14 @@ FORMAT_REC fecommon_irc_formats[] = { { "bantype", "Ban type changed to {channel $0}", 1, { 0 } }, { "no_bans", "No bans in channel {channel $0}", 1, { 0 } }, { "banlist", "$0 - {channel $1}: ban {ban $2}", 3, { 1, 0, 0 } }, - { "banlist_long", "$0 - {channel $1}: ban {ban $2} {comment by {nick $3}, $4 secs ago}", 5, { 1, 0, 0, 0, 1 } }, + { "banlist_long", "$0 - {channel $1}: ban {ban $2} {comment by {nick $3}, on $4}", 5, { 1, 0, 0, 0, 0 } }, + { "quietlist", "{channel $0}: quiet {ban $1}", 2, { 0, 0 } }, + { "quietlist_long", "{channel $0}: quiet {ban $1} {comment by {nick $2}, on $3}", 4, { 0, 0, 0, 0 } }, { "ebanlist", "{channel $0}: ban exception {ban $1}", 2, { 0, 0 } }, - { "ebanlist_long", "{channel $0}: ban exception {ban $1} {comment by {nick $2}, $3 secs ago}", 4, { 0, 0, 0, 1 } }, + { "ebanlist_long", "{channel $0}: ban exception {ban $1} {comment by {nick $2}, on $3}", 4, { 0, 0, 0, 0 } }, { "no_invitelist", "Invite list is empty in channel {channel $0}", 1, { 0 } }, { "invitelist", "{channel $0}: invite {ban $1}", 2, { 0, 0 } }, - { "invitelist_long", "{channel $0}: invite {ban $1} {comment by {nick $2}, $3 secs ago}", 4, { 0, 0, 0, 1 } }, + { "invitelist_long", "{channel $0}: invite {ban $1} {comment by {nick $2}, on $3}", 4, { 0, 0, 0, 0 } }, { "no_such_channel", "{channel $0}: No such channel", 1, { 0 } }, { "channel_synced", "Join to {channel $0} was synced in {hilight $1} secs", 2, { 0, 2 } }, { "server_help_start", "$1", 2, { 0, 0 } }, diff --git a/src/fe-common/irc/module-formats.h b/src/fe-common/irc/module-formats.h index a9d29cb0..722f8d40 100644 --- a/src/fe-common/irc/module-formats.h +++ b/src/fe-common/irc/module-formats.h @@ -59,6 +59,8 @@ enum { IRCTXT_NO_BANS, IRCTXT_BANLIST, IRCTXT_BANLIST_LONG, + IRCTXT_QUIETLIST, + IRCTXT_QUIETLIST_LONG, IRCTXT_EBANLIST, IRCTXT_EBANLIST_LONG, IRCTXT_NO_INVITELIST, From 556f580f672bd9587475cef737209699189120c7 Mon Sep 17 00:00:00 2001 From: David Schultz Date: Sun, 26 Mar 2023 19:27:48 -0500 Subject: [PATCH 2/8] add support for ircd-hybrid quiet lists --- src/fe-common/irc/fe-events-numeric.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c index 0051d3bf..be01d8c3 100644 --- a/src/fe-common/irc/fe-events-numeric.c +++ b/src/fe-common/irc/fe-events-numeric.c @@ -204,6 +204,26 @@ static void event_quiet_list(IRC_SERVER_REC *server, const char *data) g_free(params); } +static void event_hybrid_quiet_list(IRC_SERVER_REC *server, const char *data) +{ + const char *channel; + char *params, *ban, *setby, *tims, *timestr; + + g_return_if_fail(data != NULL); + + params = event_get_params(data, 5, NULL, &channel, + &ban, &setby, &tims); + timestr = my_asctime((time_t) atol(tims)); + + channel = get_visible_target(server, channel); + printformat(server, channel, MSGLEVEL_CRAP, + *setby == '\0' ? IRCTXT_QUIETLIST : IRCTXT_QUIETLIST_LONG, + channel, ban, setby, timestr); + + g_free(timestr); + g_free(params); +} + static void event_silence_list(IRC_SERVER_REC *server, const char *data) { char *params, *nick, *mask; @@ -746,6 +766,7 @@ void fe_events_numeric_init(void) signal_add("event 367", (SIGNAL_FUNC) event_ban_list); signal_add("event 348", (SIGNAL_FUNC) event_eban_list); signal_add("event 728", (SIGNAL_FUNC) event_quiet_list); + signal_add("event 344", (SIGNAL_FUNC) event_hybrid_quiet_list); /* used by ircd-hybrid */ signal_add("event 346", (SIGNAL_FUNC) event_invite_list); signal_add("event 433", (SIGNAL_FUNC) event_nick_in_use); signal_add("event 332", (SIGNAL_FUNC) event_topic_get); @@ -804,8 +825,7 @@ void fe_events_numeric_init(void) signal_add("event 470", (SIGNAL_FUNC) event_received); signal_add("event 479", (SIGNAL_FUNC) event_received); - signal_add("event 344", (SIGNAL_FUNC) event_target_received); /* reop list */ - signal_add("event 345", (SIGNAL_FUNC) event_target_received); /* end of reop list */ + signal_add("event 345", (SIGNAL_FUNC) event_target_received); /* end of reop list/hybrid quiet list */ signal_add("event 347", (SIGNAL_FUNC) event_target_received); /* end of invite exception list */ signal_add("event 349", (SIGNAL_FUNC) event_target_received); /* end of ban exception list */ signal_add("event 368", (SIGNAL_FUNC) event_target_received); /* end of ban list */ @@ -844,6 +864,7 @@ void fe_events_numeric_deinit(void) signal_remove("event 367", (SIGNAL_FUNC) event_ban_list); signal_remove("event 348", (SIGNAL_FUNC) event_eban_list); signal_remove("event 728", (SIGNAL_FUNC) event_quiet_list); + signal_remove("event 344", (SIGNAL_FUNC) event_hybrid_quiet_list); signal_remove("event 346", (SIGNAL_FUNC) event_invite_list); signal_remove("event 433", (SIGNAL_FUNC) event_nick_in_use); signal_remove("event 332", (SIGNAL_FUNC) event_topic_get); @@ -898,7 +919,6 @@ void fe_events_numeric_deinit(void) signal_remove("event 470", (SIGNAL_FUNC) event_received); signal_remove("event 479", (SIGNAL_FUNC) event_received); - signal_remove("event 344", (SIGNAL_FUNC) event_target_received); signal_remove("event 345", (SIGNAL_FUNC) event_target_received); signal_remove("event 347", (SIGNAL_FUNC) event_target_received); signal_remove("event 349", (SIGNAL_FUNC) event_target_received); From 9324ff9f68ab9a3a9c4dd97a1d5c8fa3b4342d4f Mon Sep 17 00:00:00 2001 From: David Schultz Date: Mon, 27 Mar 2023 11:04:53 -0500 Subject: [PATCH 3/8] this should work for everyone --- src/fe-common/irc/fe-events-numeric.c | 47 +++++++++++++++------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c index be01d8c3..6b4540ab 100644 --- a/src/fe-common/irc/fe-events-numeric.c +++ b/src/fe-common/irc/fe-events-numeric.c @@ -204,26 +204,6 @@ static void event_quiet_list(IRC_SERVER_REC *server, const char *data) g_free(params); } -static void event_hybrid_quiet_list(IRC_SERVER_REC *server, const char *data) -{ - const char *channel; - char *params, *ban, *setby, *tims, *timestr; - - g_return_if_fail(data != NULL); - - params = event_get_params(data, 5, NULL, &channel, - &ban, &setby, &tims); - timestr = my_asctime((time_t) atol(tims)); - - channel = get_visible_target(server, channel); - printformat(server, channel, MSGLEVEL_CRAP, - *setby == '\0' ? IRCTXT_QUIETLIST : IRCTXT_QUIETLIST_LONG, - channel, ban, setby, timestr); - - g_free(timestr); - g_free(params); -} - static void event_silence_list(IRC_SERVER_REC *server, const char *data) { char *params, *nick, *mask; @@ -733,6 +713,33 @@ static void event_target_received(IRC_SERVER_REC *server, const char *data, print_event_received(server, data, nick, TRUE); } +static void event_hybrid_quiet_list(IRC_SERVER_REC *server, const char *data) +{ + const char *channel; + char *params, *ban, *setby, *tims, *timestr; + + g_return_if_fail(data != NULL); + + params = event_get_params(data, 5, NULL, &channel, + &ban, &setby, &tims); + + if (*tims == '\0') { + /* probably not a quiet list */ + event_target_received(server, data, NULL); + return; + } + channel = get_visible_target(server, channel); + + timestr = my_asctime((time_t) atol(tims)); + + printformat(server, channel, MSGLEVEL_CRAP, + *setby == '\0' ? IRCTXT_QUIETLIST : IRCTXT_QUIETLIST_LONG, + channel, ban, setby, timestr); + + g_free(timestr); + g_free(params); +} + static void event_motd(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr) { From 201296a0dae2a9b7d4e8d4f4d52fac451a9d1027 Mon Sep 17 00:00:00 2001 From: David Schultz Date: Mon, 27 Mar 2023 18:21:36 -0500 Subject: [PATCH 4/8] add `time_ago()` in addition to timestamps; deduplicate qlist logic --- src/fe-common/irc/fe-events-numeric.c | 91 +++++++++++++++++++-------- src/fe-common/irc/module-formats.c | 8 +-- 2 files changed, 70 insertions(+), 29 deletions(-) diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c index 6b4540ab..1126c2d2 100644 --- a/src/fe-common/irc/fe-events-numeric.c +++ b/src/fe-common/irc/fe-events-numeric.c @@ -138,18 +138,55 @@ static void event_end_of_who(IRC_SERVER_REC *server, const char *data) g_free(params); } +/* Get time elapsed since an event */ +static char *time_ago(time_t seconds) +{ + static char ret[128]; + long unsigned years, weeks, days, hours, minutes; + + seconds = time(NULL) - seconds; + + years = seconds/(86400*365); + seconds %= (86400*365); + weeks = seconds/604800; + seconds %= 604800; + days = seconds/86400; + seconds %= 86400; + hours = seconds/3600; + hours %= 3600; + minutes = seconds/60; + minutes %= 60; + seconds %= 60; + + if (years) + snprintf(ret, sizeof(ret), "%luy %luw %lud", years, weeks, days); + else if (weeks) + snprintf(ret, sizeof(ret), "%luw %lud %luh", weeks, days, hours); + else if (days) + snprintf(ret, sizeof(ret), "%lud %luh %lum", days, hours, minutes); + else if (hours) + snprintf(ret, sizeof(ret), "%luh %lum", hours, minutes); + else if (minutes) + snprintf(ret, sizeof(ret), "%lum %lus", minutes, (long unsigned)seconds); + else + snprintf(ret, sizeof(ret), "%lus", (long unsigned)seconds); + + return ret; +} + static void event_ban_list(IRC_SERVER_REC *server, const char *data) { IRC_CHANNEL_REC *chanrec; BAN_REC *banrec; const char *channel; - char *params, *ban, *setby, *tims, *timestr; + char *params, *ban, *setby, *tims, *timestr, *ago; g_return_if_fail(data != NULL); params = event_get_params(data, 5, NULL, &channel, &ban, &setby, &tims); - timestr = my_asctime((time_t) atol(tims)); + timestr = my_asctime((time_t) atoll(tims)); + ago = time_ago((time_t) atoll(tims)); chanrec = irc_channel_find(server, channel); banrec = chanrec == NULL ? NULL : banlist_find(chanrec->banlist, ban); @@ -158,7 +195,7 @@ static void event_ban_list(IRC_SERVER_REC *server, const char *data) printformat(server, channel, MSGLEVEL_CRAP, *setby == '\0' ? IRCTXT_BANLIST : IRCTXT_BANLIST_LONG, banrec == NULL ? 0 : g_slist_index(chanrec->banlist, banrec)+1, - channel, ban, setby, timestr); + channel, ban, setby, timestr, ago); g_free(timestr); g_free(params); @@ -167,40 +204,49 @@ static void event_ban_list(IRC_SERVER_REC *server, const char *data) static void event_eban_list(IRC_SERVER_REC *server, const char *data) { const char *channel; - char *params, *ban, *setby, *tims, *timestr; + char *params, *ban, *setby, *tims, *timestr, *ago; g_return_if_fail(data != NULL); params = event_get_params(data, 5, NULL, &channel, &ban, &setby, &tims); - timestr = my_asctime((time_t) atol(tims)); + timestr = my_asctime((time_t) atoll(tims)); + ago = time_ago((time_t) atoll(tims)); channel = get_visible_target(server, channel); printformat(server, channel, MSGLEVEL_CRAP, *setby == '\0' ? IRCTXT_EBANLIST : IRCTXT_EBANLIST_LONG, - channel, ban, setby, timestr); + channel, ban, setby, timestr, ago); g_free(timestr); g_free(params); } +static void do_quiet_list(IRC_SERVER_REC *server, const char *channel, char *ban, char *setby, char *tims) { + char *timestr, *ago; + + timestr = my_asctime((time_t) atoll(tims)); + ago = time_ago((time_t) atoll(tims)); + + channel = get_visible_target(server, channel); + printformat(server, channel, MSGLEVEL_CRAP, + *setby == '\0' ? IRCTXT_QUIETLIST : IRCTXT_QUIETLIST_LONG, + channel, ban, setby, timestr, ago); + + g_free(timestr); +} + static void event_quiet_list(IRC_SERVER_REC *server, const char *data) { const char *channel; - char *params, *ban, *setby, *tims, *timestr; + char *params, *ban, *setby, *tims; g_return_if_fail(data != NULL); params = event_get_params(data, 6, NULL, &channel, NULL, &ban, &setby, &tims); - timestr = my_asctime((time_t) atol(tims)); + do_quiet_list(server, channel, ban, setby, tims); - channel = get_visible_target(server, channel); - printformat(server, channel, MSGLEVEL_CRAP, - *setby == '\0' ? IRCTXT_QUIETLIST : IRCTXT_QUIETLIST_LONG, - channel, ban, setby, timestr); - - g_free(timestr); g_free(params); } @@ -232,18 +278,19 @@ static void event_accept_list(IRC_SERVER_REC *server, const char *data) static void event_invite_list(IRC_SERVER_REC *server, const char *data) { const char *channel; - char *params, *invite, *setby, *tims, *timestr; + char *params, *invite, *setby, *tims, *timestr, *ago; g_return_if_fail(data != NULL); params = event_get_params(data, 5, NULL, &channel, &invite, &setby, &tims); - timestr = my_asctime((time_t) atol(tims)); + timestr = my_asctime((time_t) atoll(tims)); + ago = time_ago((time_t) atoll(tims)); channel = get_visible_target(server, channel); printformat(server, channel, MSGLEVEL_CRAP, *setby == '\0' ? IRCTXT_INVITELIST : IRCTXT_INVITELIST_LONG, - channel, invite, setby, timestr); + channel, invite, setby, timestr, ago); g_free(timestr); g_free(params); @@ -716,7 +763,7 @@ static void event_target_received(IRC_SERVER_REC *server, const char *data, static void event_hybrid_quiet_list(IRC_SERVER_REC *server, const char *data) { const char *channel; - char *params, *ban, *setby, *tims, *timestr; + char *params, *ban, *setby, *tims; g_return_if_fail(data != NULL); @@ -728,15 +775,9 @@ static void event_hybrid_quiet_list(IRC_SERVER_REC *server, const char *data) event_target_received(server, data, NULL); return; } - channel = get_visible_target(server, channel); - timestr = my_asctime((time_t) atol(tims)); + do_quiet_list(server, channel, ban, setby, tims); - printformat(server, channel, MSGLEVEL_CRAP, - *setby == '\0' ? IRCTXT_QUIETLIST : IRCTXT_QUIETLIST_LONG, - channel, ban, setby, timestr); - - g_free(timestr); g_free(params); } diff --git a/src/fe-common/irc/module-formats.c b/src/fe-common/irc/module-formats.c index 2cd87e04..3ccf17f9 100644 --- a/src/fe-common/irc/module-formats.c +++ b/src/fe-common/irc/module-formats.c @@ -81,14 +81,14 @@ FORMAT_REC fecommon_irc_formats[] = { { "bantype", "Ban type changed to {channel $0}", 1, { 0 } }, { "no_bans", "No bans in channel {channel $0}", 1, { 0 } }, { "banlist", "$0 - {channel $1}: ban {ban $2}", 3, { 1, 0, 0 } }, - { "banlist_long", "$0 - {channel $1}: ban {ban $2} {comment by {nick $3}, on $4}", 5, { 1, 0, 0, 0, 0 } }, + { "banlist_long", "$0 - {channel $1}: ban {ban $2} {comment by {nick $3}, on $4 ($5 ago)}", 6, { 1, 0, 0, 0, 0, 0 } }, { "quietlist", "{channel $0}: quiet {ban $1}", 2, { 0, 0 } }, - { "quietlist_long", "{channel $0}: quiet {ban $1} {comment by {nick $2}, on $3}", 4, { 0, 0, 0, 0 } }, + { "quietlist_long", "{channel $0}: quiet {ban $1} {comment by {nick $2}, on $3 ($4 ago)}", 5, { 0, 0, 0, 0, 0 } }, { "ebanlist", "{channel $0}: ban exception {ban $1}", 2, { 0, 0 } }, - { "ebanlist_long", "{channel $0}: ban exception {ban $1} {comment by {nick $2}, on $3}", 4, { 0, 0, 0, 0 } }, + { "ebanlist_long", "{channel $0}: ban exception {ban $1} {comment by {nick $2}, on $3 ($4 ago)}", 5, { 0, 0, 0, 0, 0 } }, { "no_invitelist", "Invite list is empty in channel {channel $0}", 1, { 0 } }, { "invitelist", "{channel $0}: invite {ban $1}", 2, { 0, 0 } }, - { "invitelist_long", "{channel $0}: invite {ban $1} {comment by {nick $2}, on $3}", 4, { 0, 0, 0, 0 } }, + { "invitelist_long", "{channel $0}: invite {ban $1} {comment by {nick $2}, on $3 ($4 ago)}", 5, { 0, 0, 0, 0, 0 } }, { "no_such_channel", "{channel $0}: No such channel", 1, { 0 } }, { "channel_synced", "Join to {channel $0} was synced in {hilight $1} secs", 2, { 0, 2 } }, { "server_help_start", "$1", 2, { 0, 0 } }, From ee1213481224275afb088518ad763d9f965697dc Mon Sep 17 00:00:00 2001 From: David Schultz Date: Mon, 27 Mar 2023 19:37:48 -0500 Subject: [PATCH 5/8] clean up `time_ago()` Co-authored-by: Doug Freed --- src/fe-common/irc/fe-events-numeric.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c index 1126c2d2..81ae34e5 100644 --- a/src/fe-common/irc/fe-events-numeric.c +++ b/src/fe-common/irc/fe-events-numeric.c @@ -146,16 +146,12 @@ static char *time_ago(time_t seconds) seconds = time(NULL) - seconds; - years = seconds/(86400*365); - seconds %= (86400*365); - weeks = seconds/604800; - seconds %= 604800; - days = seconds/86400; - seconds %= 86400; - hours = seconds/3600; - hours %= 3600; - minutes = seconds/60; - minutes %= 60; + years = seconds / (86400 * 365); + seconds %= (86400 * 365); + weeks = seconds / 604800; + days = (seconds / 86400) % 7; + hours = (seconds / 3600) % 24; + minutes = (seconds / 60) % 60; seconds %= 60; if (years) From 0bcff291e9c1a9120ffbd6a84a20b7948e690ac1 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Thu, 25 May 2023 11:36:25 +0200 Subject: [PATCH 6/8] order --- src/fe-common/irc/fe-events-numeric.c | 10 +++++----- src/fe-common/irc/module-formats.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c index 81ae34e5..667049cb 100644 --- a/src/fe-common/irc/fe-events-numeric.c +++ b/src/fe-common/irc/fe-events-numeric.c @@ -189,9 +189,9 @@ static void event_ban_list(IRC_SERVER_REC *server, const char *data) channel = get_visible_target(server, channel); printformat(server, channel, MSGLEVEL_CRAP, - *setby == '\0' ? IRCTXT_BANLIST : IRCTXT_BANLIST_LONG, - banrec == NULL ? 0 : g_slist_index(chanrec->banlist, banrec)+1, - channel, ban, setby, timestr, ago); + *setby == '\0' ? IRCTXT_BANLIST : IRCTXT_BANLIST_LONG, + banrec == NULL ? 0 : g_slist_index(chanrec->banlist, banrec) + 1, channel, ban, + setby, ago, timestr); g_free(timestr); g_free(params); @@ -226,8 +226,8 @@ static void do_quiet_list(IRC_SERVER_REC *server, const char *channel, char *ban channel = get_visible_target(server, channel); printformat(server, channel, MSGLEVEL_CRAP, - *setby == '\0' ? IRCTXT_QUIETLIST : IRCTXT_QUIETLIST_LONG, - channel, ban, setby, timestr, ago); + *setby == '\0' ? IRCTXT_QUIETLIST : IRCTXT_QUIETLIST_LONG, channel, ban, setby, + ago, timestr); g_free(timestr); } diff --git a/src/fe-common/irc/module-formats.c b/src/fe-common/irc/module-formats.c index 3ccf17f9..86310157 100644 --- a/src/fe-common/irc/module-formats.c +++ b/src/fe-common/irc/module-formats.c @@ -81,11 +81,11 @@ FORMAT_REC fecommon_irc_formats[] = { { "bantype", "Ban type changed to {channel $0}", 1, { 0 } }, { "no_bans", "No bans in channel {channel $0}", 1, { 0 } }, { "banlist", "$0 - {channel $1}: ban {ban $2}", 3, { 1, 0, 0 } }, - { "banlist_long", "$0 - {channel $1}: ban {ban $2} {comment by {nick $3}, on $4 ($5 ago)}", 6, { 1, 0, 0, 0, 0, 0 } }, + { "banlist_long", "$0 - {channel $1}: ban {ban $2} {comment by {nick $3}, on $5 ($4 ago)}", 6, { 1, 0, 0, 0, 0, 0 } }, { "quietlist", "{channel $0}: quiet {ban $1}", 2, { 0, 0 } }, - { "quietlist_long", "{channel $0}: quiet {ban $1} {comment by {nick $2}, on $3 ($4 ago)}", 5, { 0, 0, 0, 0, 0 } }, + { "quietlist_long", "{channel $0}: quiet {ban $1} {comment by {nick $2}, on $4 ($3 ago)}", 5, { 0, 0, 0, 0, 0 } }, { "ebanlist", "{channel $0}: ban exception {ban $1}", 2, { 0, 0 } }, - { "ebanlist_long", "{channel $0}: ban exception {ban $1} {comment by {nick $2}, on $3 ($4 ago)}", 5, { 0, 0, 0, 0, 0 } }, + { "ebanlist_long", "{channel $0}: ban exception {ban $1} {comment by {nick $2}, on $4 ($3 ago)}", 5, { 0, 0, 0, 0, 0 } }, { "no_invitelist", "Invite list is empty in channel {channel $0}", 1, { 0 } }, { "invitelist", "{channel $0}: invite {ban $1}", 2, { 0, 0 } }, { "invitelist_long", "{channel $0}: invite {ban $1} {comment by {nick $2}, on $3 ($4 ago)}", 5, { 0, 0, 0, 0, 0 } }, From 0355ed0bea5a993b49804b6d7a32588ade1a9b48 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Thu, 25 May 2023 11:42:15 +0200 Subject: [PATCH 7/8] format --- src/fe-common/irc/fe-events-numeric.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c index 667049cb..951bd31f 100644 --- a/src/fe-common/irc/fe-events-numeric.c +++ b/src/fe-common/irc/fe-events-numeric.c @@ -163,9 +163,9 @@ static char *time_ago(time_t seconds) else if (hours) snprintf(ret, sizeof(ret), "%luh %lum", hours, minutes); else if (minutes) - snprintf(ret, sizeof(ret), "%lum %lus", minutes, (long unsigned)seconds); + snprintf(ret, sizeof(ret), "%lum %lus", minutes, (long unsigned) seconds); else - snprintf(ret, sizeof(ret), "%lus", (long unsigned)seconds); + snprintf(ret, sizeof(ret), "%lus", (long unsigned) seconds); return ret; } @@ -211,14 +211,16 @@ static void event_eban_list(IRC_SERVER_REC *server, const char *data) channel = get_visible_target(server, channel); printformat(server, channel, MSGLEVEL_CRAP, - *setby == '\0' ? IRCTXT_EBANLIST : IRCTXT_EBANLIST_LONG, - channel, ban, setby, timestr, ago); + *setby == '\0' ? IRCTXT_EBANLIST : IRCTXT_EBANLIST_LONG, channel, ban, setby, + timestr, ago); g_free(timestr); g_free(params); } -static void do_quiet_list(IRC_SERVER_REC *server, const char *channel, char *ban, char *setby, char *tims) { +static void do_quiet_list(IRC_SERVER_REC *server, const char *channel, char *ban, char *setby, + char *tims) +{ char *timestr, *ago; timestr = my_asctime((time_t) atoll(tims)); @@ -239,8 +241,7 @@ static void event_quiet_list(IRC_SERVER_REC *server, const char *data) g_return_if_fail(data != NULL); - params = event_get_params(data, 6, NULL, &channel, - NULL, &ban, &setby, &tims); + params = event_get_params(data, 6, NULL, &channel, NULL, &ban, &setby, &tims); do_quiet_list(server, channel, ban, setby, tims); g_free(params); @@ -285,8 +286,8 @@ static void event_invite_list(IRC_SERVER_REC *server, const char *data) channel = get_visible_target(server, channel); printformat(server, channel, MSGLEVEL_CRAP, - *setby == '\0' ? IRCTXT_INVITELIST : IRCTXT_INVITELIST_LONG, - channel, invite, setby, timestr, ago); + *setby == '\0' ? IRCTXT_INVITELIST : IRCTXT_INVITELIST_LONG, channel, invite, + setby, timestr, ago); g_free(timestr); g_free(params); @@ -763,8 +764,7 @@ static void event_hybrid_quiet_list(IRC_SERVER_REC *server, const char *data) g_return_if_fail(data != NULL); - params = event_get_params(data, 5, NULL, &channel, - &ban, &setby, &tims); + params = event_get_params(data, 5, NULL, &channel, &ban, &setby, &tims); if (*tims == '\0') { /* probably not a quiet list */ From 685816e9459a4c4c93f314222d5123467438e88a Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Thu, 25 May 2023 11:48:31 +0200 Subject: [PATCH 8/8] up abi --- src/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.h b/src/common.h index 96886f6b..59566dc8 100644 --- a/src/common.h +++ b/src/common.h @@ -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 51 +#define IRSSI_ABI_VERSION 52 #define DEFAULT_SERVER_ADD_PORT 6667 #define DEFAULT_SERVER_ADD_TLS_PORT 6697