From c0b6c6ced335ec1700e5ce4d5feae568c425fed8 Mon Sep 17 00:00:00 2001 From: Marwan ZOGHLAMI Date: Wed, 21 Feb 2024 10:07:58 +0100 Subject: [PATCH 1/2] feat(quoi-feur): cumulative streak punishment and prevent mute evading To improve fun:tm: and punish players in the most efficient way, the mute is now an accumulation of how many times "quoi" has been said since the last timeout. e.g.: An "akhy" spam "quoi" 10 times and didn't get a timeout, then another random try to say "quoi" and got chosen by the "pseudo-randomness": he will be muted for 11 minutes The second feature is to prevent cheat by muting before displaying "coubeh". Some users just delete their messages before they get muted by the bot. --- src/core/cache.ts | 1 + src/modules/quoiFeur/quoiFeur.helpers.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/cache.ts b/src/core/cache.ts index f84ecad..c3ebfd4 100644 --- a/src/core/cache.ts +++ b/src/core/cache.ts @@ -23,6 +23,7 @@ interface Cache> { interface CacheEntries { lobbyIds: string[]; onDemandChannels: string[]; + quoiAccumulation: number; quoiFeurChannels: string[]; recurringMessages: { id: string; channelId: string; frequency: Frequency; message: string }[]; } diff --git a/src/modules/quoiFeur/quoiFeur.helpers.ts b/src/modules/quoiFeur/quoiFeur.helpers.ts index 417c7bb..fa076d9 100644 --- a/src/modules/quoiFeur/quoiFeur.helpers.ts +++ b/src/modules/quoiFeur/quoiFeur.helpers.ts @@ -38,6 +38,7 @@ export const reactOnEndWithQuoi = async (message: Message) => { if (!endWithQuoi(message.content)) return; const channelIds = await cache.get('quoiFeurChannels', []); + const accumulation = await cache.get('quoiAccumulation', 1); const messageParentId = message.channel.type === ChannelType.PublicThread ? message.channel.parentId : null; @@ -51,14 +52,17 @@ export const reactOnEndWithQuoi = async (message: Message) => { const probability = 1 / 6; if (Math.random() <= probability) { - await reactWithCoubeh(message); await message.member?.timeout( - ONE_MINUTE * 5, + ONE_MINUTE * accumulation, `${message.member.displayName} have the cramptés`, ); + await cache.set('quoiAccumulation', 1); + await reactWithCoubeh(message); + return; } + await cache.set('quoiAccumulation', accumulation + 1); await reactWithFeur(message); }; From 0c9cd9b24fb4571752d777a88c50372e1d7fd0cc Mon Sep 17 00:00:00 2001 From: Automne von Einzbern Date: Wed, 21 Feb 2024 10:07:58 +0100 Subject: [PATCH 2/2] feat(quoi-feur): cumulative streak punishment and prevent mute evading To improve fun:tm: and punish players in the most efficient way, the mute is now an accumulation of how many times "quoi" has been said since the last timeout. e.g.: An "akhy" spam "quoi" 10 times and didn't get a timeout, then another random try to say "quoi" and got chosen by the "pseudo-randomness": he will be muted for 11 minutes The second feature is to prevent cheat by muting before displaying "coubeh". Some users just delete their messages before they get muted by the bot. --- src/core/cache.ts | 1 + src/modules/quoiFeur/quoiFeur.helpers.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/cache.ts b/src/core/cache.ts index f84ecad..c3ebfd4 100644 --- a/src/core/cache.ts +++ b/src/core/cache.ts @@ -23,6 +23,7 @@ interface Cache> { interface CacheEntries { lobbyIds: string[]; onDemandChannels: string[]; + quoiAccumulation: number; quoiFeurChannels: string[]; recurringMessages: { id: string; channelId: string; frequency: Frequency; message: string }[]; } diff --git a/src/modules/quoiFeur/quoiFeur.helpers.ts b/src/modules/quoiFeur/quoiFeur.helpers.ts index 417c7bb..fa076d9 100644 --- a/src/modules/quoiFeur/quoiFeur.helpers.ts +++ b/src/modules/quoiFeur/quoiFeur.helpers.ts @@ -38,6 +38,7 @@ export const reactOnEndWithQuoi = async (message: Message) => { if (!endWithQuoi(message.content)) return; const channelIds = await cache.get('quoiFeurChannels', []); + const accumulation = await cache.get('quoiAccumulation', 1); const messageParentId = message.channel.type === ChannelType.PublicThread ? message.channel.parentId : null; @@ -51,14 +52,17 @@ export const reactOnEndWithQuoi = async (message: Message) => { const probability = 1 / 6; if (Math.random() <= probability) { - await reactWithCoubeh(message); await message.member?.timeout( - ONE_MINUTE * 5, + ONE_MINUTE * accumulation, `${message.member.displayName} have the cramptés`, ); + await cache.set('quoiAccumulation', 1); + await reactWithCoubeh(message); + return; } + await cache.set('quoiAccumulation', accumulation + 1); await reactWithFeur(message); };