New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

blooket.js

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blooket.js - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

LICENSE

79

blooket.js

@@ -7,9 +7,5 @@ const ws = require('ws');

const answerHandler = require("./modules/answerHandler")
const {goldHandler, goldchance} = require("./modules/goldHandler")
const {goldHandler, goldchance, getPlayers} = require("./modules/goldHandler")
const delay = ms => new Promise(res => setTimeout(res, ms));
class Blooket extends EventEmitter {
/**
* @constructor - blooket
* @param {object} options - The Blooket.JS options. Currently, you can use "repeat, true/false, default true". Must be a JSON object.
*/
constructor(options) {

@@ -50,8 +46,3 @@ super()

}
/**
* @param {number} pin - The game pin
* @param {string} name - The client's name
* @param {string} animal - The client's animal picture
*/
async join(pin, name, animal) {
async join(pin, name, animal, spam=false) {
await socketcheck(pin).then((socket) => { this.socket = new ws(socket.url)})

@@ -74,3 +65,9 @@ this.pin = pin

})
if (this.animal == "random") {
this.animal = await this.randomblook()
}
await this.connect()
if (spam == true) {
return null
}
this.emit("joined", this)

@@ -98,5 +95,20 @@ await getquestions(this.gameid).then((questions) => {

}
/**
* Sends the player information to the websocket
*/
randomblook() {
return new Promise(async(resolve, reject) => {
var blooklist = []
var playerlist = await getPlayers(this)
for (var player in playerlist) {
blooklist.push(playerlist[player].b)
}
console.log(blooklist)
var blooks = ["Chick","Chicken","Cow","Goat","Horse","Pig","Sheep","Duck","Dog","Cat","Rabbit","Goldfish","Hamster","Turtle","Kitten","Puppy","Bear","Moose","Fox","Raccoon","Squirrel","Owl","Hedgehog","Tiger","Orangutan","Cockatoo","Parrot","Anaconda","Jaguar","Macaw","Toucan","Panther","Capuchin","Snowy_Owl","Polar_Bear","Artic_Fox","Baby_Penguin","Penguin","Arctic_Hare","Seal","Walrus","Witch","Wizard","Elf","Fairy","Slime_Monster","Jester","Dragon","Queen","Unicorn","King","Two_of_Spades","Eat_Me","Drink_Me","Alice","Queen_of_Hearts","Dormouse","White_Rabbit","Cheshire_Cat","Caterpillar","Mad_Hatter","King_of_Hearts","Toast","Cereal","Yogurt","Breakfast_Combo","Orange_Juice","Milk","Waffle","Pancakes","French_Toast","Pizza","Earth","Meteor","Stars","Alien","Planet","UFO","Spaceship","Astronaut","Snow_Globe","Holiday_Gift","Hot_Chocolate","Holiday_Wreath","Gingerbread_Man","Gingerbread_House","Snowman","Santa_Claus","Pumpkin","Swamp_Monster","Frankenstein","Vampire","Zombie","Mummy","Werewolf","Ghost","Red_Astronaut","Blue_Astronaut","Green_Astronaut","Pink_Astronaut","Orange_Astronaut","Yellow_Astronaut","Black_Astronaut","Purple_Astronaut","Brown_Astronaut","Cyan_Astronaut","Lime_Astronaut","Spooky_Pumpkin","Spooky_Mummy","Spooky_Ghost","Frost_Wreath","Tropical_Globe"];
blooklist.forEach((blook) => {
delete blooks[blooks.indexOf(blook)]
});
var blooks = blooks.filter(function (blook) {
return blook != null
});
return resolve(blooks[Math.floor(Math.random() * blooks.length)])
})
}
connect() {

@@ -109,5 +121,3 @@ return new Promise((resolve,reject) => {

}
/**
* Starts the question, changes the question index for the next question
*/
async startquestion() {

@@ -125,5 +135,11 @@ if (this.mode != "royale" & this.mode != "classic") {

}
/**
* @param {number}
*/
autocorrect() {
var q = this.questions[this.CurrentIndex]
if (this.mode == "royale" || this.mode == "classic") {
return this.shuffle[q.answers.indexOf(q.correctAnswers[0])]
} else {
return q.answers.indexOf(q.correctAnswers[0]) + 1
}
}
async answer(a) {

@@ -164,8 +180,8 @@ console.log("Answering Question: " + this.CurrentIndex)

}
} else {
this.emit("Incorrect")
}
}
}
/**
* @param {number} - The prize to open
*/
async getgold(p) {

@@ -189,5 +205,3 @@ await goldHandler(p, this).then((e) => {

}
/**
* @param {string} - The player to swap from
*/
swap(player) {

@@ -206,5 +220,3 @@ var targetanimal = this.steal[0][player].b

}
/**
* @param {string} - The player to steal from
*/
rob(player) {

@@ -222,3 +234,12 @@ var target = this.steal[0][player]

}
async BotSpam(pin, name, animal, n) {
var t = 0
while (n > t) {
this.join(pin, name + String(t), animal, true)
await delay(1500)
console.log("Joined")
t += 1
}
}
}
module.exports = Blooket;

@@ -29,3 +29,3 @@ /**

return new Promise(async(resolve, reject) => {
res = await got(`https://www.blooket.com/api/games?gameId=${id}`)
res = await got(`https://api.blooket.com/api/games?gameId=${id}`)
questiondata = JSON.parse(res.body)

@@ -32,0 +32,0 @@ return resolve(questiondata)

@@ -116,2 +116,2 @@ /**

}
module.exports = {goldHandler, goldchance}
module.exports = {goldHandler, goldchance, getPlayers}
{
"name": "blooket.js",
"version": "1.0.0",
"version": "1.1.0",
"description": "This is a terminal client for the quiz service known as Blooket",

@@ -5,0 +5,0 @@ "main": "blooket.js",

@@ -0,4 +1,4 @@

![Blooket.JS](https://blooket.js.org/images/favicon_animated.svg)
# Blooket.JS
## Version 0.6.0 Alpha
This version is **STILL** in beta. Classic Game Mode is not yet supported.
## Version 1.1.0
#### Table Of Contents

@@ -18,5 +18,7 @@ - [Features](#features)

- [answer](#answer)
- [autocorrect](#autocorrect)
- [Get Gold](#getgoldfunction)
- [Swap](#swapfunction)
- [Rob](#rob)
- [BotSpam](#bot)
- [Events](#events)

@@ -41,3 +43,5 @@ - [Joined](#joined)

- Playing games
- Auto answer (can be set to do it correctly)
- Bot Spam
- Random Blook
- Auto answer (can be set to do it correctly, see [this issue](https://github.com/RedYetiDev/blooket.js/issues/2))
- Can use "Prizes", like the normal client

@@ -101,2 +105,5 @@

- #### <a id="autocorrect">autocorrect()
The `autocorrect` function is a function to be used in place of the `a` variable within the `game.answer` function. So, instead of running `game.answer(1,2,3 or 4)`, run `game.answer(autocorrect())`
- #### <a id="getgoldfunction"></a>getgold(p)

@@ -110,2 +117,10 @@ (Only in Gold Quest) The getgold function is used to collect your prize. The `p` variable can by a number 1 through 3. The prizes you can get are randomly selected (see `modules/goldchance.js`). This function is run when the user handles the `GetGold` event. (See `GetGold` in `Events`).

(Only in Gold Quest) The rob function is used to steal from a player. The `player` variable should be a name of a player in the game, or a `Object.keys()` function like `Object.keys({variable})[0]` replacing `0` with a number 0-through the amount of players subtracted by 1 (ex: 20 players means number 0 through 19). It is used while handling the `Steal` event (see `Steal` in `Events` and `Swap and Steal` in `Examples`).
- #### <a id="bots"></a>BotSpam(pin, name, animal, n)
Using the BotSpam function will unleash a army of even robots to destroy the world:boom: :scream: :boom:! No it will not... yet... The BotSpam function takes all the normal join arguments (`pin`, `name`, `animal`), and one extra, `n`. This variable should be positive number. It is the number of bots to spam the game with. (The bots will not answer questions but might in the future). The `BotSpam` function should be the **ONLY** function in the script when used. The correct way to call this function to use the following snippet
```js
const Blooket = require("blooket.js")
const game = new Blooket()
game.BotSpam(PIN,Name,Animal, Number)
```
The Bot's names will be as such "Name0", "Name1", "Name2"...

@@ -173,3 +188,2 @@ ## <a id="events"></a>Events

## <a id="up"></a>Upcoming Features
- Classic Game Mode
- `Powerups/Glitch` support in Factory Mode

@@ -176,0 +190,0 @@ - And more

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc