Add disabling front/latch autoproxy per-member
This commit is contained in:
parent
7f82a3e63a
commit
41247c68a6
@ -42,6 +42,7 @@ namespace PluralKit.Bot
|
||||
public static Command MemberServerAvatar = new Command("member serveravatar", "member <member> serveravatar [url|@mention]", "Changes a member's avatar in the current server");
|
||||
public static Command MemberDisplayName = new Command("member displayname", "member <member> displayname [display name]", "Changes a member's display name");
|
||||
public static Command MemberServerName = new Command("member servername", "member <member> servername [server name]", "Changes a member's display name in the current server");
|
||||
public static Command MemberAutoproxy = new Command("member autoproxy", "member <member> autoproxy [on|off]", "Sets whether a member will be autoproxied when autoproxy is set to latch or front mode.");
|
||||
public static Command MemberKeepProxy = new Command("member keepproxy", "member <member> keepproxy [on|off]", "Sets whether to include a member's proxy tags when proxying");
|
||||
public static Command MemberRandom = new Command("random", "random", "Looks up a random member from your system");
|
||||
public static Command MemberPrivacy = new Command("member privacy", "member <member> privacy <name|description|birthday|pronouns|metadata|visibility|all> <public|private>", "Changes a members's privacy settings");
|
||||
@ -89,7 +90,7 @@ namespace PluralKit.Bot
|
||||
|
||||
public static Command[] MemberCommands = {
|
||||
MemberInfo, MemberNew, MemberRename, MemberDisplayName, MemberServerName, MemberDesc, MemberPronouns,
|
||||
MemberColor, MemberBirthday, MemberProxy, MemberKeepProxy, MemberDelete, MemberAvatar, MemberServerAvatar, MemberPrivacy,
|
||||
MemberColor, MemberBirthday, MemberProxy, MemberAutoproxy, MemberKeepProxy, MemberDelete, MemberAvatar, MemberServerAvatar, MemberPrivacy,
|
||||
MemberRandom
|
||||
};
|
||||
|
||||
@ -334,6 +335,8 @@ namespace PluralKit.Bot
|
||||
await ctx.Execute<MemberEdit>(MemberDisplayName, m => m.DisplayName(ctx, target));
|
||||
else if (ctx.Match("servername", "sn", "sname", "snick", "snickname", "servernick", "servernickname", "serverdisplayname", "guildname", "guildnick", "guildnickname", "serverdn"))
|
||||
await ctx.Execute<MemberEdit>(MemberServerName, m => m.ServerName(ctx, target));
|
||||
else if (ctx.Match("autoproxy", "ap"))
|
||||
await ctx.Execute<MemberEdit>(MemberAutoproxy, m => m.MemberAutoproxy(ctx, target));
|
||||
else if (ctx.Match("keepproxy", "keeptags", "showtags"))
|
||||
await ctx.Execute<MemberEdit>(MemberKeepProxy, m => m.KeepProxy(ctx, target));
|
||||
else if (ctx.Match("privacy"))
|
||||
|
@ -373,6 +373,33 @@ namespace PluralKit.Bot
|
||||
await ctx.Reply($"{Emojis.Success} Member proxy tags will now not be included in the resulting message when proxying.");
|
||||
}
|
||||
|
||||
public async Task MemberAutoproxy(Context ctx, PKMember target)
|
||||
{
|
||||
if (ctx.System == null) throw Errors.NoSystemError;
|
||||
if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError;
|
||||
|
||||
bool newValue;
|
||||
if (ctx.Match("on", "enabled", "true", "yes") || ctx.MatchFlag("on", "enabled", "true", "yes")) newValue = true;
|
||||
else if (ctx.Match("off", "disabled", "false", "no") || ctx.MatchFlag("off", "disabled", "false", "no")) newValue = false;
|
||||
else if (ctx.HasNext()) throw new PKSyntaxError("You must pass either \"on\" or \"off\".");
|
||||
else
|
||||
{
|
||||
if (target.AllowAutoproxy)
|
||||
await ctx.Reply("Latch/front autoproxy are **enabled** for this member. This member will be automatically proxied when autoproxy is set to latch or front mode.");
|
||||
else
|
||||
await ctx.Reply("Latch/front autoproxy are **disabled** for this member. This member will not be automatically proxied when autoproxy is set to latch or front mode.");
|
||||
return;
|
||||
};
|
||||
|
||||
var patch = new MemberPatch {AllowAutoproxy = Partial<bool>.Present(newValue)};
|
||||
await _db.Execute(conn => _repo.UpdateMember(conn, target.Id, patch));
|
||||
|
||||
if (newValue)
|
||||
await ctx.Reply($"{Emojis.Success} Latch / front autoproxy have been **enabled** for this member.");
|
||||
else
|
||||
await ctx.Reply($"{Emojis.Success} Latch / front autoproxy have been **disabled** for this member.");
|
||||
}
|
||||
|
||||
public async Task Privacy(Context ctx, PKMember target, PrivacyLevel? newValueFromCommand)
|
||||
{
|
||||
if (ctx.System == null) throw Errors.NoSystemError;
|
||||
|
@ -62,7 +62,7 @@ namespace PluralKit.Bot
|
||||
_ => null
|
||||
};
|
||||
|
||||
if (member == null) return false;
|
||||
if (member == null || (ctx.AutoproxyMode != AutoproxyMode.Member && !member.AllowAutoproxy)) return false;
|
||||
match = new ProxyMatch
|
||||
{
|
||||
Content = messageContent,
|
||||
|
@ -19,7 +19,7 @@ namespace PluralKit.Core
|
||||
internal class Database: IDatabase
|
||||
{
|
||||
private const string RootPath = "PluralKit.Core.Database"; // "resource path" root for SQL files
|
||||
private const int TargetSchemaVersion = 11;
|
||||
private const int TargetSchemaVersion = 12;
|
||||
|
||||
private readonly CoreConfig _config;
|
||||
private readonly ILogger _logger;
|
||||
|
@ -19,6 +19,8 @@ namespace PluralKit.Core
|
||||
public string? ServerAvatar { get; }
|
||||
public string? Avatar { get; }
|
||||
|
||||
public bool AllowAutoproxy { get; }
|
||||
|
||||
public string ProxyName(MessageContext ctx) => ctx.SystemTag != null
|
||||
? $"{ServerName ?? DisplayName ?? Name} {ctx.SystemTag}"
|
||||
: ServerName ?? DisplayName ?? Name;
|
||||
|
@ -62,7 +62,9 @@ create function proxy_members(account_id bigint, guild_id bigint)
|
||||
name text,
|
||||
|
||||
server_avatar text,
|
||||
avatar text
|
||||
avatar text,
|
||||
|
||||
allow_autoproxy bool
|
||||
)
|
||||
as $$
|
||||
select
|
||||
@ -78,7 +80,9 @@ as $$
|
||||
|
||||
-- Avatar info
|
||||
member_guild.avatar_url as server_avatar,
|
||||
members.avatar_url as avatar
|
||||
members.avatar_url as avatar,
|
||||
|
||||
members.allow_autoproxy as allow_autoproxy
|
||||
from accounts
|
||||
inner join systems on systems.id = accounts.system
|
||||
inner join members on members.system = systems.id
|
||||
|
5
PluralKit.Core/Database/Migrations/12.sql
Normal file
5
PluralKit.Core/Database/Migrations/12.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- SCHEMA VERSION 12: <insert date> --
|
||||
-- Add disabling front/latch autoproxy per-member --
|
||||
|
||||
alter table members add column allow_autoproxy bool not null default true;
|
||||
update info set schema_version = 12;
|
@ -24,6 +24,7 @@ namespace PluralKit.Core {
|
||||
public bool KeepProxy { get; private set; }
|
||||
public Instant Created { get; private set; }
|
||||
public int MessageCount { get; private set; }
|
||||
public bool AllowAutoproxy { get; private set; }
|
||||
|
||||
public PrivacyLevel MemberVisibility { get; private set; }
|
||||
public PrivacyLevel DescriptionPrivacy { get; private set; }
|
||||
|
@ -16,6 +16,7 @@ namespace PluralKit.Core
|
||||
public Partial<ProxyTag[]> ProxyTags { get; set; }
|
||||
public Partial<bool> KeepProxy { get; set; }
|
||||
public Partial<int> MessageCount { get; set; }
|
||||
public Partial<bool> AllowAutoproxy { get; set; }
|
||||
public Partial<PrivacyLevel> Visibility { get; set; }
|
||||
public Partial<PrivacyLevel> NamePrivacy { get; set; }
|
||||
public Partial<PrivacyLevel> DescriptionPrivacy { get; set; }
|
||||
@ -35,6 +36,7 @@ namespace PluralKit.Core
|
||||
.With("proxy_tags", ProxyTags)
|
||||
.With("keep_proxy", KeepProxy)
|
||||
.With("message_count", MessageCount)
|
||||
.With("allow_autoproxy", AllowAutoproxy)
|
||||
.With("member_visibility", Visibility)
|
||||
.With("name_privacy", NamePrivacy)
|
||||
.With("description_privacy", DescriptionPrivacy)
|
||||
|
@ -49,6 +49,7 @@ Words in **\<angle brackets>** or **[square brackets]** mean fill-in-the-blank.
|
||||
- `pk;member <name> proxy [tags]` - Changes the proxy tags of a member. use below add/remove commands for members with multiple tag pairs.
|
||||
- `pk;member <name> proxy add [tags]` - Adds a proxy tag pair to a member.
|
||||
- `pk;member <name> proxy remove [tags]` - Removes a proxy tag from a member.
|
||||
- `pk;member <name> autoproxy [on|off]` - Sets whether a member will be autoproxied when autoproxy is set to latch or front mode.
|
||||
- `pk;member <name> keepproxy [on|off]` - Sets whether to include a member's proxy tags in the proxied message.
|
||||
- `pk;member <name> pronouns [pronouns]` - Changes the pronouns of a member.
|
||||
- `pk;member <name> color [color]` - Changes the color of a member.
|
||||
|
@ -347,6 +347,18 @@ To enable member-mode autoproxying for a given server, use the following command
|
||||
|
||||
pk;autoproxy <member>
|
||||
|
||||
### Disabling front/latch autoproxy on a per-member basis
|
||||
If a system uses front or latch mode autoproxy, but one member prefers to send messages through the account (and not proxy), you can disable the front and latch modes for that specific member.
|
||||
|
||||
pk;member <name> autoproxy off
|
||||
|
||||
To re-enable front / latch modes for that member, use the following command:
|
||||
|
||||
pk;member <name> autoproxy on
|
||||
|
||||
This will *not* disable member mode autoproxy. If you do not wish to autoproxy, please turn off autoproxy instead of setting autoproxy to a specific member.
|
||||
|
||||
|
||||
## Managing switches
|
||||
PluralKit allows you to log member switches through the bot.
|
||||
Essentially, this means you can mark one or more members as *the current fronter(s)* for the duration until the next switch.
|
||||
|
Loading…
Reference in New Issue
Block a user