mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add useragent
This commit is contained in:
+10
-2
@@ -1,5 +1,6 @@
|
|||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
const UserAgent = require('user-agents');
|
||||||
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'];
|
||||||
|
|
||||||
@@ -18,11 +19,13 @@ class Akinator {
|
|||||||
this.signature = null;
|
this.signature = null;
|
||||||
this.guessed = null;
|
this.guessed = null;
|
||||||
this.akiWin = null;
|
this.akiWin = null;
|
||||||
|
this.agent = new UserAgent();
|
||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
const { text } = await request
|
const { text } = await request
|
||||||
.post(`https://${this.region}.akinator.com/game`)
|
.post(`https://${this.region}.akinator.com/game`)
|
||||||
|
.set({ 'User-Agent': this.agent.toString() })
|
||||||
.send({
|
.send({
|
||||||
sid: '1',
|
sid: '1',
|
||||||
cm: this.childMode
|
cm: this.childMode
|
||||||
@@ -39,6 +42,7 @@ class Akinator {
|
|||||||
async step(answer) {
|
async step(answer) {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.post(`https://${this.region}.akinator.com/answer`)
|
.post(`https://${this.region}.akinator.com/answer`)
|
||||||
|
.set({ 'User-Agent': this.agent.toString() })
|
||||||
.send({
|
.send({
|
||||||
step: this.currentStep.toString(),
|
step: this.currentStep.toString(),
|
||||||
progression: this.progress,
|
progression: this.progress,
|
||||||
@@ -68,6 +72,7 @@ class Akinator {
|
|||||||
async back() {
|
async back() {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.post(`https://${this.region}.akinator.com/cancel_answer`)
|
.post(`https://${this.region}.akinator.com/cancel_answer`)
|
||||||
|
.set({ 'User-Agent': this.agent.toString() })
|
||||||
.send({
|
.send({
|
||||||
step: this.currentStep.toString(),
|
step: this.currentStep.toString(),
|
||||||
progression: this.progress,
|
progression: this.progress,
|
||||||
@@ -98,8 +103,11 @@ class Akinator {
|
|||||||
params.append('forward_answer', '1');
|
params.append('forward_answer', '1');
|
||||||
const { body, text } = await request
|
const { body, text } = await request
|
||||||
.post(`https://${this.region}.akinator.com/exclude`)
|
.post(`https://${this.region}.akinator.com/exclude`)
|
||||||
.send(params, true)
|
.send(params.toString(), true)
|
||||||
.set({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' });
|
.set({
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||||
|
'User-Agent': this.agent.toString()
|
||||||
|
});
|
||||||
console.log(text);
|
console.log(text);
|
||||||
this.guessed = null;
|
this.guessed = null;
|
||||||
this.stepLastProposition = body.step;
|
this.stepLastProposition = body.step;
|
||||||
|
|||||||
Reference in New Issue
Block a user