Skip to content

Commit

Permalink
I'm sorry
Browse files Browse the repository at this point in the history
Signed-off-by: Wiibleyde <nathan@bonnell.fr>
  • Loading branch information
Wiibleyde committed Dec 6, 2024
1 parent 637f459 commit 4c54696
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/events/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { config } from "@/config"
import { isMessageQuizQuestion } from "@/commands/fun/quiz/quiz"
import { generateWithGoogle } from "@/utils/intelligence"
import { backSpace } from "@/utils/textUtils"
import { detectFeur, generateResponse } from "@/utils/messageManager"

client.on(Events.InteractionCreate, async (interaction) => {
if (interaction.isCommand()) {
Expand Down Expand Up @@ -88,4 +89,8 @@ client.on(Events.MessageCreate, async (message) => {
logger.info(`Réponse de l'IA à <@${message.author.id}> dans <#${channelId}> : ${aiReponse}`)
}
}

if(detectFeur(message.content)) {
message.channel.send(generateResponse())
}
})
53 changes: 53 additions & 0 deletions src/utils/messageManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const quoiRegexs = [
// Quoi
/quoi/,
/quoi\?/,
/quoi\ ?/,
/quoi\ ?\?/,
/quoi\ ?\?/,


// Koa
/koa/,
/koa\?/,
/koa\ ?/,
/koa\ ?\?/,
/koa\ ?\?/,
]

export const possibleResponses = [
{
response: "Feur.",
probability: 80
},
{
response: "coubeh.",
probability: 10
},
{
response: "drilatère.",
probability: 10
}
]


export function detectFeur(message: string): boolean {
for (const regex of quoiRegexs) {
if (regex.test(message.toLowerCase())) {
return true
}
}
return false
}

export function generateResponse(): string {
const random = Math.random() * 100
let cumulativeProbability = 0
for (const response of possibleResponses) {
cumulativeProbability += response.probability
if (random <= cumulativeProbability) {
return response.response
}
}
return "Feur."
}

0 comments on commit 4c54696

Please sign in to comment.