feat(bot): add -wid flag to pk;s fh to show member IDs

This commit is contained in:
Iris System 2022-08-27 23:48:06 +12:00
parent 3db818741a
commit 9153c26425

View File

@ -42,6 +42,8 @@ public class SystemFront
? $"Front history of {system.Name} (`{system.Hid}`)" ? $"Front history of {system.Name} (`{system.Hid}`)"
: $"Front history of `{system.Hid}`"; : $"Front history of `{system.Hid}`";
var showMemberId = ctx.MatchFlag("with-id", "wid");
await ctx.Paginate( await ctx.Paginate(
sws, sws,
totalSwitches, totalSwitches,
@ -61,8 +63,8 @@ public class SystemFront
var members = await ctx.Database.Execute(c => ctx.Repository.GetSwitchMembers(c, sw.Id)).ToListAsync(); var members = await ctx.Database.Execute(c => ctx.Repository.GetSwitchMembers(c, sw.Id)).ToListAsync();
var membersStr = members.Any() var membersStr = members.Any()
? string.Join(", ", members.Select(m => m.NameFor(ctx))) ? string.Join(", ", members.Select(m => $"**{m.NameFor(ctx)}**{(showMemberId ? $" (`{m.Hid}`)" : "")}"))
: "no fronter"; : "**no fronter**";
var switchSince = SystemClock.Instance.GetCurrentInstant() - sw.Timestamp; var switchSince = SystemClock.Instance.GetCurrentInstant() - sw.Timestamp;
@ -73,12 +75,12 @@ public class SystemFront
// Calculate the time between the last switch (that we iterated - ie. the next one on the timeline) and the current one // Calculate the time between the last switch (that we iterated - ie. the next one on the timeline) and the current one
var switchDuration = lastSw.Value - sw.Timestamp; var switchDuration = lastSw.Value - sw.Timestamp;
stringToAdd = stringToAdd =
$"**{membersStr}** ({sw.Timestamp.FormatZoned(ctx.Zone)}, {switchSince.FormatDuration()} ago, for {switchDuration.FormatDuration()})\n"; $"{membersStr} ({sw.Timestamp.FormatZoned(ctx.Zone)}, {switchSince.FormatDuration()} ago, for {switchDuration.FormatDuration()})\n";
} }
else else
{ {
stringToAdd = stringToAdd =
$"**{membersStr}** ({sw.Timestamp.FormatZoned(ctx.Zone)}, {switchSince.FormatDuration()} ago)\n"; $"{membersStr} ({sw.Timestamp.FormatZoned(ctx.Zone)}, {switchSince.FormatDuration()} ago)\n";
} }
if (sb.Length + stringToAdd.Length >= 4096) if (sb.Length + stringToAdd.Length >= 4096)