From 5e21260af3d156477e9cfa547a63ea3ddfd051d6 Mon Sep 17 00:00:00 2001 From: 2riniar Date: Thu, 28 Nov 2024 01:52:30 +0900 Subject: [PATCH] =?UTF-8?q?Silent:=20=E9=BB=99=E3=82=89=E3=81=9B=E3=82=8B?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=82=92=E3=82=AA=E3=83=9F=E3=83=83=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/Master/SettingMaster.cs | 1 - Common/Master/TriggerPhraseMaster.cs | 1 - Common/Models/SilentManager.cs | 23 ------------------- Events/Gacha/GachaRareReplyPresenter.cs | 6 +++-- .../Gacha/GachaRareReplySupressPresenter.cs | 17 -------------- Program.cs | 8 ++----- 6 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 Common/Models/SilentManager.cs delete mode 100644 Events/Gacha/GachaRareReplySupressPresenter.cs diff --git a/Common/Master/SettingMaster.cs b/Common/Master/SettingMaster.cs index 97775cc..24238fa 100644 --- a/Common/Master/SettingMaster.cs +++ b/Common/Master/SettingMaster.cs @@ -37,7 +37,6 @@ private int GetInt(string key) public int ReplyMaxDuration => GetInt(nameof(ReplyMaxDuration)); public int TypingMaxDuration => GetInt(nameof(TypingMaxDuration)); - public int SilentDuration => GetInt(nameof(SilentDuration)); public int DailyResetTime => GetInt(nameof(DailyResetTime)); public int MonthlyResetDay => GetInt(nameof(MonthlyResetDay)); public int BirthdayMonth => GetInt(nameof(BirthdayMonth)); diff --git a/Common/Master/TriggerPhraseMaster.cs b/Common/Master/TriggerPhraseMaster.cs index dd4fdc9..25aa487 100644 --- a/Common/Master/TriggerPhraseMaster.cs +++ b/Common/Master/TriggerPhraseMaster.cs @@ -9,7 +9,6 @@ public class TriggerPhraseMaster : MasterTable; public enum TriggerType { Unknown, - Silent, GachaExecute, GachaGet, Marugame, diff --git a/Common/Models/SilentManager.cs b/Common/Models/SilentManager.cs deleted file mode 100644 index 1664124..0000000 --- a/Common/Models/SilentManager.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Approvers.King.Common; - -public static class SilentManager -{ - private static readonly Dictionary SilentUsers = new(); - - /// - /// 一定時間黙らせる - /// - public static void SetSilent(ulong userId, TimeSpan timeSpan) - { - var expireTime = TimeManager.GetNow() + timeSpan; - SilentUsers[userId] = expireTime; - } - - /// - /// 黙っている最中か - /// - public static bool IsSilent(ulong userId) - { - return SilentUsers.TryGetValue(userId, out var expireTime) && !TimeManager.IsExpired(expireTime); - } -} diff --git a/Events/Gacha/GachaRareReplyPresenter.cs b/Events/Gacha/GachaRareReplyPresenter.cs index a57873f..1766d30 100644 --- a/Events/Gacha/GachaRareReplyPresenter.cs +++ b/Events/Gacha/GachaRareReplyPresenter.cs @@ -7,8 +7,10 @@ public class GachaRareReplyPresenter : DiscordMessagePresenterBase { protected override async Task MainAsync() { - if (SilentManager.IsSilent(Message.Author.Id) || - Message.Channel.Id != EnvironmentManager.DiscordMainChannelId) return; + if (Message.Channel.Id != EnvironmentManager.DiscordMainChannelId) + { + return; + } await using var app = AppService.CreateSession(); var user = await app.FindOrCreateUserAsync(Message.Author.Id); diff --git a/Events/Gacha/GachaRareReplySupressPresenter.cs b/Events/Gacha/GachaRareReplySupressPresenter.cs deleted file mode 100644 index 69dbc09..0000000 --- a/Events/Gacha/GachaRareReplySupressPresenter.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Approvers.King.Common; -using Discord; - -namespace Approvers.King.Events; - -public class GachaRareReplySupressPresenter : DiscordMessagePresenterBase -{ - protected override async Task MainAsync() - { - var silentTimeSpan = NumberUtility.GetTimeSpanFromMilliseconds(MasterManager.SettingMaster.SilentDuration); - SilentManager.SetSilent(Message.Author.Id, silentTimeSpan); - var message = string.Format( - MasterManager.SettingMaster.SilentReplyMessage, - MentionUtils.MentionUser(Message.Author.Id)); - await Message.ReplyAsync(message); - } -} diff --git a/Program.cs b/Program.cs index 5c2f5c6..e86ab54 100644 --- a/Program.cs +++ b/Program.cs @@ -35,7 +35,7 @@ private static async Task BuildAsync(string[] args) SchedulerManager.RegisterDaily(TimeManager.DailyResetTime); SchedulerManager.RegisterYearly(TimeManager.Birthday + TimeManager.DailyResetTime + - TimeSpan.FromSeconds(1)); + TimeSpan.FromSeconds(1)); SchedulerManager.RegisterMonthly(TimeManager.MonthlyResetDay, TimeManager.DailyResetTime); @@ -64,12 +64,8 @@ private static void OnMessageReceived(SocketMessage message) return; } - if (TryExecuteMarugame(userMessage)) return; - - if (IsContainsTriggerPhrase(userMessage.Content, TriggerType.Silent)) + if (TryExecuteMarugame(userMessage)) { - // 黙らせる - DiscordManager.ExecuteAsync(userMessage).Run(); return; }