bonktools 3.2.0 → 4.1.2
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 +32 -247
- package/dependencies/CondensedInjector.js +18 -0
- package/dependencies/sgrAPI.user.js +526 -0
- package/dist/bot.js +15 -0
- package/dist/browser/browserManager.js +156 -0
- package/dist/browser/roomMaker.js +459 -0
- package/dist/config/room.js +23 -0
- package/dist/index.js +96 -0
- package/dist/lib/index.js +15 -0
- package/dist/messages.js +87 -0
- package/dist/types/constants.types.js +59 -0
- package/dist/types/joinTeam.types.js +10 -0
- package/dist/utils/botExtensions.js +75 -0
- package/dist/utils/investigationTriggerStart.js +21 -0
- package/dist/utils/logger.js +48 -0
- package/package.json +39 -33
- package/bonk_fullchain.pem +0 -37
- package/examples/host-bot.js +0 -63
- package/examples/simple-bot.js +0 -127
- package/old/bonkbot.js +0 -1266
- package/old/examplebot.js +0 -64
- package/scripts/download-cert.js +0 -52
- package/src/bot.js +0 -1470
- package/src/index.js +0 -23
- package/src/packet.js +0 -374
- package/src/utils/constants.js +0 -153
- package/src/utils/errors.js +0 -137
- package/src/utils/logger.js +0 -109
- package/src/utils/validation.js +0 -130
package/README.md
CHANGED
|
@@ -1,262 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# FUTHERO Bonk.io Rooms
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bot que cria e gerencia salas no [Bonk.io](https://bonk.io) via Puppeteer. Suporta vários modos de jogo, cada um com suas regras, mapa e comandos.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Requisitos
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- Node.js 18+
|
|
8
|
+
- Chrome/Chromium
|
|
9
|
+
- Arquivos em `dependencies/`: `CondensedInjector.js` e `sgrAPI.user.js` (use `download-scripts.sh` se precisar)
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Configuração
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
1. Copie `.env.example` para `.env`
|
|
14
|
+
2. Defina `BOT_USERNAME` e `BOT_PASSWORD` (conta Bonk.io)
|
|
15
|
+
3. `MODE=mbappa2x2` (padrão) — 2v2 futsal, 5 pontos, mapa favorito
|
|
16
|
+
4. Opcional: `ROOM_NAME`, `ROOM_PASSWORD`, `ROOM_MAX_PLAYERS`, `DISCORD_SERVER_LINK`, `HEADLESS=1`
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
npm install bonkbot
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Features
|
|
18
|
-
|
|
19
|
-
- Connect to existing rooms or create new ones
|
|
20
|
-
- Automatically determine the optimal server using the game's API
|
|
21
|
-
- Send and receive chat messages
|
|
22
|
-
- Track players joining and leaving
|
|
23
|
-
- Manage teams and game settings
|
|
24
|
-
- Handle game events
|
|
25
|
-
- Comprehensive error handling
|
|
26
|
-
- Detailed logging
|
|
27
|
-
|
|
28
|
-
# Support
|
|
29
|
-
|
|
30
|
-
[Discord Server](https://discord.gg/USJQjwD7AY)
|
|
31
|
-
|
|
32
|
-
## Basic Usage
|
|
33
|
-
|
|
34
|
-
```javascript
|
|
35
|
-
const { createBot, LOG_LEVELS } = require('bonkbot');
|
|
36
|
-
|
|
37
|
-
// Create a bot instance
|
|
38
|
-
const bot = createBot({
|
|
39
|
-
account: {
|
|
40
|
-
username: 'BotName',
|
|
41
|
-
guest: true, // Use guest account
|
|
42
|
-
},
|
|
43
|
-
logLevel: LOG_LEVELS.WARN, // Set log level (DEBUG, INFO, WARN, ERROR, NONE)
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Initialize and handle events
|
|
47
|
-
bot.events.on('ready', async () => {
|
|
48
|
-
await bot.connect();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Handle chat messages
|
|
52
|
-
bot.events.on('CHAT_MESSAGE', (message) => {
|
|
53
|
-
console.log(`${message.player.username}: ${message.message}`);
|
|
54
|
-
|
|
55
|
-
// Respond to !ping command
|
|
56
|
-
if (message.message === '!ping') {
|
|
57
|
-
bot.chat('Pong!');
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
bot.events.on('PACKET', (packet) => {
|
|
62
|
-
bot.autoHandlePacket(packet);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
bot.init();
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Authentication Examples
|
|
69
|
-
|
|
70
|
-
### Automatic Server Detection
|
|
71
|
-
|
|
72
|
-
By default, BonkBot will automatically determine the optimal server to connect to by querying the game's API. This ensures your bot connects to the most appropriate server based on the current game infrastructure.
|
|
73
|
-
|
|
74
|
-
If you want to override this behavior and connect to a specific server, you can provide the `server` option when creating the bot:
|
|
75
|
-
|
|
76
|
-
```javascript
|
|
77
|
-
const bot = createBot({
|
|
78
|
-
// ... other options
|
|
79
|
-
server: 'b2ny1', // Force connection to a specific server
|
|
80
|
-
});
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Guest Account
|
|
84
|
-
|
|
85
|
-
```javascript
|
|
86
|
-
const bot = createBot({
|
|
87
|
-
account: {
|
|
88
|
-
username: 'BotName',
|
|
89
|
-
guest: true,
|
|
90
|
-
},
|
|
91
|
-
logLevel: LOG_LEVELS.WARN,
|
|
92
|
-
});
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### User Account
|
|
96
|
-
|
|
97
|
-
```javascript
|
|
98
|
-
const bot = createBot({
|
|
99
|
-
account: {
|
|
100
|
-
username: 'YourUsername',
|
|
101
|
-
password: 'YourPassword',
|
|
102
|
-
guest: false,
|
|
103
|
-
},
|
|
104
|
-
logLevel: LOG_LEVELS.WARN,
|
|
105
|
-
});
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Connection Flow and Examples
|
|
18
|
+
## Uso
|
|
109
19
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
2. Ready event fires when login completes
|
|
114
|
-
3. Connect to game server (`bot.connect()`)
|
|
115
|
-
4. Find or create room
|
|
116
|
-
5. Join room or create room
|
|
117
|
-
6. Handle game events
|
|
118
|
-
|
|
119
|
-
### Joining a Room by Name
|
|
120
|
-
|
|
121
|
-
```javascript
|
|
122
|
-
bot.events.on('ready', async () => {
|
|
123
|
-
try {
|
|
124
|
-
// Find room by name
|
|
125
|
-
const roomInfo = await bot.getAddressFromRoomName('roomName');
|
|
126
|
-
console.log(`Found room: ${roomInfo.roomname}`);
|
|
127
|
-
|
|
128
|
-
// Set address and connect
|
|
129
|
-
bot.setAddress(roomInfo);
|
|
130
|
-
await bot.connect();
|
|
131
|
-
|
|
132
|
-
// Join with optional password
|
|
133
|
-
await bot.joinRoom({
|
|
134
|
-
password: 'optional-password',
|
|
135
|
-
});
|
|
136
|
-
} catch (error) {
|
|
137
|
-
console.error('Failed to join room:', error);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Joining a Room by Link
|
|
143
|
-
|
|
144
|
-
```javascript
|
|
145
|
-
bot.events.on('ready', async () => {
|
|
146
|
-
try {
|
|
147
|
-
// Get room info from share link
|
|
148
|
-
const roomInfo = await bot.getAddressFromUrl('https://bonk.io/123abc');
|
|
149
|
-
console.log(`Found room: ${roomInfo.roomname}`);
|
|
150
|
-
|
|
151
|
-
// Connect to room
|
|
152
|
-
bot.setAddress(roomInfo);
|
|
153
|
-
await bot.connect();
|
|
154
|
-
await bot.joinRoom();
|
|
155
|
-
} catch (error) {
|
|
156
|
-
console.error('Failed to join room:', error);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### Creating a Room
|
|
162
|
-
|
|
163
|
-
```javascript
|
|
164
|
-
bot.events.on('ready', async () => {
|
|
165
|
-
try {
|
|
166
|
-
// Connect to server first
|
|
167
|
-
await bot.connect();
|
|
168
|
-
|
|
169
|
-
// Then create room
|
|
170
|
-
bot.createRoom({
|
|
171
|
-
roomname: 'BonkBot Room',
|
|
172
|
-
maxplayers: 10,
|
|
173
|
-
roompassword: '',
|
|
174
|
-
hidden: true,
|
|
175
|
-
});
|
|
176
|
-
} catch (error) {
|
|
177
|
-
console.error('Failed to create room:', error);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Get share link when room is created
|
|
182
|
-
bot.events.on('ROOM_SHARE_LINK', (data) => {
|
|
183
|
-
console.log(`Room created! URL: ${data.url}`);
|
|
184
|
-
});
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## Available Events
|
|
188
|
-
|
|
189
|
-
| Event | Description | Returns |
|
|
190
|
-
| ------------------ | --------------------------- | ------------------------- |
|
|
191
|
-
| `ready` | Bot is ready to connect | - |
|
|
192
|
-
| `connect` | Connected to server | - |
|
|
193
|
-
| `PACKET` | Any packet received | `{type, ...data}` |
|
|
194
|
-
| `JOIN` | Joined a room | `{game, room, players}` |
|
|
195
|
-
| `PLAYER_JOIN` | Player joined room | `{player, id}` |
|
|
196
|
-
| `PLAYER_LEAVE` | Player left room | `{player, id}` |
|
|
197
|
-
| `CHAT_MESSAGE` | Chat message received | `{player, message}` |
|
|
198
|
-
| `TEAM_CHANGE` | Player changed team | `{player, team}` |
|
|
199
|
-
| `HOST_TRANSFER` | Host was transferred | `{oldHost, newHost}` |
|
|
200
|
-
| `READY_CHANGE` | Player ready status changed | `{player, ready}` |
|
|
201
|
-
| `GAME_START` | Game started | - |
|
|
202
|
-
| `GAME_END` | Game ended | - |
|
|
203
|
-
| `COUNTDOWN` | Game countdown | `{countdown}` |
|
|
204
|
-
| `MAP_SWITCH` | Map was switched | `{map}` |
|
|
205
|
-
| `MAP_SUGGEST` | Map was suggested | `{title, author, player}` |
|
|
206
|
-
| `CHANGE_ROUNDS` | Round count changed | `{rounds}` |
|
|
207
|
-
| `GAMEMODE_CHANGE` | Game mode changed | `{mode, engine}` |
|
|
208
|
-
| `ROOM_SHARE_LINK` | Room link created | `{url}` |
|
|
209
|
-
| `PLAYER_KICK` | Player was kicked | `player` |
|
|
210
|
-
| `PLAYER_TABBED` | Player tabbed in/out | `{player, tabbed}` |
|
|
211
|
-
| `PLAYER_INPUT` | Player input received | `{player, movement}` |
|
|
212
|
-
| `TEAMLOCK_TOGGLE` | Teams locked/unlocked | `{teamsLocked}` |
|
|
213
|
-
| `ROOM_NAME_UPDATE` | Room name changed | `{name}` |
|
|
214
|
-
| `ROOM_ADDRESS` | Room address updated | `{address}` |
|
|
215
|
-
| `BALANCE_SET` | Player balance changed | `{player, balance}` |
|
|
216
|
-
| `disconnect` | Disconnected from server | - |
|
|
217
|
-
|
|
218
|
-
## Common Methods
|
|
219
|
-
|
|
220
|
-
```javascript
|
|
221
|
-
// Chat message
|
|
222
|
-
bot.chat('Hello world');
|
|
223
|
-
|
|
224
|
-
// Get all players
|
|
225
|
-
const players = bot.getAllPlayers();
|
|
226
|
-
|
|
227
|
-
// Get host
|
|
228
|
-
const host = bot.getHost();
|
|
229
|
-
|
|
230
|
-
// Get room share link
|
|
231
|
-
const shareLink = bot.getShareLink();
|
|
232
|
-
|
|
233
|
-
// Set player ready status
|
|
234
|
-
bot.ready(true);
|
|
235
|
-
|
|
236
|
-
// Join a team (0-5)
|
|
237
|
-
bot.joinTeam(2); // 0=spectator, 1=FFA, 2=red, 3=blue...
|
|
238
|
-
|
|
239
|
-
// Give host to player
|
|
240
|
-
bot.giveHost(playerId);
|
|
241
|
-
|
|
242
|
-
// Kick a player
|
|
243
|
-
bot.kickPlayer(playerId);
|
|
244
|
-
|
|
245
|
-
// Leave the room
|
|
246
|
-
bot.leaveGame();
|
|
20
|
+
```bash
|
|
21
|
+
npm install
|
|
22
|
+
npm run dev:new
|
|
247
23
|
```
|
|
248
24
|
|
|
249
|
-
|
|
25
|
+
O bot cria a sala e exibe o link. Comandos gerais em todos os modos: `!help` `!ping` `!queue` `!r` `!reset` `!cancel` `!discord`.
|
|
250
26
|
|
|
251
|
-
|
|
27
|
+
### Modo MBAPPA 2X2
|
|
252
28
|
|
|
253
|
-
-
|
|
254
|
-
-
|
|
29
|
+
- 2 jogadores no time vermelho e 2 no azul; todos dão Ready (botão ou !r) para iniciar.
|
|
30
|
+
- Partida em primeiro a 5 gols; mapa é o primeiro favorito da conta.
|
|
31
|
+
- Ao terminar: se 1 no spec, ele digita `!p <abreviação>` para escolher o parceiro (o outro fica no spec); se 2 no spec, entram no lugar dos perdedores.
|
|
255
32
|
|
|
256
|
-
##
|
|
33
|
+
## Scripts
|
|
257
34
|
|
|
258
|
-
|
|
35
|
+
- `npm run dev:new` — com janela
|
|
36
|
+
- `npm run dev:new:headless` — headless
|
|
37
|
+
- `npm run build` / `npm start` — build e execução
|
|
259
38
|
|
|
260
|
-
##
|
|
39
|
+
## Estrutura
|
|
261
40
|
|
|
262
|
-
|
|
41
|
+
- `src/index-new.ts` — entrada, escolhe modo via `MODE` e inicia sala
|
|
42
|
+
- `src/modes/types.ts` — interface dos modos
|
|
43
|
+
- `src/modes/mbappa2x2/` — modo MBAPPA 2X2 (2v2, 5 pts, !p)
|
|
44
|
+
- `src/modes/common/` — comandos gerais
|
|
45
|
+
- `src/browser/roomMaker.ts` — criação da sala (Puppeteer)
|
|
46
|
+
- `src/room/bonkRoom.ts` — gestão da sala (delega ao modo)
|
|
47
|
+
- `config/room.ts` — configuração base da sala
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
let url = "https://bonk.io/js/alpha2s.js";
|
|
2
|
+
window.code = new Promise(async res => res(await (await fetch(url + "?")).text()));
|
|
3
|
+
window._appendChild = document.head.appendChild;
|
|
4
|
+
document.head.appendChild = function(...args) {
|
|
5
|
+
if(args[0].src === url) {
|
|
6
|
+
args[0].removeAttribute("src");
|
|
7
|
+
(async () => {
|
|
8
|
+
window.code = await window.code;
|
|
9
|
+
while(!window.bonkCodeInjectors) await new Promise(res => setTimeout(res, 100));
|
|
10
|
+
for(injector of window.bonkCodeInjectors) window.code = injector(window.code);
|
|
11
|
+
args[0].textContent = window.code;
|
|
12
|
+
args[0].dispatchEvent(new Event("load"));
|
|
13
|
+
return window._appendChild.apply(document.head, args);
|
|
14
|
+
})();
|
|
15
|
+
} else {
|
|
16
|
+
return window._appendChild.apply(document.head, args);
|
|
17
|
+
}
|
|
18
|
+
}
|