mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Future-proof a bit
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
const request = require('node-superfetch');
|
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 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'];
|
const answers = ['Yes', 'No', 'Don\'t know', 'Probably', 'Probably not'];
|
||||||
|
|
||||||
@@ -27,16 +27,12 @@ class Akinator {
|
|||||||
sid: '1',
|
sid: '1',
|
||||||
cm: this.childMode
|
cm: this.childMode
|
||||||
});
|
});
|
||||||
this.question = text.match(/<p class="question-text" id="question-label">(.+)<\/p>/)[1];
|
const $ = cheerio.load(text);
|
||||||
|
this.question = $('.question-text').text();
|
||||||
this.session = text.match(/session: '(.+)'/)[1];
|
this.session = text.match(/session: '(.+)'/)[1];
|
||||||
this.signature = text.match(/signature: '(.+)'/)[1];
|
this.signature = text.match(/signature: '(.+)'/)[1];
|
||||||
this.answers = [
|
this.answers = [];
|
||||||
decodeHTML(text.match(/<a class="li-game" href="#" id="a_yes" data-index="0">(.+)<\/a>/)[1]),
|
$('.li-game').each((i, elem) => this.answers.push($(elem).text()));
|
||||||
decodeHTML(text.match(/<a class="li-game" href="#" id="a_no" data-index="1">(.+)<\/a>/)[1]),
|
|
||||||
decodeHTML(text.match(/<a class="li-game" href="#" id="a_dont_know" data-index="2">(.+)<\/a>/)[1]),
|
|
||||||
decodeHTML(text.match(/<a class="li-game" href="#" id="a_probably" data-index="3">(.+)<\/a>/)[1]),
|
|
||||||
decodeHTML(text.match(/<a class="li-game" href="#" id="a_probaly_not" data-index="4">(.+)<\/a>/)[1])
|
|
||||||
];
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user