From c166c83999de4256718f6ad202a29e8355232f1e Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sat, 22 Nov 2025 12:29:41 -0600 Subject: [PATCH 1/4] Add another UserService.cs content detector A special content detector gives a special reply --- DiscordBot/Services/UserService.cs | 42 +++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/DiscordBot/Services/UserService.cs b/DiscordBot/Services/UserService.cs index 2d5ccea6..4bb14d73 100644 --- a/DiscordBot/Services/UserService.cs +++ b/DiscordBot/Services/UserService.cs @@ -41,8 +41,13 @@ public class UserService private readonly int _thanksCooldownTime; private readonly int _thanksMinJoinTime; - private readonly string _thanksRegex; + + private readonly DateTime _mikuMentioned; + private readonly int _mikuCooldownTime; + private readonly string _mikuRegex; + private readonly string _mikuReply; + private readonly UpdateService _updateService; private readonly Dictionary _xpCooldown; @@ -106,6 +111,16 @@ Init thanks _thanksCooldownTime = userSettings.ThanksCooldown; _thanksMinJoinTime = userSettings.ThanksMinJoinTime; + /* + Init Miku + */ + _mikuMentioned = DateTime.Now; + //_mikuCooldownTime = new TimeSpan(0, 39, 0); + _mikuCooldownTime = new TimeSpan(0, 0, 39); + _mikuRegex = @"(?i)\b(miku|hatsune|初音ミク|初音|ミク)\b"; + //_mikuReply = "Oi, mite, mite, <@358915848515354626> -chan! :three: :nine:"; + _mikuReply = "Oi, mite, mite, <@427306565184389132> ! :three: :nine:"; + /* Init Code analysis */ @@ -140,6 +155,7 @@ Event subscriptions _client.MessageReceived += UpdateXp; _client.MessageReceived += Thanks; _client.MessageUpdated += ThanksEdited; + _client.MessageReceived += MikuCheck; _client.MessageReceived += CodeCheck; _client.MessageReceived += ScoldForAtEveryoneUsage; _client.MessageReceived += AutoCreateThread; @@ -503,6 +519,30 @@ await messageParam.Channel.SendMessageAsync( } } + public async Task MikuCheck(SocketMessage messageParam) + { + //Get guild id + var channel = (SocketGuildChannel)messageParam.Channel; + var guildId = channel.Guild.Id; + + //Make sure its in the UDC server + if (guildId != _settings.GuildId) return; + + if (messageParam.Author.IsBot) + return; + + var now = DateTime.Now; + if ((DateTime.Now - _mikuMentioned) < _mikuCooldownTime) + return; + + var match = Regex.Match(messageParam.Content, _mikuRegex); + if (!match.Success) + return; + + _mikuMentioned = now; + await messageParam.Channel.SendMessageAsync(_mikuReply); + } + public async Task CodeCheck(SocketMessage messageParam) { // Don't correct a Bot, don't correct in off-topic From e8a00f3d9269c5b6d8f359dba0201947df90d38a Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sat, 22 Nov 2025 12:31:23 -0600 Subject: [PATCH 2/4] Update UserService.cs --- DiscordBot/Services/UserService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DiscordBot/Services/UserService.cs b/DiscordBot/Services/UserService.cs index 4bb14d73..a5ab060f 100644 --- a/DiscordBot/Services/UserService.cs +++ b/DiscordBot/Services/UserService.cs @@ -44,7 +44,7 @@ public class UserService private readonly string _thanksRegex; private readonly DateTime _mikuMentioned; - private readonly int _mikuCooldownTime; + private readonly TimeSpan _mikuCooldownTime; private readonly string _mikuRegex; private readonly string _mikuReply; From 89bbce968ceccae5c48176a4098f64f229a0346a Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sat, 22 Nov 2025 12:33:58 -0600 Subject: [PATCH 3/4] Update UserService.cs --- DiscordBot/Services/UserService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DiscordBot/Services/UserService.cs b/DiscordBot/Services/UserService.cs index a5ab060f..051f7ebd 100644 --- a/DiscordBot/Services/UserService.cs +++ b/DiscordBot/Services/UserService.cs @@ -43,7 +43,7 @@ public class UserService private readonly int _thanksMinJoinTime; private readonly string _thanksRegex; - private readonly DateTime _mikuMentioned; + private DateTime _mikuMentioned; private readonly TimeSpan _mikuCooldownTime; private readonly string _mikuRegex; private readonly string _mikuReply; From 709bdb92aea6fb19cc4eaacf3adc82c5cd3efaf5 Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sat, 22 Nov 2025 12:43:29 -0600 Subject: [PATCH 4/4] Update UserService.cs --- DiscordBot/Services/UserService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DiscordBot/Services/UserService.cs b/DiscordBot/Services/UserService.cs index 051f7ebd..6fc7bbba 100644 --- a/DiscordBot/Services/UserService.cs +++ b/DiscordBot/Services/UserService.cs @@ -113,13 +113,14 @@ Init thanks /* Init Miku + Gag feature has no external settings, hardcoded userid refers to Reenaki/Kiki. */ _mikuMentioned = DateTime.Now; - //_mikuCooldownTime = new TimeSpan(0, 39, 0); - _mikuCooldownTime = new TimeSpan(0, 0, 39); + _mikuCooldownTime = new TimeSpan(0, 39, 0); // 39min + //_mikuCooldownTime = new TimeSpan(0, 0, 39); // test 39sec _mikuRegex = @"(?i)\b(miku|hatsune|初音ミク|初音|ミク)\b"; - //_mikuReply = "Oi, mite, mite, <@358915848515354626> -chan! :three: :nine:"; - _mikuReply = "Oi, mite, mite, <@427306565184389132> ! :three: :nine:"; + _mikuReply = ":three: :nine: Oi, mite, mite, <@358915848515354626> -chan!"; + //_mikuReply = "Oi, mite, mite, <@427306565184389132> ! :three: :nine:"; // test /* Init Code analysis