bonktools 2.0.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +191 -480
- package/package.json +45 -64
- package/src/index.js +23 -0
- package/dist/connection/BonkConnection.d.ts +0 -173
- package/dist/connection/BonkConnection.js +0 -482
- package/dist/connection/PacketBuilder.d.ts +0 -13
- package/dist/connection/PacketBuilder.js +0 -25
- package/dist/connection/PacketParser.d.ts +0 -14
- package/dist/connection/PacketParser.js +0 -26
- package/dist/connection/types.d.ts +0 -0
- package/dist/connection/types.js +0 -1
- package/dist/game/GameLoop.d.ts +0 -0
- package/dist/game/GameLoop.js +0 -1
- package/dist/index.d.ts +0 -48
- package/dist/index.js +0 -73
- package/dist/simulator/GameState.d.ts +0 -0
- package/dist/simulator/GameState.js +0 -1
- package/dist/simulator/PhysicsWorld.d.ts +0 -0
- package/dist/simulator/PhysicsWorld.js +0 -1
- package/dist/types/events.d.ts +0 -0
- package/dist/types/events.js +0 -1
- package/dist/types/index.d.ts +0 -0
- package/dist/types/index.js +0 -1
- package/dist/utils/constants.d.ts +0 -175
- package/dist/utils/constants.js +0 -187
- package/dist/utils/logger.d.ts +0 -31
- package/dist/utils/logger.js +0 -133
- package/dist/utils/validation.d.ts +0 -5
- package/dist/utils/validation.js +0 -28
package/package.json
CHANGED
|
@@ -1,64 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "bonktools",
|
|
3
|
-
"version": "2.0
|
|
4
|
-
"description": "Advanced Bonk.io bot library with physics simulation and game state management",
|
|
5
|
-
"main": "
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
},
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"socket.io-client": "^2.3.1"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@types/jest": "^29.5.0",
|
|
50
|
-
"@types/node": "^20.10.0",
|
|
51
|
-
"@types/socket.io-client": "^1.4.36",
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
53
|
-
"@typescript-eslint/parser": "^6.0.0",
|
|
54
|
-
"eslint": "^8.50.0",
|
|
55
|
-
"jest": "^29.7.0",
|
|
56
|
-
"prettier": "^3.0.0",
|
|
57
|
-
"ts-jest": "^29.1.0",
|
|
58
|
-
"ts-node": "^10.9.0",
|
|
59
|
-
"typescript": "^5.3.0"
|
|
60
|
-
},
|
|
61
|
-
"engines": {
|
|
62
|
-
"node": ">=16.0.0"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "bonktools",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "Advanced Bonk.io bot library with physics simulation and game state management",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js",
|
|
8
|
+
"lib",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
|
+
"download-cert": "node scripts/download-cert.js",
|
|
15
|
+
"preinstall": "node scripts/download-cert.js || true",
|
|
16
|
+
"simple-bot": "node examples/simple-bot.js",
|
|
17
|
+
"host-bot": "node examples/host-bot.js"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"bonk.io",
|
|
21
|
+
"bot",
|
|
22
|
+
"game",
|
|
23
|
+
"automation",
|
|
24
|
+
"physics",
|
|
25
|
+
"box2d"
|
|
26
|
+
],
|
|
27
|
+
"author": "OBL",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/brenoluizdev/bonktools.git"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"axios": "^1.6.0",
|
|
38
|
+
"box2d-wasm": "^6.0.1",
|
|
39
|
+
"eventemitter3": "^5.0.1",
|
|
40
|
+
"socket.io-client": "^4.7.2"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=16"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BonkBot - A JavaScript library for creating bots for bonk.io
|
|
3
|
+
* @module bonkbot
|
|
4
|
+
*/
|
|
5
|
+
const BonkBot = require("./bot");
|
|
6
|
+
const {
|
|
7
|
+
LOG_LEVELS
|
|
8
|
+
} = require("./utils/logger");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create a new BonkBot instance
|
|
12
|
+
* @param {Object} options - Bot options
|
|
13
|
+
* @returns {BonkBot} New BonkBot instance
|
|
14
|
+
*/
|
|
15
|
+
function createBot(options = {}) {
|
|
16
|
+
return new BonkBot(options);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
createBot,
|
|
21
|
+
LOG_LEVELS,
|
|
22
|
+
BonkBot,
|
|
23
|
+
};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
export type Account = {
|
|
3
|
-
username: string;
|
|
4
|
-
password?: string;
|
|
5
|
-
guest: boolean;
|
|
6
|
-
};
|
|
7
|
-
export type RoomInfo = {
|
|
8
|
-
address: string | null;
|
|
9
|
-
name: string | null;
|
|
10
|
-
server: string;
|
|
11
|
-
bypass: string;
|
|
12
|
-
id: number | null;
|
|
13
|
-
dbid: number | null;
|
|
14
|
-
teamsLocked: boolean;
|
|
15
|
-
map: any;
|
|
16
|
-
inGame: boolean;
|
|
17
|
-
};
|
|
18
|
-
export type GameInfo = {
|
|
19
|
-
id: number | null;
|
|
20
|
-
host: number | null;
|
|
21
|
-
banned: boolean;
|
|
22
|
-
};
|
|
23
|
-
export type Player = {
|
|
24
|
-
id: number;
|
|
25
|
-
username: string;
|
|
26
|
-
guest: boolean;
|
|
27
|
-
peerID: string;
|
|
28
|
-
};
|
|
29
|
-
export type JoinOptions = {
|
|
30
|
-
password?: string;
|
|
31
|
-
peerID?: string;
|
|
32
|
-
};
|
|
33
|
-
export type CreateRoomOptions = {
|
|
34
|
-
roomname?: string;
|
|
35
|
-
maxplayers?: number;
|
|
36
|
-
password?: string;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Gerencia a conexão WebSocket com o servidor Bonk.io e o estado do jogo.
|
|
40
|
-
*/
|
|
41
|
-
export declare class BonkConnection extends EventEmitter {
|
|
42
|
-
private socket;
|
|
43
|
-
private connected;
|
|
44
|
-
private keepAliveTimer;
|
|
45
|
-
private PROTOCOL_VERSION;
|
|
46
|
-
account: Account;
|
|
47
|
-
server: string;
|
|
48
|
-
room: RoomInfo;
|
|
49
|
-
game: GameInfo;
|
|
50
|
-
players: Map<number, Player>;
|
|
51
|
-
token: string | null;
|
|
52
|
-
peerID: string;
|
|
53
|
-
avatar: any;
|
|
54
|
-
location: any;
|
|
55
|
-
constructor(account: Account, server?: string);
|
|
56
|
-
/**
|
|
57
|
-
* Gera um ID de par (peerID) aleatório.
|
|
58
|
-
* @returns {string} O peerID gerado.
|
|
59
|
-
*/
|
|
60
|
-
private generatePeerID;
|
|
61
|
-
/**
|
|
62
|
-
* Obtém o token de autenticação do usuário.
|
|
63
|
-
* (Implementação baseada no bonkbot original, usando axios)
|
|
64
|
-
* @param {string} username - Nome de usuário.
|
|
65
|
-
* @param {string} password - Senha.
|
|
66
|
-
* @returns {Promise<string>} O token de autenticação.
|
|
67
|
-
*/
|
|
68
|
-
private getToken;
|
|
69
|
-
/**
|
|
70
|
-
* Obtém informações do servidor (localização, etc.).
|
|
71
|
-
* (Implementação baseada no bonkbot original)
|
|
72
|
-
* @returns {Promise<any>} Informações do servidor.
|
|
73
|
-
*/
|
|
74
|
-
private getServerInfo;
|
|
75
|
-
/**
|
|
76
|
-
* Inicializa a conexão (autenticação, obtenção de info do servidor).
|
|
77
|
-
* @returns {Promise<BonkConnection>} Esta instância.
|
|
78
|
-
*/
|
|
79
|
-
init(): Promise<BonkConnection>;
|
|
80
|
-
/**
|
|
81
|
-
* Inicia o temporizador de keep-alive.
|
|
82
|
-
*/
|
|
83
|
-
private startKeepAlive;
|
|
84
|
-
/**
|
|
85
|
-
* Para o bot (limpa timers, etc.).
|
|
86
|
-
*/
|
|
87
|
-
private stopBot;
|
|
88
|
-
/**
|
|
89
|
-
* Configura os ouvintes de eventos do Socket.IO.
|
|
90
|
-
*/
|
|
91
|
-
private setupSocketEvents;
|
|
92
|
-
/**
|
|
93
|
-
* Conecta-se ao servidor Bonk.io.
|
|
94
|
-
* @returns {Promise<BonkConnection>} Esta instância.
|
|
95
|
-
*/
|
|
96
|
-
connect(): Promise<BonkConnection>;
|
|
97
|
-
/**
|
|
98
|
-
* Desconecta do servidor.
|
|
99
|
-
*/
|
|
100
|
-
disconnect(): void;
|
|
101
|
-
/**
|
|
102
|
-
* Envia uma mensagem (pacote) para o servidor.
|
|
103
|
-
* @param {number} type - Tipo da mensagem (CLIENT_MESSAGE_TYPES).
|
|
104
|
-
* @param {any} data - Dados da mensagem.
|
|
105
|
-
*/
|
|
106
|
-
sendMessage(type: number, data: any): void;
|
|
107
|
-
/**
|
|
108
|
-
* Envia o pacote TIMESYNC (keep-alive).
|
|
109
|
-
*/
|
|
110
|
-
private sendTimesync;
|
|
111
|
-
/**
|
|
112
|
-
* Envia uma mensagem de chat para a sala.
|
|
113
|
-
* @param {string} message - A mensagem a ser enviada.
|
|
114
|
-
*/
|
|
115
|
-
sendChat(message: string): void;
|
|
116
|
-
/**
|
|
117
|
-
* Envia um comando de input do jogador (movimento).
|
|
118
|
-
* @param {number} input - O valor do input (ex: 1 para esquerda, 2 para direita, etc.).
|
|
119
|
-
* @param {number} frame - O frame atual do jogo.
|
|
120
|
-
* @param {number} sequence - O número de sequência do input.
|
|
121
|
-
*/
|
|
122
|
-
sendInput(input: number, frame: number, sequence: number): void;
|
|
123
|
-
/**
|
|
124
|
-
* Envia o comando para iniciar o jogo.
|
|
125
|
-
*/
|
|
126
|
-
startGame(): void;
|
|
127
|
-
/**
|
|
128
|
-
* Envia o comando para mudar de time.
|
|
129
|
-
* @param {number} team - O ID do time (1 a 5, ou 0 para espectador).
|
|
130
|
-
*/
|
|
131
|
-
changeTeam(team: number): void;
|
|
132
|
-
/**
|
|
133
|
-
* Envia o comando para definir o status de pronto/não pronto.
|
|
134
|
-
* @param {boolean} ready - True para pronto, False para não pronto.
|
|
135
|
-
*/
|
|
136
|
-
setReady(ready: boolean): void;
|
|
137
|
-
/**
|
|
138
|
-
* Envia o comando para chutar/banir um jogador.
|
|
139
|
-
* @param {number} id - O ID do jogador.
|
|
140
|
-
* @param {boolean} ban - Se deve banir (true) ou apenas chutar (false).
|
|
141
|
-
*/
|
|
142
|
-
kickBanPlayer(id: number, ban?: boolean): void;
|
|
143
|
-
/**
|
|
144
|
-
* Cria uma nova sala.
|
|
145
|
-
* @param {CreateRoomOptions} options - Opções de criação de sala.
|
|
146
|
-
* @returns {Promise<RoomInfo>} Informações da sala criada.
|
|
147
|
-
*/
|
|
148
|
-
createRoom(options?: CreateRoomOptions): Promise<RoomInfo>;
|
|
149
|
-
/**
|
|
150
|
-
* Entra em uma sala existente.
|
|
151
|
-
* @param {string} roomAddress - Endereço da sala (ex: '123456' ou '123456abcde').
|
|
152
|
-
* @param {JoinOptions} options - Opções de entrada.
|
|
153
|
-
* @returns {Promise<void>}
|
|
154
|
-
*/
|
|
155
|
-
joinRoom(roomAddress: string, options?: JoinOptions): Promise<void>;
|
|
156
|
-
/**
|
|
157
|
-
* Define o endereço da sala.
|
|
158
|
-
* @param {any} addressInfo - Informações de endereço da sala.
|
|
159
|
-
*/
|
|
160
|
-
private setAddress;
|
|
161
|
-
/**
|
|
162
|
-
* Obtém informações de endereço da sala a partir de uma URL/ID.
|
|
163
|
-
* (Implementação baseada no bonkbot original)
|
|
164
|
-
* @param {string} url - URL ou ID da sala.
|
|
165
|
-
* @returns {Promise<any>} Informações de endereço.
|
|
166
|
-
*/
|
|
167
|
-
private getAddressFromUrl;
|
|
168
|
-
/**
|
|
169
|
-
* Manipula os pacotes recebidos do servidor.
|
|
170
|
-
* @param {any} packet - Pacote analisado.
|
|
171
|
-
*/
|
|
172
|
-
private handlePacket;
|
|
173
|
-
}
|