From d9593a92f2617ee2b63c35fd72c58270a0664b6b Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sat, 15 Nov 2025 11:38:52 -0600 Subject: [PATCH 1/5] Avoid flooding in TipModule.cs Protect !listtips from flooding once the number of tips is too high. --- DiscordBot/Modules/TipModule.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/DiscordBot/Modules/TipModule.cs b/DiscordBot/Modules/TipModule.cs index f3725f8e..bd66d909 100644 --- a/DiscordBot/Modules/TipModule.cs +++ b/DiscordBot/Modules/TipModule.cs @@ -149,6 +149,8 @@ public async Task ListTips(params string[] keywords) if (!IsAuthorized(user)) return; + int floodCount = 20; + List tips = null; if (keywords?.Length > 0) { @@ -159,11 +161,27 @@ public async Task ListTips(params string[] keywords) await ReplyAsync("No tips for the keywords provided were found.").DeleteAfterSeconds(5); return; } + if (tips.Count >= floodCount) + { + await ReplyAsync("Too many tips found for the keywords provided; refine your search.").DeleteAfterSeconds(5); + return; + } } else { tips = TipService.GetAllTips().OrderBy(t => t.Id).ToList(); + if (tips.Count >= floodCount) + { + var terms = new HashSet(); + foreach (var tip in tips) + foreach (var term in tip.Keywords) + terms.Add(term); + var termList = string.Join("`, `", terms.OrderBy(k => k)); + await ReplyAsync("Too many tips found, add one or more keywords to narrow the list.\n`{terms}`").DeleteAfterSeconds(5); + return; + } } + int chunkCount = 10; int chunkTime = 1500; bool first = true; From cac93858fb7aaf75e3cbf8418f8a1b43f08019b5 Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sat, 15 Nov 2025 11:42:25 -0600 Subject: [PATCH 2/5] Update TipModule.cs --- DiscordBot/Modules/TipModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DiscordBot/Modules/TipModule.cs b/DiscordBot/Modules/TipModule.cs index bd66d909..2a693ec7 100644 --- a/DiscordBot/Modules/TipModule.cs +++ b/DiscordBot/Modules/TipModule.cs @@ -149,7 +149,7 @@ public async Task ListTips(params string[] keywords) if (!IsAuthorized(user)) return; - int floodCount = 20; + int floodCount = 12; List tips = null; if (keywords?.Length > 0) @@ -177,7 +177,7 @@ public async Task ListTips(params string[] keywords) foreach (var term in tip.Keywords) terms.Add(term); var termList = string.Join("`, `", terms.OrderBy(k => k)); - await ReplyAsync("Too many tips found, add one or more keywords to narrow the list.\n`{terms}`").DeleteAfterSeconds(5); + await ReplyAsync("Too many tips found, add one or more keywords to narrow the search.\n`{terms}`"); return; } } From 9b9b2699d115069b1deaf0d8ebd87bfc5d257e6e Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sat, 15 Nov 2025 11:49:01 -0600 Subject: [PATCH 3/5] Update TipModule.cs --- DiscordBot/Modules/TipModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DiscordBot/Modules/TipModule.cs b/DiscordBot/Modules/TipModule.cs index 2a693ec7..00d1ef0d 100644 --- a/DiscordBot/Modules/TipModule.cs +++ b/DiscordBot/Modules/TipModule.cs @@ -177,7 +177,7 @@ public async Task ListTips(params string[] keywords) foreach (var term in tip.Keywords) terms.Add(term); var termList = string.Join("`, `", terms.OrderBy(k => k)); - await ReplyAsync("Too many tips found, add one or more keywords to narrow the search.\n`{terms}`"); + await ReplyAsync($"Too many tips found, add one or more keywords to narrow the search.\n`{terms}`"); return; } } From d22c14ad5623ba45b6b20cac76d44cae9a8869f7 Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sat, 15 Nov 2025 11:54:26 -0600 Subject: [PATCH 4/5] Update TipModule.cs --- DiscordBot/Modules/TipModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DiscordBot/Modules/TipModule.cs b/DiscordBot/Modules/TipModule.cs index 00d1ef0d..e29147e3 100644 --- a/DiscordBot/Modules/TipModule.cs +++ b/DiscordBot/Modules/TipModule.cs @@ -177,7 +177,7 @@ public async Task ListTips(params string[] keywords) foreach (var term in tip.Keywords) terms.Add(term); var termList = string.Join("`, `", terms.OrderBy(k => k)); - await ReplyAsync($"Too many tips found, add one or more keywords to narrow the search.\n`{terms}`"); + await ReplyAsync($"Total of {tips.Count} tips found, add one or more keywords to narrow the search.\n`{termList}`"); return; } } From 98d868ef3628cfd87bb41ee772136bae5fcc80c2 Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sat, 15 Nov 2025 12:03:31 -0600 Subject: [PATCH 5/5] Update TipModule.cs --- DiscordBot/Modules/TipModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DiscordBot/Modules/TipModule.cs b/DiscordBot/Modules/TipModule.cs index e29147e3..c5350d85 100644 --- a/DiscordBot/Modules/TipModule.cs +++ b/DiscordBot/Modules/TipModule.cs @@ -149,7 +149,7 @@ public async Task ListTips(params string[] keywords) if (!IsAuthorized(user)) return; - int floodCount = 12; + int floodCount = 20; List tips = null; if (keywords?.Length > 0) @@ -163,7 +163,7 @@ public async Task ListTips(params string[] keywords) } if (tips.Count >= floodCount) { - await ReplyAsync("Too many tips found for the keywords provided; refine your search.").DeleteAfterSeconds(5); + await ReplyAsync($"Total of {tips.Count} tips found for the keywords provided; refine your search.").DeleteAfterSeconds(5); return; } }