-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wiibleyde <nathan@bonnell.fr>
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | ||
} |