Add per-server per-system proxy enable toggle

This commit is contained in:
Ske
2019-12-22 14:15:56 +01:00
parent 857b0488b9
commit 639c813ce7
5 changed files with 62 additions and 5 deletions

View File

@@ -90,11 +90,15 @@ namespace PluralKit.Bot
// And make sure the channel's not blacklisted from proxying.
var guildCfg = await _data.GetOrCreateGuildConfig(channel.GuildId);
if (guildCfg.Blacklist.Contains(channel.Id)) return;
// Make sure the system hasn't blacklisted the guild either
var systemGuildCfg = await _data.GetSystemGuildSettings(match.System, channel.GuildId);
if (!systemGuildCfg.ProxyEnabled) return;
// We know message.Channel can only be ITextChannel as PK doesn't work in DMs/groups
// Afterwards we ensure the bot has the right permissions, otherwise bail early
if (!await EnsureBotPermissions(channel)) return;
// Can't proxy a message with no content and no attachment
if (match.InnerText.Trim().Length == 0 && message.Attachments.Count == 0)
return;