diff --git a/CompatBot/Config.cs b/CompatBot/Config.cs index d1eefee3..d256443b 100644 --- a/CompatBot/Config.cs +++ b/CompatBot/Config.cs @@ -57,7 +57,7 @@ internal static class Config public static TimeSpan SocketDisconnectCheckIntervalInSec => TimeSpan.FromSeconds(config.GetValue(nameof(SocketDisconnectCheckIntervalInSec), 10)); public static TimeSpan LogParsingTimeoutInSec => TimeSpan.FromSeconds(config.GetValue(nameof(LogParsingTimeoutInSec), 30)); public static TimeSpan BuildTimeDifferenceForOutdatedBuildsInDays => TimeSpan.FromDays(config.GetValue(nameof(BuildTimeDifferenceForOutdatedBuildsInDays), 3)); - public static TimeSpan ShutupTimeLimitInMin => TimeSpan.FromMinutes(config.GetValue(nameof(ShutupTimeLimitInMin), 5)); + public static TimeSpan ShutupTimeLimitInMin => TimeSpan.FromMinutes(config.GetValue(nameof(ShutupTimeLimitInMin), 15)); public static TimeSpan ForcedNicknamesRecheckTimeInHours => TimeSpan.FromHours(config.GetValue(nameof(ForcedNicknamesRecheckTimeInHours), 3)); public static TimeSpan IncomingMessageCheckIntervalInMin => TimeSpan.FromMinutes(config.GetValue(nameof(IncomingMessageCheckIntervalInMin), 10)); public static TimeSpan MetricsIntervalInSec => TimeSpan.FromSeconds(config.GetValue(nameof(MetricsIntervalInSec), 10)); diff --git a/CompatBot/EventHandlers/Starbucks.cs b/CompatBot/EventHandlers/Starbucks.cs index e028fab0..c4d584c1 100644 --- a/CompatBot/EventHandlers/Starbucks.cs +++ b/CompatBot/EventHandlers/Starbucks.cs @@ -115,6 +115,8 @@ internal static class Starbucks message = await channel.GetMessageAsync(message.Id).ConfigureAwait(false); if (emoji == Config.Reactions.Starbucks) await CheckMediaTalkAsync(client, channel, message, emoji).ConfigureAwait(false); + if (emoji == Config.Reactions.ShutUp && !isBacklog) + await ShutupAsync(client, user, message).ConfigureAwait(false); await CheckGameFansAsync(client, channel, message).ConfigureAwait(false); } catch (Exception e) @@ -159,6 +161,20 @@ internal static class Starbucks await client.ReportAsync(Config.Reactions.Starbucks + " Media talk report", message, reporters, null, ReportSeverity.Medium).ConfigureAwait(false); } + private static async ValueTask ShutupAsync(DiscordClient client, DiscordUser user, DiscordMessage message) + { + if (message.Author is null || message.Author.IsCurrent is false) + return; + + if (message.CreationTimestamp.Add(Config.ShutupTimeLimitInMin) < DateTime.UtcNow) + return; + + if (!await user.IsWhitelistedAsync(client, message.Channel?.Guild).ConfigureAwait(false)) + return; + + await message.DeleteAsync().ConfigureAwait(false); + } + private static async ValueTask CheckGameFansAsync(DiscordClient client, DiscordChannel channel, DiscordMessage message) { var bot = await client.GetMemberAsync(channel.Guild, client.CurrentUser).ConfigureAwait(false);