RedYetiDev / blooket.js

Blooket.JS. An API for the Blooket service. This is currently in development.
https://blooket.js.org
1 stars 0 forks source link

Can you make an always correct bot. #2

Closed Justiniscoding closed 3 years ago

Justiniscoding commented 3 years ago

I have the idea of using this to make five bots in racing mode. one will always answer question 1 and so on. Is it possible to have a function called on bot1.correctanswer to tell the main bot which answer is correct? you also said in the readME that you can make it auto answer correctly how?

RedYetiDev commented 3 years ago

Well, yes, you can, but I forgot to add it to the README file. For racing mode, factory mode, cafe mode and gold quest mode, you can use a function similar to the one bellow

bot1.on("QuestionStart", function(q) {
     bot1.answer(q.answers.indexOf(1.correctAnswers[0]) + 1)
}

Pretty much, the q variable is a JSON object containing the question data. So, what is doing is getting the index of the correct answer in the possibles choices, (ex: Correct Answer is Apple, possible choices are Apple, Banana, Cherry, Orange.) The indexOf() command finds the index, in the examples, it would return 0, but since the package is setup to receive numbers 1 through 4, and automatically subtract them by 1, the indexOf() result must by increased by 1. In other terms,

q.answers = ["Apple","Banana","Cherry","Orange"]
q.correctAnswers = ["Apple"]
q.answers.indexOf(q.correctAnswers[0]) // Will return 0, then we add it by 1, so the package with subtract it by 1 later.

For Battle Royale Mode or Classic Mode, use a function like such

bot1.on("QuestionStart", function(q) {
  bot1.answer(bot1.shuffle[q.answers.indexOf(q.correctAnswers[0])])

This is pretty much the same as before, except in Battle Royale and Classic mode, the server shuffles the question order, for example, if shuffle is 0321, then the first choice is located at position 0 (Or the first option you see) and the second choice is located at position 3, and so forth. So, if the indexOfcommand returns 1, it gets the second item in shuffle, and that the answer it sends pretty much if gets the index, and de-shuffles it (if de-shuffles is a real word/term). (No need to add 1 to the result, because of the "de-shuffle"). Anything else?

RedYetiDev commented 3 years ago

I will add that feature as a built in function in the next patch

Justiniscoding commented 3 years ago

ok, and is it possible to sign in to an account, play racing mode and then collect tokens?

RedYetiDev commented 3 years ago

I have not tested that with the package, but I will look into it.

Justiniscoding commented 3 years ago

ok. in game.join can you use any blook? like the waffle blook which is only available to unlock with an account

RedYetiDev commented 3 years ago

Yes.

Justiniscoding commented 3 years ago

In v 1 i hope you can add a login feature!

RedYetiDev commented 3 years ago

We are in v1, but in the next version possibly

Justiniscoding commented 3 years ago

oops, i last checked the version yesterday

RedYetiDev commented 3 years ago

Its fine. I highly doubt login will be feature, but maybe I whip something up

Justiniscoding commented 3 years ago

👍

RedYetiDev commented 3 years ago

I going to go ahead and close this issue. Re open if you need anything.

RedYetiDev commented 3 years ago

Hello again @Justiniscoding, I have good news and bad news for you, Bad news: There will NOT be a sign in feature

Good news: If you want to get tokens, run this command in the terminal.

curl 'https://www.blooket.com/api/users/addtokens' \

-X 'PUT' \   

-H 'Content-Type: application/json;charset=utf-8' \

-H 'Accept: application/json, text/plain, */*' \

-H 'Authorization: {Your JWT TOKEN}' \

-H 'Accept-Language: en-us' \

-H 'Accept-Encoding: gzip, deflate, br' \

-H 'Host: www.blooket.com' \

-H 'Origin: https://www.blooket.com' \

-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15' \

-H 'Connection: keep-alive' \

-H 'Referer: https://www.blooket.com/play/classic/final' \

--data-binary '{"name":"{YOUR USERNAME}","addedTokens":{AMOUNT TO ADD}}'

The JWT token is a token that starts with JWT ..., the ...being the token. The Token can be found in Local Storage for www.blooket.com.

Token

The image was taken using Safari. The amount to add can be any number, but will only add a maximum of 500 tokens per account per day.