Add disabling reaction pings
This commit is contained in:
parent
216dfffe58
commit
59af6f02e8
@ -25,6 +25,7 @@ namespace PluralKit.Bot
|
|||||||
public static Command SystemFrontHistory = new Command("system fronthistory", "system [system] fronthistory", "Shows a system's front history");
|
public static Command SystemFrontHistory = new Command("system fronthistory", "system [system] fronthistory", "Shows a system's front history");
|
||||||
public static Command SystemFrontPercent = new Command("system frontpercent", "system [system] frontpercent [timespan]", "Shows a system's front breakdown");
|
public static Command SystemFrontPercent = new Command("system frontpercent", "system [system] frontpercent [timespan]", "Shows a system's front breakdown");
|
||||||
public static Command SystemPrivacy = new Command("system privacy", "system privacy <description|members|fronter|fronthistory> <public|private>", "Changes your system's privacy settings");
|
public static Command SystemPrivacy = new Command("system privacy", "system privacy <description|members|fronter|fronthistory> <public|private>", "Changes your system's privacy settings");
|
||||||
|
public static Command SystemPing = new Command("system ping", "system ping <enable|disable>", "Changes your system's ping preferences");
|
||||||
public static Command Autoproxy = new Command("autoproxy", "autoproxy [off|front|latch|member]", "Sets your system's autoproxy mode for this server");
|
public static Command Autoproxy = new Command("autoproxy", "autoproxy [off|front|latch|member]", "Sets your system's autoproxy mode for this server");
|
||||||
public static Command MemberInfo = new Command("member", "member <member>", "Looks up information about a member");
|
public static Command MemberInfo = new Command("member", "member <member>", "Looks up information about a member");
|
||||||
public static Command MemberNew = new Command("member new", "member new <name>", "Creates a new member");
|
public static Command MemberNew = new Command("member new", "member new <name>", "Creates a new member");
|
||||||
@ -204,6 +205,8 @@ namespace PluralKit.Bot
|
|||||||
await ctx.Execute<SystemFront>(SystemFrontPercent, m => m.SystemFrontPercent(ctx, ctx.System));
|
await ctx.Execute<SystemFront>(SystemFrontPercent, m => m.SystemFrontPercent(ctx, ctx.System));
|
||||||
else if (ctx.Match("privacy"))
|
else if (ctx.Match("privacy"))
|
||||||
await ctx.Execute<SystemEdit>(SystemPrivacy, m => m.SystemPrivacy(ctx));
|
await ctx.Execute<SystemEdit>(SystemPrivacy, m => m.SystemPrivacy(ctx));
|
||||||
|
else if (ctx.Match("ping"))
|
||||||
|
await ctx.Execute<SystemEdit>(SystemPing, m => m.SystemPing(ctx));
|
||||||
else if (ctx.Match("commands", "help"))
|
else if (ctx.Match("commands", "help"))
|
||||||
await PrintCommandList(ctx, "systems", SystemCommands);
|
await PrintCommandList(ctx, "systems", SystemCommands);
|
||||||
else if (!ctx.HasNext()) // Bare command
|
else if (!ctx.HasNext()) // Bare command
|
||||||
@ -365,4 +368,4 @@ namespace PluralKit.Bot
|
|||||||
return $"System with ID `{input}` not found.";
|
return $"System with ID `{input}` not found.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,6 +312,29 @@ namespace PluralKit.Bot
|
|||||||
await ctx.Reply($"System {subjectStr} privacy has been set to **{levelStr}**. Other accounts will now {levelExplanation} your system {subjectStr}.");
|
await ctx.Reply($"System {subjectStr} privacy has been set to **{levelStr}**. Other accounts will now {levelExplanation} your system {subjectStr}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task SystemPing(Context ctx)
|
||||||
|
{
|
||||||
|
ctx.CheckSystem();
|
||||||
|
|
||||||
|
if (!ctx.HasNext())
|
||||||
|
{
|
||||||
|
if (ctx.System.Pings) {await ctx.Reply("Reaction pings are currently **enabled** for your system. To disable reaction pings, type `pk;s ping disable`.");}
|
||||||
|
else {await ctx.Reply("Reaction pings are currently **disabled** for your system. To enable reaction pings, type `pk;s ping enable`.");}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (ctx.Match("on", "enable")) {
|
||||||
|
ctx.System.Pings = true;
|
||||||
|
await _data.SaveSystem(ctx.System);
|
||||||
|
await ctx.Reply("Reaction pings have now been enabled.");
|
||||||
|
}
|
||||||
|
if (ctx.Match("off", "disable")) {
|
||||||
|
ctx.System.Pings = false;
|
||||||
|
await _data.SaveSystem(ctx.System);
|
||||||
|
await ctx.Reply("Reaction pings have now been disabled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<DateTimeZone> FindTimeZone(Context ctx, string zoneStr) {
|
public async Task<DateTimeZone> FindTimeZone(Context ctx, string zoneStr) {
|
||||||
// First, if we're given a flag emoji, we extract the flag emoji code from it.
|
// First, if we're given a flag emoji, we extract the flag emoji code from it.
|
||||||
zoneStr = Core.StringUtils.ExtractCountryFlag(zoneStr) ?? zoneStr;
|
zoneStr = Core.StringUtils.ExtractCountryFlag(zoneStr) ?? zoneStr;
|
||||||
@ -370,4 +393,4 @@ namespace PluralKit.Bot
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,9 +285,15 @@ namespace PluralKit.Bot
|
|||||||
var requiredPerms = Permissions.AccessChannels | Permissions.SendMessages;
|
var requiredPerms = Permissions.AccessChannels | Permissions.SendMessages;
|
||||||
if ((permissions & requiredPerms) != requiredPerms) return;
|
if ((permissions & requiredPerms) != requiredPerms) return;
|
||||||
|
|
||||||
|
if (!msg.System.Pings) {
|
||||||
|
await args.Channel.SendMessageAsync($"Hey <@{args.User.Id}>, {msg.Member.DisplayName ?? msg.Member.Name}'s system has disabled reaction pings. You can mention them by copy pasting the following message:");
|
||||||
|
await args.Channel.SendMessageAsync($"`<@{msg.Message.Sender}>`");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var embed = new DiscordEmbedBuilder().WithDescription($"[Jump to pinged message]({args.Message.JumpLink})");
|
var embed = new DiscordEmbedBuilder().WithDescription($"[Jump to pinged message]({args.Message.JumpLink})");
|
||||||
await args.Channel.SendMessageAsync($"Psst, **{msg.Member.DisplayName ?? msg.Member.Name}** (<@{msg.Message.Sender}>), you have been pinged by <@{args.User.Id}>.", embed: embed.Build());
|
await args.Channel.SendMessageAsync($"Psst, **{msg.Member.DisplayName ?? msg.Member.Name}** (<@{msg.Message.Sender}>), you have been pinged by <@{args.User.Id}>.", embed: embed.Build());
|
||||||
|
|
||||||
// Finally remove the original reaction (if we can)
|
// Finally remove the original reaction (if we can)
|
||||||
if (args.Channel.BotHasAllPermissions(Permissions.ManageMessages))
|
if (args.Channel.BotHasAllPermissions(Permissions.ManageMessages))
|
||||||
await args.Message.DeleteReactionAsync(args.Emoji, args.User);
|
await args.Message.DeleteReactionAsync(args.Emoji, args.User);
|
||||||
@ -359,4 +365,4 @@ namespace PluralKit.Bot
|
|||||||
await _data.DeleteMessagesBulk(args.Messages.Select(m => m.Id).ToList());
|
await _data.DeleteMessagesBulk(args.Messages.Select(m => m.Id).ToList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
-- SCHEMA VERSION 4: 2020-02-14
|
-- SCHEMA VERSION 5: 2020-02-14
|
||||||
alter table servers add column log_cleanup_enabled bool not null default false;
|
alter table servers add column log_cleanup_enabled bool not null default false;
|
||||||
update info set schema_version = 5;
|
update info set schema_version = 5;
|
3
PluralKit.Core/Migrations/6.sql
Executable file
3
PluralKit.Core/Migrations/6.sql
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
-- SCHEMA VERSION 6: 2020-03-21
|
||||||
|
alter table systems add column pings bool not null default true;
|
||||||
|
update info set schema_version = 6;
|
@ -17,11 +17,12 @@ namespace PluralKit.Core {
|
|||||||
[JsonIgnore] public string Token { get; set; }
|
[JsonIgnore] public string Token { get; set; }
|
||||||
[JsonProperty("created")] public Instant Created { get; set; }
|
[JsonProperty("created")] public Instant Created { get; set; }
|
||||||
[JsonProperty("tz")] public string UiTz { get; set; }
|
[JsonProperty("tz")] public string UiTz { get; set; }
|
||||||
public PrivacyLevel DescriptionPrivacy { get; set; }
|
[JsonProperty("ping")] public bool Pings { get; set; }
|
||||||
|
public PrivacyLevel DescriptionPrivacy { get; set; }
|
||||||
public PrivacyLevel MemberListPrivacy { get; set; }
|
public PrivacyLevel MemberListPrivacy { get; set; }
|
||||||
public PrivacyLevel FrontPrivacy { get; set; }
|
public PrivacyLevel FrontPrivacy { get; set; }
|
||||||
public PrivacyLevel FrontHistoryPrivacy { get; set; }
|
public PrivacyLevel FrontHistoryPrivacy { get; set; }
|
||||||
|
|
||||||
[JsonIgnore] public DateTimeZone Zone => DateTimeZoneProviders.Tzdb.GetZoneOrNull(UiTz);
|
[JsonIgnore] public DateTimeZone Zone => DateTimeZoneProviders.Tzdb.GetZoneOrNull(UiTz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ namespace PluralKit.Core {
|
|||||||
|
|
||||||
public async Task SaveSystem(PKSystem system) {
|
public async Task SaveSystem(PKSystem system) {
|
||||||
using (var conn = await _conn.Obtain())
|
using (var conn = await _conn.Obtain())
|
||||||
await conn.ExecuteAsync("update systems set name = @Name, description = @Description, tag = @Tag, avatar_url = @AvatarUrl, token = @Token, ui_tz = @UiTz, description_privacy = @DescriptionPrivacy, member_list_privacy = @MemberListPrivacy, front_privacy = @FrontPrivacy, front_history_privacy = @FrontHistoryPrivacy where id = @Id", system);
|
await conn.ExecuteAsync("update systems set name = @Name, description = @Description, tag = @Tag, avatar_url = @AvatarUrl, token = @Token, ui_tz = @UiTz, description_privacy = @DescriptionPrivacy, member_list_privacy = @MemberListPrivacy, front_privacy = @FrontPrivacy, front_history_privacy = @FrontHistoryPrivacy, pings = @Pings where id = @Id", system);
|
||||||
|
|
||||||
_logger.Information("Updated system {@System}", system);
|
_logger.Information("Updated system {@System}", system);
|
||||||
await _cache.InvalidateSystem(system);
|
await _cache.InvalidateSystem(system);
|
||||||
|
@ -11,7 +11,7 @@ using Serilog;
|
|||||||
namespace PluralKit.Core {
|
namespace PluralKit.Core {
|
||||||
public class SchemaService
|
public class SchemaService
|
||||||
{
|
{
|
||||||
private const int TargetSchemaVersion = 5;
|
private const int TargetSchemaVersion = 6;
|
||||||
|
|
||||||
private DbConnectionFactory _conn;
|
private DbConnectionFactory _conn;
|
||||||
private ILogger _logger;
|
private ILogger _logger;
|
||||||
|
Loading…
Reference in New Issue
Block a user