From 06b8e3e6fa92696b940f859ad7d30642d0ab7dd8 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:01:59 +0200 Subject: [PATCH 1/8] Fix .channel formatting --- src/mod/irc.mod/cmdsirc.c | 82 +++++++++++++++++++---------------- src/mod/irc.mod/help/irc.help | 10 ++--- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/mod/irc.mod/cmdsirc.c b/src/mod/irc.mod/cmdsirc.c index c9bf58ab1..403b178ed 100644 --- a/src/mod/irc.mod/cmdsirc.c +++ b/src/mod/irc.mod/cmdsirc.c @@ -703,54 +703,58 @@ static void cmd_invite(struct userrec *u, int idx, char *par) static void cmd_channel(struct userrec *u, int idx, char *par) { - char handle[HANDLEN + 1], s[UHOSTLEN], s1[UHOSTLEN], atrflag, chanflag; + char s[UHOSTLEN], join[7], handle[HANDLEN + 1], atrflag, chanflag; struct chanset_t *chan; memberlist *m; - int maxnicklen, maxhandlen; + int maxnicklen = 0, maxhandlen = 0, maxaccountlen = 0, maxuserhostlen = 0; chan = get_channel(idx, par); if (!chan || !has_oporhalfop(idx, chan)) return; putlog(LOG_CMDS, "*", "#%s# (%s) channel", dcc[idx].nick, chan->dname); - strlcpy(s, getchanmode(chan), sizeof s); if (channel_pending(chan)) - egg_snprintf(s1, sizeof s1, "%s %s", IRC_PROCESSINGCHAN, chan->dname); + snprintf(s, sizeof s, "%s %s", IRC_PROCESSINGCHAN, chan->dname); else if (channel_active(chan)) - egg_snprintf(s1, sizeof s1, "%s %s", IRC_CHANNEL, chan->dname); + snprintf(s, sizeof s, "%s %s", IRC_CHANNEL, chan->dname); else - egg_snprintf(s1, sizeof s1, "%s %s", IRC_DESIRINGCHAN, chan->dname); - dprintf(idx, "%s, %d member%s, mode %s:\n", s1, chan->channel.members, - chan->channel.members == 1 ? "" : "s", s); + snprintf(s, sizeof s, "%s %s", IRC_DESIRINGCHAN, chan->dname); + dprintf(idx, "%s, %d member%s, mode %s:\n", s, chan->channel.members, + chan->channel.members == 1 ? "" : "s", getchanmode(chan)); if (chan->channel.topic) dprintf(idx, "%s: %s\n", IRC_CHANNELTOPIC, chan->channel.topic); if (channel_active(chan)) { - /* find max nicklen and handlen */ - maxnicklen = maxhandlen = 0; + /* find max nicklen, handlen and accountlen */ for (m = chan->channel.member; m && m->nick[0]; m = m->next) { if (strlen(m->nick) > maxnicklen) maxnicklen = strlen(m->nick); + if (strlen(m->account) > maxaccountlen) + maxaccountlen = strlen(m->account); + if (strlen(m->userhost) > maxuserhostlen) + maxuserhostlen = strlen(m->userhost); u = get_user_from_member(m); if (u && (strlen(u->handle) > maxhandlen)) maxhandlen = strlen(u->handle); } - if (maxnicklen < 9) - maxnicklen = 9; - if (maxhandlen < 9) - maxhandlen = 9; - - dprintf(idx, "(n = owner, m = master, o = op, d = deop, b = bot)\n"); - dprintf(idx, " %-*s %-*s %-*s %-6s %-5s %s\n", maxnicklen, "NICKNAME", - maxhandlen, "HANDLE", maxnicklen, "ACCOUNT", "JOIN", "IDLE", - "USER@HOST"); + if (maxnicklen < 8) + maxnicklen = 8; + if (maxhandlen < 6) + maxhandlen = 6; + if (maxaccountlen < 7) + maxaccountlen = 7; + if (maxuserhostlen < 9) + maxuserhostlen = 9; + + dprintf(idx, "(n = owner, m = master, o = op, d = deop, b = bot)\n" + " %-*s %-*s %-*s JOIN F IDLE USER@HOST\n", maxnicklen, + "NICKNAME", maxhandlen, "HANDLE", maxaccountlen, "ACCOUNT"); for (m = chan->channel.member; m && m->nick[0]; m = m->next) { if (m->joined > 0) { if ((now - (m->joined)) > 86400) - strftime(s, 6, "%d%b", localtime(&(m->joined))); + strftime(join, sizeof join, "%y%m%d", localtime(&(m->joined))); else - strftime(s, 6, "%H:%M", localtime(&(m->joined))); + strftime(join, sizeof join, "%H:%M", localtime(&(m->joined))); } else - strlcpy(s, " --- ", sizeof s); - egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost); + strcpy(join, "*"); u = get_user_from_member(m); if (u == NULL) strlcpy(handle, "*", sizeof handle); @@ -833,31 +837,33 @@ static void cmd_channel(struct userrec *u, int idx, char *par) else chanflag = ' '; if (chan_issplit(m)) { - dprintf(idx, "%c%-*s %-*s %-*s %-6s %c <- netsplit, %" PRId64 "s\n", - chanflag, maxnicklen, m->nick, maxhandlen, handle, maxnicklen, - m->account, s, atrflag, (int64_t) (now - m->split)); + dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %-*s <- netsplit, %" PRId64 "s\n", + chanflag, maxnicklen, m->nick, maxhandlen, handle, + maxaccountlen, m->account, join, atrflag, maxuserhostlen, + m->userhost, (int64_t) (now - m->split)); } else if (!rfc_casecmp(m->nick, botname)) { - dprintf(idx, "%c%-*s %-*s %-*s %-6s %c <- it's me!\n", - chanflag, maxnicklen, m->nick, maxhandlen, handle, maxnicklen, - m->account, s, atrflag); + dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %-*s <- it's me!\n", + chanflag, maxnicklen, m->nick, maxhandlen, handle, + maxaccountlen, m->account, join, atrflag, maxuserhostlen, + m->userhost); } else { /* Determine idle time */ if (now - (m->last) > 86400) - snprintf(s1, sizeof s1, "%2" PRId64 "d", ((int64_t) (now - m->last)) / 86400); + snprintf(s, sizeof s, "%2" PRId64 "d", ((int64_t) (now - m->last)) / 86400); else if (now - (m->last) > 3600) - snprintf(s1, sizeof s1, "%2" PRId64 "h", ((int64_t) (now - m->last)) / 3600); + snprintf(s, sizeof s, "%2" PRId64 "h", ((int64_t) (now - m->last)) / 3600); else if (now - (m->last) > 180) - snprintf(s1, sizeof s1, "%2" PRId64 "m", ((int64_t) (now - m->last)) / 60); + snprintf(s, sizeof s, "%2" PRId64 "m", ((int64_t) (now - m->last)) / 60); else - strlcpy(s1, " ", sizeof s1); + strlcpy(s, "", sizeof s); if (chan_ircaway(m)) { - strlcpy(s1+strlen(s1), " (away)", ((sizeof s1)-strlen(s1))); + strlcpy(s+strlen(s), "(away)", ((sizeof s) - strlen(s))); } else { - strlcpy(s1+strlen(s1), " ", ((sizeof s1)-strlen(s1))); + strlcpy(s+strlen(s), " ", ((sizeof s) - strlen(s))); } - dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %s %s\n", chanflag, maxnicklen, - m->nick, maxhandlen, handle, maxnicklen, m->account, s, atrflag, - s1, m->userhost); + dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %-6s %s\n", chanflag, + maxnicklen, m->nick, maxhandlen, handle, maxaccountlen, + m->account, join, atrflag, s, m->userhost); } if (chan_fakeop(m)) dprintf(idx, " (%s)\n", IRC_FAKECHANOP); diff --git a/src/mod/irc.mod/help/irc.help b/src/mod/irc.mod/help/irc.help index d5a163d53..3c55b0860 100644 --- a/src/mod/irc.mod/help/irc.help +++ b/src/mod/irc.mod/help/irc.help @@ -39,18 +39,16 @@ See also: deluser, +host, -host, +user, -user #hiya, 0 members, mode +:" instead. Next is a list of the users on the channel, with each entry looking like this: - NICKNAME HANDLE JOIN IDLE USER@HOST - @Wcc Wcc --- N Wcc@blah.atlaga.adelphia.net + NICKNAME HANDLE ACCOUNT JOIN F IDLE USER@HOST + @Wcc Wcc * 00:42 Wcc@foo.adelphia.net The "@Wcc" means that the user's nickname is Wcc and that he is a chanop. The second "Wcc" is the user's handle. Sometimes this will differ from the nickname a person is using. The time displayed is the time the user joined the channel. The next field is the user's status flag. These are the same as the flags listed in %b.help whois%b. Global flags are uppercase. Only - the 'highest' flag is displayed. - - The last two fields are the user's idle time, and the user@host they are - connecting from + the 'highest' flag is displayed. The last two fields are the user's idle + time, and the user@host they are connecting from See also: console, whois%{m|m}, status%{-} %{help=deluser}%{+m|m} From cee1f98c2b8a88db0f05a274a13f837d6718505d Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:09:53 +0200 Subject: [PATCH 2/8] . --- src/mod/irc.mod/help/irc.help | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/irc.mod/help/irc.help b/src/mod/irc.mod/help/irc.help index 3c55b0860..a078f7b23 100644 --- a/src/mod/irc.mod/help/irc.help +++ b/src/mod/irc.mod/help/irc.help @@ -48,7 +48,7 @@ See also: deluser, +host, -host, +user, -user the channel. The next field is the user's status flag. These are the same as the flags listed in %b.help whois%b. Global flags are uppercase. Only the 'highest' flag is displayed. The last two fields are the user's idle - time, and the user@host they are connecting from + time, and the user@host they are connecting from. See also: console, whois%{m|m}, status%{-} %{help=deluser}%{+m|m} From d1143d9af388dd39b1c80d98e0bafee11ebcf142 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:19:48 +0200 Subject: [PATCH 3/8] Enhance doc --- src/mod/irc.mod/help/irc.help | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/irc.mod/help/irc.help b/src/mod/irc.mod/help/irc.help index a078f7b23..ee667e5df 100644 --- a/src/mod/irc.mod/help/irc.help +++ b/src/mod/irc.mod/help/irc.help @@ -48,7 +48,7 @@ See also: deluser, +host, -host, +user, -user the channel. The next field is the user's status flag. These are the same as the flags listed in %b.help whois%b. Global flags are uppercase. Only the 'highest' flag is displayed. The last two fields are the user's idle - time, and the user@host they are connecting from. + time (if more than 3 minutes), and the user@host they are connecting from. See also: console, whois%{m|m}, status%{-} %{help=deluser}%{+m|m} From dcf6e04f5823a973fed2db72b5dbe9416535a0e3 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:23:51 +0200 Subject: [PATCH 4/8] Fix format --- src/mod/irc.mod/cmdsirc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mod/irc.mod/cmdsirc.c b/src/mod/irc.mod/cmdsirc.c index 403b178ed..7f7cc26a4 100644 --- a/src/mod/irc.mod/cmdsirc.c +++ b/src/mod/irc.mod/cmdsirc.c @@ -849,11 +849,11 @@ static void cmd_channel(struct userrec *u, int idx, char *par) } else { /* Determine idle time */ if (now - (m->last) > 86400) - snprintf(s, sizeof s, "%2" PRId64 "d", ((int64_t) (now - m->last)) / 86400); + snprintf(s, sizeof s, "%" PRId64 "d", ((int64_t) (now - m->last)) / 86400); else if (now - (m->last) > 3600) - snprintf(s, sizeof s, "%2" PRId64 "h", ((int64_t) (now - m->last)) / 3600); + snprintf(s, sizeof s, "%" PRId64 "h", ((int64_t) (now - m->last)) / 3600); else if (now - (m->last) > 180) - snprintf(s, sizeof s, "%2" PRId64 "m", ((int64_t) (now - m->last)) / 60); + snprintf(s, sizeof s, "%" PRId64 "m", ((int64_t) (now - m->last)) / 60); else strlcpy(s, "", sizeof s); if (chan_ircaway(m)) { From d4c181929aade8cd6bc8243c7fc4c7df0a10e2ed Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:05:50 +0200 Subject: [PATCH 5/8] Fix idle / away format --- src/mod/irc.mod/cmdsirc.c | 20 ++++++++++---------- src/mod/irc.mod/help/irc.help | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mod/irc.mod/cmdsirc.c b/src/mod/irc.mod/cmdsirc.c index 7f7cc26a4..6b57089ee 100644 --- a/src/mod/irc.mod/cmdsirc.c +++ b/src/mod/irc.mod/cmdsirc.c @@ -745,7 +745,7 @@ static void cmd_channel(struct userrec *u, int idx, char *par) maxuserhostlen = 9; dprintf(idx, "(n = owner, m = master, o = op, d = deop, b = bot)\n" - " %-*s %-*s %-*s JOIN F IDLE USER@HOST\n", maxnicklen, + " %-*s %-*s %-*s JOIN F IDLE USER@HOST\n", maxnicklen, "NICKNAME", maxhandlen, "HANDLE", maxaccountlen, "ACCOUNT"); for (m = chan->channel.member; m && m->nick[0]; m = m->next) { if (m->joined > 0) { @@ -837,31 +837,31 @@ static void cmd_channel(struct userrec *u, int idx, char *par) else chanflag = ' '; if (chan_issplit(m)) { - dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %-*s <- netsplit, %" PRId64 "s\n", + dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %-*s <- netsplit, %" PRId64 "s\n", chanflag, maxnicklen, m->nick, maxhandlen, handle, maxaccountlen, m->account, join, atrflag, maxuserhostlen, m->userhost, (int64_t) (now - m->split)); } else if (!rfc_casecmp(m->nick, botname)) { - dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %-*s <- it's me!\n", + dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %-*s <- it's me!\n", chanflag, maxnicklen, m->nick, maxhandlen, handle, maxaccountlen, m->account, join, atrflag, maxuserhostlen, m->userhost); } else { /* Determine idle time */ if (now - (m->last) > 86400) - snprintf(s, sizeof s, "%" PRId64 "d", ((int64_t) (now - m->last)) / 86400); + snprintf(s, sizeof s, "%4" PRId64 "d", ((int64_t) (now - m->last)) / 86400); else if (now - (m->last) > 3600) - snprintf(s, sizeof s, "%" PRId64 "h", ((int64_t) (now - m->last)) / 3600); + snprintf(s, sizeof s, "%4" PRId64 "h", ((int64_t) (now - m->last)) / 3600); else if (now - (m->last) > 180) - snprintf(s, sizeof s, "%" PRId64 "m", ((int64_t) (now - m->last)) / 60); + snprintf(s, sizeof s, "%4" PRId64 "m", ((int64_t) (now - m->last)) / 60); else - strlcpy(s, "", sizeof s); + strcpy(s, " "); if (chan_ircaway(m)) { - strlcpy(s+strlen(s), "(away)", ((sizeof s) - strlen(s))); + strlcpy(s + strlen(s), " (away)", ((sizeof s) - strlen(s))); } else { - strlcpy(s+strlen(s), " ", ((sizeof s) - strlen(s))); + strlcpy(s + strlen(s), " ", ((sizeof s) - strlen(s))); } - dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %-6s %s\n", chanflag, + dprintf(idx, "%c%-*s %-*s %-*s %-6s %c %s %s\n", chanflag, maxnicklen, m->nick, maxhandlen, handle, maxaccountlen, m->account, join, atrflag, s, m->userhost); } diff --git a/src/mod/irc.mod/help/irc.help b/src/mod/irc.mod/help/irc.help index ee667e5df..83126be29 100644 --- a/src/mod/irc.mod/help/irc.help +++ b/src/mod/irc.mod/help/irc.help @@ -39,8 +39,8 @@ See also: deluser, +host, -host, +user, -user #hiya, 0 members, mode +:" instead. Next is a list of the users on the channel, with each entry looking like this: - NICKNAME HANDLE ACCOUNT JOIN F IDLE USER@HOST - @Wcc Wcc * 00:42 Wcc@foo.adelphia.net + NICKNAME HANDLE ACCOUNT JOIN F IDLE USER@HOST + @Wcc Wcc * 00:42 Wcc@example.org The "@Wcc" means that the user's nickname is Wcc and that he is a chanop. The second "Wcc" is the user's handle. Sometimes this will differ from the From 2561d2269dd429a1297bc2da3fe8b0c5293947f3 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:17:12 +0200 Subject: [PATCH 6/8] Cleanup --- src/mod/irc.mod/help/irc.help | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/irc.mod/help/irc.help b/src/mod/irc.mod/help/irc.help index 83126be29..6adf1ed3d 100644 --- a/src/mod/irc.mod/help/irc.help +++ b/src/mod/irc.mod/help/irc.help @@ -39,8 +39,8 @@ See also: deluser, +host, -host, +user, -user #hiya, 0 members, mode +:" instead. Next is a list of the users on the channel, with each entry looking like this: - NICKNAME HANDLE ACCOUNT JOIN F IDLE USER@HOST - @Wcc Wcc * 00:42 Wcc@example.org + NICKNAME HANDLE ACCOUNT JOIN F IDLE USER@HOST + @Wcc Wcc * 00:42 Wcc@example.org The "@Wcc" means that the user's nickname is Wcc and that he is a chanop. The second "Wcc" is the user's handle. Sometimes this will differ from the From cf02bc21ab91cbaf868ad1f4fbbfecd5b946f8a6 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:37:20 +0200 Subject: [PATCH 7/8] Enhance doc for .channel away --- src/mod/irc.mod/help/irc.help | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mod/irc.mod/help/irc.help b/src/mod/irc.mod/help/irc.help index 6adf1ed3d..ddfeec1e0 100644 --- a/src/mod/irc.mod/help/irc.help +++ b/src/mod/irc.mod/help/irc.help @@ -50,6 +50,9 @@ See also: deluser, +host, -host, +user, -user the 'highest' flag is displayed. The last two fields are the user's idle time (if more than 3 minutes), and the user@host they are connecting from. + IDLE could display "(away)" as last away status known to the bot. It could + be out of sync, if not tracked via away-notify capability or otherwise. + See also: console, whois%{m|m}, status%{-} %{help=deluser}%{+m|m} ### %bdeluser%b From 79d41be1ea9d4158e291f7a24c0ac555ea82d045 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:29:48 +0200 Subject: [PATCH 8/8] Keep history --- src/mod/irc.mod/help/irc.help | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/irc.mod/help/irc.help b/src/mod/irc.mod/help/irc.help index ddfeec1e0..5c2c715de 100644 --- a/src/mod/irc.mod/help/irc.help +++ b/src/mod/irc.mod/help/irc.help @@ -40,7 +40,7 @@ See also: deluser, +host, -host, +user, -user channel, with each entry looking like this: NICKNAME HANDLE ACCOUNT JOIN F IDLE USER@HOST - @Wcc Wcc * 00:42 Wcc@example.org + @Wcc Wcc * 00:42 N Wcc@example.org The "@Wcc" means that the user's nickname is Wcc and that he is a chanop. The second "Wcc" is the user's handle. Sometimes this will differ from the