From a0401a0783545d7bd767e0a8b31b4d0e1d1e9fb3 Mon Sep 17 00:00:00 2001 From: lilyissillyyy Date: Sun, 24 Aug 2025 11:01:51 -0400 Subject: [PATCH] Future-proof a bit --- structures/Akinator.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/structures/Akinator.js b/structures/Akinator.js index 2e7864d2..0febb243 100644 --- a/structures/Akinator.js +++ b/structures/Akinator.js @@ -1,5 +1,5 @@ const request = require('node-superfetch'); -const { decode: decodeHTML } = require('html-entities'); +const cheerio = require('cheerio'); const regions = ['en', 'ar', 'cn', 'de', 'es', 'fr', 'il', 'it', 'jp', 'kr', 'nl', 'pt', 'ru', 'tr', 'id']; const answers = ['Yes', 'No', 'Don\'t know', 'Probably', 'Probably not']; @@ -27,16 +27,12 @@ class Akinator { sid: '1', cm: this.childMode }); - this.question = text.match(/

(.+)<\/p>/)[1]; + const $ = cheerio.load(text); + this.question = $('.question-text').text(); this.session = text.match(/session: '(.+)'/)[1]; this.signature = text.match(/signature: '(.+)'/)[1]; - this.answers = [ - decodeHTML(text.match(/(.+)<\/a>/)[1]), - decodeHTML(text.match(/(.+)<\/a>/)[1]), - decodeHTML(text.match(/(.+)<\/a>/)[1]), - decodeHTML(text.match(/(.+)<\/a>/)[1]), - decodeHTML(text.match(/(.+)<\/a>/)[1]) - ]; + this.answers = []; + $('.li-game').each((i, elem) => this.answers.push($(elem).text())); return this; }