feat: add more options for when to make proxied messages silent

This commit is contained in:
Petal Ladenson 2026-01-13 19:26:10 -07:00
parent 952bb02285
commit 546a287c28
9 changed files with 71 additions and 14 deletions

View file

@ -112,7 +112,7 @@ public partial class CommandTree
public static Command ServerConfigLogClean = new Command("serverconfig log cleanup", "serverconfig log cleanup [on|off]", "Toggles whether to clean up other bots' log channels");
public static Command ServerConfigInvalidCommandResponse = new Command("serverconfig invalid command error", "serverconfig invalid command error [on|off]", "Sets whether to show an error message when an unknown command is sent");
public static Command ServerConfigRequireSystemTag = new Command("serverconfig require tag", "serverconfig require tag [on|off]", "Sets whether server users are required to have a system tag on proxied messages");
public static Command ServerConfigSuppressNotifications = new Command("serverconfig suppress notifications", "serverconfig suppress notifications [on|off]", "Sets whether all proxied messages will have notifications suppressed (sent as `@silent` messages)");
public static Command ServerConfigSuppressNotifications = new Command("serverconfig suppress notifications", "serverconfig suppress notifications [always|never|match|invert]", "Sets when proxied messages will have notifications suppressed (sent as `@silent` messages)");
public static Command Invite = new Command("invite", "invite", "Gets a link to invite PluralKit to other servers");
public static Command PermCheck = new Command("permcheck", "permcheck <guild>", "Checks whether a server's permission setup is correct");
public static Command Admin = new Command("admin", "admin", "Super secret admin commands (sshhhh)");

View file

@ -49,9 +49,9 @@ public class ServerConfig
items.Add(new(
"suppress notifications",
"Whether all proxied messages will have notifications suppressed (sent as `@silent` messages)",
EnabledDisabled(ctx.GuildConfig!.SuppressNotifications),
"disabled"
"When proxied messages will have notifications suppressed (sent as `@silent` messages)",
ctx.GuildConfig!.SuppressNotifications.ToUserString(),
"never"
));
items.Add(new(
@ -438,13 +438,38 @@ public class ServerConfig
if (!ctx.HasNext())
{
var msg = $"Suppressing notifications for proxied messages is currently **{EnabledDisabled(ctx.GuildConfig!.SuppressNotifications)}**.";
var msg = $"Suppressing notifications for proxied messages is currently set to **{ctx.GuildConfig!.SuppressNotifications.ToUserString()}**. Proxied messages will ";
switch (ctx.GuildConfig!.SuppressNotifications)
{
case GuildConfig.SuppressCondition.Never:
msg += "never be marked as silent.";
break;
case GuildConfig.SuppressCondition.Always:
msg += "always be marked as silent.";
break;
case GuildConfig.SuppressCondition.Match:
msg += "be marked as silent if the trigger message was marked as silent.";
break;
case GuildConfig.SuppressCondition.Invert:
msg += "be marked as silent if the trigger message was **not** marked as silent.";
break;
}
await ctx.Reply(msg);
return;
}
var newVal = ctx.MatchToggle(false);
var newVal = GuildConfig.SuppressCondition.Never;
if (ctx.Match("on", "always", "silent", "suppress"))
newVal = GuildConfig.SuppressCondition.Always;
else if (ctx.Match("match", "same", "inherit"))
newVal = GuildConfig.SuppressCondition.Match;
else if (ctx.Match("invert", "opposite"))
newVal = GuildConfig.SuppressCondition.Invert;
else if (!ctx.Match("off", "never", "disable", "disabled"))
{
throw new PKError("You must pass one of \"always\", \"never\", \"match\", or \"invert\" to this command.");
}
await ctx.Repository.UpdateGuild(ctx.Guild.Id, new() { SuppressNotifications = newVal });
await ctx.Reply($"Suppressing notifications for proxied messages is now {EnabledDisabled(newVal)}.");
await ctx.Reply($"Suppressing notifications for proxied messages is now set to {newVal.ToUserString()}.");
}
}

View file

@ -242,7 +242,15 @@ public class ProxyService
var tts = match.Member.Tts && senderPermissions.HasFlag(PermissionSet.SendTtsMessages);
Message.MessageFlags flags = 0;
if (ctx.SuppressNotifications)
// If the guild suppress notifications condition is set to Always
if (ctx.SuppressNotifications == GuildConfig.SuppressCondition.Always ||
// OR if it is set to Match and the trigger message was silent
(ctx.SuppressNotifications == GuildConfig.SuppressCondition.Match &&
trigger.Flags.HasFlag(Message.MessageFlags.SuppressNotifications)) ||
// OR if it is set to Invert and the trigger message wasn't silent
(ctx.SuppressNotifications == GuildConfig.SuppressCondition.Invert &&
!trigger.Flags.HasFlag(Message.MessageFlags.SuppressNotifications)))
// Make the proxied message silent
flags |= Message.MessageFlags.SuppressNotifications;
if (trigger.Flags.HasFlag(Message.MessageFlags.VoiceMessage))
flags |= Message.MessageFlags.VoiceMessage;