Compare commits
2 Commits
5b4b5d3c0f
...
dda9ba81ae
Author | SHA1 | Date |
---|---|---|
|
dda9ba81ae | |
|
8617ab9d8b |
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "schat2-clive",
|
||||
"version": "1.17.2",
|
||||
"version": "1.17.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "schat2-clive",
|
||||
"version": "1.17.2",
|
||||
"version": "1.17.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bhttp": "^1.2.8",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "schat2-clive",
|
||||
"version": "1.17.2",
|
||||
"version": "1.17.3",
|
||||
"description": "Game host for SChat 2-powered chat sites",
|
||||
"main": "src/app.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -13,7 +13,7 @@ const contemplations = [
|
|||
'Let\'s see...',
|
||||
];
|
||||
|
||||
const answers = {
|
||||
const answersByType = {
|
||||
positive: [
|
||||
'It is certain',
|
||||
'It is decidedly so',
|
||||
|
@ -42,6 +42,7 @@ const answers = {
|
|||
],
|
||||
};
|
||||
|
||||
const answers = Object.entries(answersByType).flatMap(([type, typeAnswers]) => typeAnswers.map((answer) => ({ answer, type })));
|
||||
const questions = new Map();
|
||||
|
||||
function purgeQuestions() {
|
||||
|
@ -65,13 +66,16 @@ async function onCommand(args, context) {
|
|||
? stringSimilarity.findBestMatch(question, Array.from(questions.keys())).bestMatch
|
||||
: null;
|
||||
|
||||
const answerType = similarQuestion?.rating > 0.5
|
||||
? questions.get(similarQuestion.target).answerType
|
||||
: Object.keys(answers)[crypto.randomInt(0, 3)];
|
||||
const similarQuestionType = similarQuestion?.rating > 0.6 && questions.get(similarQuestion.target)?.type;
|
||||
|
||||
const answer = answers[answerType][crypto.randomInt(0, answers[answerType].length)];
|
||||
const { answer, type } = similarQuestionType
|
||||
? {
|
||||
answer: answersByType[similarQuestionType][crypto.randomInt(0, answersByType[similarQuestionType].length)],
|
||||
type: similarQuestionType,
|
||||
}
|
||||
: answers[crypto.randomInt(0, answers.length)];
|
||||
|
||||
questions.set(question, { answerType, timestamp: new Date() });
|
||||
questions.set(question, { type, timestamp: new Date() });
|
||||
|
||||
context.sendMessage(`🎱 ${contemplations[crypto.randomInt(0, contemplations.length)]}`, context.room.id, { label: false });
|
||||
|
||||
|
|
Loading…
Reference in New Issue