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/dist/messages.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Mensagens do bot em PT-BR
|
|
4
|
+
* Centraliza todas as strings para facilitar manutenção
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.HELP_TEXT = exports.MESSAGES = void 0;
|
|
8
|
+
exports.MESSAGES = {
|
|
9
|
+
// Inicialização
|
|
10
|
+
BOT_READY: "✅ Bot pronto (conta Bonk.io). Conectando e criando sala...",
|
|
11
|
+
CONNECTED: "🔌 Conectado ao servidor.",
|
|
12
|
+
ROOM_CREATED: "🟢 Sala criada. O bot é o host.",
|
|
13
|
+
CONNECTION_ERROR: "❌ Erro ao conectar ou criar sala:",
|
|
14
|
+
// Boas-vindas
|
|
15
|
+
WELCOME: (username) => `👋 Bem-vindo à FUTHERO, ${username}!`,
|
|
16
|
+
DEV_WARNING: "⚠️ Lembre-se: Essa sala está em desenvolvimento e pode apresentar bugs.",
|
|
17
|
+
DISCORD_LINK: "ℹ️ Faça parte da nossa comunidade no Discord: https://discord.gg/qRJ4UCMfja",
|
|
18
|
+
// Fila e estados
|
|
19
|
+
PLAYER_LEFT: (username) => `👋 ${username} saiu da sala.`,
|
|
20
|
+
GAME_ENDED: "🎉 O jogo acabou!",
|
|
21
|
+
QUEUE_LIST: (players) => `📋 Fila (${players.length}): ${players.join(", ")}`,
|
|
22
|
+
QUEUE_EMPTY: "📋 A fila está vazia.",
|
|
23
|
+
ADDED_TO_QUEUE: (username) => `✅ ${username} foi adicionado à fila.`,
|
|
24
|
+
// Pick/escolha
|
|
25
|
+
YOUR_TURN_TO_PICK: (username) => `🎯 ${username}, é sua vez de escolher um adversário!`,
|
|
26
|
+
USE_PICK_COMMAND: "💡 Use !p <nome> ou !escolher <nome> para escolher.",
|
|
27
|
+
PLAYER_PICKED: (picker, picked) => `✅ ${picker} escolheu ${picked}!`,
|
|
28
|
+
NO_MATCH_FOUND: "❌ Nenhum jogador encontrado com esse nome.",
|
|
29
|
+
MULTIPLE_MATCHES: "❌ Múltiplos jogadores encontrados. Seja mais específico.",
|
|
30
|
+
NOT_YOUR_TURN: (username) => `❌ É a vez de ${username} escolher.`,
|
|
31
|
+
PICK_TIMEOUT: (username) => `⏱️ Tempo esgotado! ${username} foi removido da fila.`,
|
|
32
|
+
// Ready
|
|
33
|
+
USE_READY_COMMAND: "💡 Use !r ou !pronto quando estiver pronto.",
|
|
34
|
+
PLAYER_READY: (username, ready, total) => `✅ ${username} está pronto! (${ready}/${total})`,
|
|
35
|
+
ALL_READY: "✅ Todos prontos! Iniciando partida...",
|
|
36
|
+
READY_TIMEOUT: "⏱️ Tempo esgotado! Partida cancelada.",
|
|
37
|
+
// Partida
|
|
38
|
+
MATCH_STARTING: (player1, player2) => `🎮 Próxima partida: ${player1} vs ${player2}`,
|
|
39
|
+
MATCH_RESULT: (winner, winnerRating, winnerChange, loser, loserRating, loserChange) => `🏆 Vitória de ${winner}!\n` +
|
|
40
|
+
`${winner}: ${Math.round(winnerRating)} (${winnerChange >= 0 ? '+' : ''}${Math.round(winnerChange)})\n` +
|
|
41
|
+
`${loser}: ${Math.round(loserRating)} (${loserChange >= 0 ? '+' : ''}${Math.round(loserChange)})`,
|
|
42
|
+
MATCH_TIE: (player1, rating1, change1, player2, rating2, change2) => `🤝 Empate!\n` +
|
|
43
|
+
`${player1}: ${Math.round(rating1)} (${change1 >= 0 ? '+' : ''}${Math.round(change1)})\n` +
|
|
44
|
+
`${player2}: ${Math.round(rating2)} (${change2 >= 0 ? '+' : ''}${Math.round(change2)})`,
|
|
45
|
+
// Reset/Cancel
|
|
46
|
+
VOTE_RESET: (votes, total) => `🔄 Voto para reiniciar: ${votes}/${total}`,
|
|
47
|
+
RESETTING_MATCH: "🔄 Reiniciando partida com mesmo placar...",
|
|
48
|
+
VOTE_CANCEL: (votes, total) => `❌ Voto para cancelar: ${votes}/${total}`,
|
|
49
|
+
CANCELLING_MATCH: "❌ Partida cancelada!",
|
|
50
|
+
// Rating
|
|
51
|
+
PLAYER_RATING: (username, rating, wins, losses, ties) => `📊 ${username}: ${Math.round(rating)} pontos (V: ${wins}, D: ${losses}, E: ${ties})`,
|
|
52
|
+
RATING_NOT_FOUND: (username) => `❌ ${username} ainda não jogou nenhuma partida ranqueada.`,
|
|
53
|
+
TOP_PLAYERS: (count) => `🏆 Top ${count} jogadores:`,
|
|
54
|
+
NO_PLAYERS_YET: "📊 Ainda não há jogadores ranqueados.",
|
|
55
|
+
// Ajuda
|
|
56
|
+
HELP_TITLE: "📖 Comandos disponíveis:",
|
|
57
|
+
HELP_QUEUE: "!fila - Ver a fila de jogadores",
|
|
58
|
+
HELP_PICK: "!p <nome> - Escolher adversário (quando for sua vez)",
|
|
59
|
+
HELP_READY: "!r ou !pronto - Marcar como pronto",
|
|
60
|
+
HELP_RESET: "!reset - Votar para reiniciar com mesmo placar",
|
|
61
|
+
HELP_CANCEL: "!cancelar - Votar para cancelar partida",
|
|
62
|
+
HELP_RATING: "!rating [nome] - Ver rating de um jogador",
|
|
63
|
+
HELP_TOP: "!top [N] - Ver top N do ranking (padrão: 10)",
|
|
64
|
+
HELP_DISCORD: "!discord - Link do servidor Discord",
|
|
65
|
+
HELP_AJUDA: "!ajuda - Ver esta mensagem",
|
|
66
|
+
// Erros
|
|
67
|
+
COMMAND_NOT_FOUND: "❌ Comando não encontrado. Use !ajuda para ver os comandos disponíveis.",
|
|
68
|
+
NOT_IN_GAME: "❌ Você não está em uma partida.",
|
|
69
|
+
ALREADY_IN_QUEUE: "❌ Você já está na fila.",
|
|
70
|
+
NOT_IN_QUEUE: "❌ Você não está na fila.",
|
|
71
|
+
GAME_IN_PROGRESS: "❌ Há uma partida em andamento.",
|
|
72
|
+
// Estados
|
|
73
|
+
STATE_IDLE: "💤 Aguardando jogadores na fila...",
|
|
74
|
+
STATE_PICK: "🎯 Fase de escolha de adversário",
|
|
75
|
+
STATE_READY: "⏳ Aguardando jogadores ficarem prontos",
|
|
76
|
+
STATE_GAME: "🎮 Partida em andamento",
|
|
77
|
+
};
|
|
78
|
+
exports.HELP_TEXT = `${exports.MESSAGES.HELP_TITLE}
|
|
79
|
+
${exports.MESSAGES.HELP_QUEUE}
|
|
80
|
+
${exports.MESSAGES.HELP_PICK}
|
|
81
|
+
${exports.MESSAGES.HELP_READY}
|
|
82
|
+
${exports.MESSAGES.HELP_RESET}
|
|
83
|
+
${exports.MESSAGES.HELP_CANCEL}
|
|
84
|
+
${exports.MESSAGES.HELP_RATING}
|
|
85
|
+
${exports.MESSAGES.HELP_TOP}
|
|
86
|
+
${exports.MESSAGES.HELP_DISCORD}
|
|
87
|
+
${exports.MESSAGES.HELP_AJUDA}`;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SERVER_MESSAGE_TYPES = exports.CLIENT_MESSAGE_TYPES_NUM = exports.INVESTIGATION_TRIGGER_START = exports.SUBSTITUTION_TIMEOUT_MS = void 0;
|
|
4
|
+
/** Timeout para resposta do espectador na substituição (ms). API Bonk / Mbappa. */
|
|
5
|
+
exports.SUBSTITUTION_TIMEOUT_MS = 15000;
|
|
6
|
+
/** Ativar logs detalhados de investigação para Trigger Start / GAME_START. Ver docs/investigation/TRIGGER_START_GAME_START.md */
|
|
7
|
+
exports.INVESTIGATION_TRIGGER_START = process.env.INVESTIGATION === "1";
|
|
8
|
+
/** API Bonk - tipos de mensagem cliente (outgoing). Payload conforme doc: 42[type, payload]. */
|
|
9
|
+
exports.CLIENT_MESSAGE_TYPES_NUM = {
|
|
10
|
+
KICK_BAN_PLAYER: 9,
|
|
11
|
+
CHANGE_OTHER_TEAM: 26,
|
|
12
|
+
TRIGGER_START: 5,
|
|
13
|
+
SEND_START_COUNTDOWN: 36,
|
|
14
|
+
SET_READY: 16,
|
|
15
|
+
ALL_READY_RESET: 17,
|
|
16
|
+
SEND_HOST_CHANGE: 34,
|
|
17
|
+
};
|
|
18
|
+
exports.SERVER_MESSAGE_TYPES = {
|
|
19
|
+
PLAYER_PINGS: 1,
|
|
20
|
+
ROOM_ADDRESS: 2,
|
|
21
|
+
JOIN_ROOM: 3,
|
|
22
|
+
PLAYER_JOIN: 4,
|
|
23
|
+
PLAYER_LEAVE: 5,
|
|
24
|
+
HOST_LEAVE: 6,
|
|
25
|
+
PLAYER_INPUT: 7,
|
|
26
|
+
READY_CHANGE: 8,
|
|
27
|
+
GAME_END: 13,
|
|
28
|
+
GAME_START: 15,
|
|
29
|
+
STATUS_MESSAGE: 16,
|
|
30
|
+
TEAM_CHANGE: 18,
|
|
31
|
+
TEAMLOCK_TOGGLE: 19,
|
|
32
|
+
CHAT_MESSAGE: 20,
|
|
33
|
+
INITIAL_DATA: 21,
|
|
34
|
+
TIMESYNC: 23,
|
|
35
|
+
PLAYER_KICK: 24,
|
|
36
|
+
MAP_REORDER: 25,
|
|
37
|
+
GAMEMODE_CHANGE: 26,
|
|
38
|
+
CHANGE_ROUNDS: 27,
|
|
39
|
+
MAP_SWITCH: 29,
|
|
40
|
+
TYPING: 30,
|
|
41
|
+
AFK_WARNING: 32,
|
|
42
|
+
MAP_SUGGEST: 33,
|
|
43
|
+
MAP_SUGGEST2: 34,
|
|
44
|
+
BALANCE_SET: 36,
|
|
45
|
+
DEBUG_WINNER: 38,
|
|
46
|
+
SAVE_REPLAY: 40,
|
|
47
|
+
HOST_TRANSFER: 41,
|
|
48
|
+
FRIEND_REQUEST: 42,
|
|
49
|
+
COUNTDOWN: 43,
|
|
50
|
+
ABORT_COUNTDOWN: 44,
|
|
51
|
+
PLAYER_LEVEL_UP: 45,
|
|
52
|
+
LOCAL_GAINED_XP: 46,
|
|
53
|
+
STATE: 48,
|
|
54
|
+
ROOM_SHARE_LINK: 49,
|
|
55
|
+
PLAYER_TABBED: 52,
|
|
56
|
+
CURATE_RESULT: 57,
|
|
57
|
+
ROOM_NAME_UPDATE: 58,
|
|
58
|
+
ROOM_PASSWORD_UPDATE: 59,
|
|
59
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JoinTeam = void 0;
|
|
4
|
+
var JoinTeam;
|
|
5
|
+
(function (JoinTeam) {
|
|
6
|
+
JoinTeam[JoinTeam["SPEC"] = 0] = "SPEC";
|
|
7
|
+
JoinTeam[JoinTeam["FFA"] = 1] = "FFA";
|
|
8
|
+
JoinTeam[JoinTeam["RED"] = 2] = "RED";
|
|
9
|
+
JoinTeam[JoinTeam["BLUE"] = 3] = "BLUE";
|
|
10
|
+
})(JoinTeam || (exports.JoinTeam = JoinTeam = {}));
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bot extensions for features not exposed directly by bonktools.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.changeOtherTeam = changeOtherTeam;
|
|
7
|
+
exports.startGameAsHost = startGameAsHost;
|
|
8
|
+
exports.allReadyReset = allReadyReset;
|
|
9
|
+
const constants_types_1 = require("../types/constants.types");
|
|
10
|
+
/**
|
|
11
|
+
* Changes another player's team (requires host).
|
|
12
|
+
* @param bot - Bot instance
|
|
13
|
+
* @param playerId - Player ID
|
|
14
|
+
* @param team - Target team (0=spec, 1=FFA, 2=red, 3=blue)
|
|
15
|
+
*/
|
|
16
|
+
async function changeOtherTeam(bot, playerId, team) {
|
|
17
|
+
try {
|
|
18
|
+
if (typeof bot.sendMessage !== "function") {
|
|
19
|
+
console.error("[BotExt] sendMessage is not available");
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
await bot.sendMessage(constants_types_1.CLIENT_MESSAGE_TYPES_NUM.CHANGE_OTHER_TEAM, {
|
|
23
|
+
id: playerId,
|
|
24
|
+
targetTeam: team,
|
|
25
|
+
});
|
|
26
|
+
console.log(`[BotExt] Player ${playerId} team changed to ${team}`);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error(`[BotExt] Error while changing team:`, error);
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Starts the game as host (sends ready + countdown).
|
|
36
|
+
* @param bot - Bot instance
|
|
37
|
+
*/
|
|
38
|
+
async function startGameAsHost(bot) {
|
|
39
|
+
try {
|
|
40
|
+
// 1. Host marks itself as ready
|
|
41
|
+
if (typeof bot.ready === "function") {
|
|
42
|
+
await bot.ready(true);
|
|
43
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
44
|
+
}
|
|
45
|
+
// 2. Send 1-second countdown
|
|
46
|
+
if (typeof bot.sendMessage === "function") {
|
|
47
|
+
await bot.sendMessage(constants_types_1.CLIENT_MESSAGE_TYPES_NUM.SEND_START_COUNTDOWN, 1);
|
|
48
|
+
console.log("[BotExt] startGame: ready + countdown(1) sent");
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
console.error("[BotExt] startGameAsHost error:", e);
|
|
55
|
+
throw e;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resets ready status for all players.
|
|
60
|
+
* @param bot - Bot instance
|
|
61
|
+
*/
|
|
62
|
+
async function allReadyReset(bot) {
|
|
63
|
+
try {
|
|
64
|
+
if (typeof bot.sendMessage !== "function") {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
await bot.sendMessage(constants_types_1.CLIENT_MESSAGE_TYPES_NUM.ALL_READY_RESET, {});
|
|
68
|
+
console.log("[BotExt] allReadyReset sent");
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error("[BotExt] Error while resetting ready:", error);
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utilitários para investigação de GAME_START / Trigger Start.
|
|
4
|
+
* Usado quando INVESTIGATION=1 ou para debug.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.investigationRunActive = void 0;
|
|
8
|
+
exports.setInvestigationRunActive = setInvestigationRunActive;
|
|
9
|
+
exports.logGameStartReceived = logGameStartReceived;
|
|
10
|
+
/** Ativo quando uma corrida de investigação está em andamento (pode ser setado por outros módulos). */
|
|
11
|
+
exports.investigationRunActive = false;
|
|
12
|
+
function setInvestigationRunActive(value) {
|
|
13
|
+
exports.investigationRunActive = value;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Registra payload de GAME_START recebido (para comparação host vs bot).
|
|
17
|
+
* Chamado por packet.ts quando INVESTIGATION_TRIGGER_START ou investigationRunActive.
|
|
18
|
+
*/
|
|
19
|
+
function logGameStartReceived(payload) {
|
|
20
|
+
console.log("[Investigation] GAME_START payload:", JSON.stringify(payload, null, 2));
|
|
21
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Logger = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
class Logger {
|
|
9
|
+
static formatMessage(level, message) {
|
|
10
|
+
const timestamp = chalk_1.default.gray(new Date().toISOString());
|
|
11
|
+
const prefix = chalk_1.default.bold("[bonktools]");
|
|
12
|
+
let levelColor;
|
|
13
|
+
switch (level) {
|
|
14
|
+
case "DEBUG":
|
|
15
|
+
levelColor = chalk_1.default.cyan(`[${level}]`);
|
|
16
|
+
break;
|
|
17
|
+
case "INFO":
|
|
18
|
+
levelColor = chalk_1.default.green(`[${level}]`);
|
|
19
|
+
break;
|
|
20
|
+
case "WARN":
|
|
21
|
+
levelColor = chalk_1.default.yellow(`[${level}]`);
|
|
22
|
+
break;
|
|
23
|
+
case "ERROR":
|
|
24
|
+
levelColor = chalk_1.default.red(`[${level}]`);
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
levelColor = chalk_1.default.white(`[${level}]`);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
return `${timestamp} ${prefix} ${levelColor} ${message}`;
|
|
31
|
+
}
|
|
32
|
+
static debug(message) {
|
|
33
|
+
console.debug(this.formatMessage("DEBUG", message));
|
|
34
|
+
}
|
|
35
|
+
static info(message) {
|
|
36
|
+
console.log(this.formatMessage("INFO", message));
|
|
37
|
+
}
|
|
38
|
+
static warn(message) {
|
|
39
|
+
console.warn(this.formatMessage("WARN", message));
|
|
40
|
+
}
|
|
41
|
+
static error(message, error) {
|
|
42
|
+
console.error(this.formatMessage("ERROR", message));
|
|
43
|
+
if (error) {
|
|
44
|
+
console.error(chalk_1.default.redBright(error instanceof Error ? error.stack : String(error)));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.Logger = Logger;
|
package/package.json
CHANGED
|
@@ -1,43 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bonktools",
|
|
3
|
-
"version": "3.2.0",
|
|
4
3
|
"description": "Advanced Bonk.io bot library with physics simulation and game state management",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"publish_3": "npm version major",
|
|
15
|
-
"publish_4": "npm publish"
|
|
4
|
+
"version": "4.1.2",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"main": "dist/lib/index.js",
|
|
7
|
+
"types": "dist/lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/lib/index.d.ts",
|
|
11
|
+
"require": "./dist/lib/index.js"
|
|
12
|
+
}
|
|
16
13
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"game",
|
|
21
|
-
"automation",
|
|
22
|
-
"physics",
|
|
23
|
-
"box2d"
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/**",
|
|
16
|
+
"dependencies/**"
|
|
24
17
|
],
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"test:payload": "node --test --require ts-node/register test/investigation/triggerStartPayload.test.ts",
|
|
22
|
+
"investigate:compare": "node --require ts-node/register scripts/investigate-compare-payloads.ts",
|
|
23
|
+
"test:browser": "ts-node scripts/test-browser-start.ts",
|
|
24
|
+
"test:browser:headless": "HEADLESS=1 ts-node scripts/test-browser-start.ts",
|
|
25
|
+
"publish": "npm publish --access public"
|
|
33
26
|
},
|
|
34
27
|
"dependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
28
|
+
"bonktools": "^3.2.0",
|
|
29
|
+
"chalk": "^5.6.2",
|
|
30
|
+
"dotenv": "^17.2.3",
|
|
31
|
+
"fs": "^0.0.1-security",
|
|
32
|
+
"lz-string": "^1.5.0",
|
|
33
|
+
"msgpack-lite": "^0.1.26",
|
|
34
|
+
"node-fetch": "^3.3.2",
|
|
35
|
+
"nodemon": "^3.1.10",
|
|
36
|
+
"path": "^0.12.7",
|
|
37
|
+
"playwright": "^1.49.0",
|
|
38
|
+
"puppeteer": "^24.37.3",
|
|
39
|
+
"puppeteer-core": "^24.37.3",
|
|
40
|
+
"socket.io-client": "^2.5.0"
|
|
41
|
+
},
|
|
42
|
+
"overrides": {
|
|
43
|
+
"socket.io-client": "^2.5.0"
|
|
39
44
|
},
|
|
40
|
-
"
|
|
41
|
-
"node": "
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"ts-node": "^10.9.2",
|
|
47
|
+
"typescript": "^5.0.0"
|
|
42
48
|
}
|
|
43
49
|
}
|
package/bonk_fullchain.pem
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
|
2
|
-
MIIGcTCCBNmgAwIBAgIQBCOxRTvzzdaopUgt3SZ4TzANBgkqhkiG9w0BAQsFADBg
|
|
3
|
-
MQswCQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkM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32
|
-
OdUCnhNgVDUU1cojkPdCdII7PRfF8z1mOL2CpjXcT5MglIWExPEOlyw/FYkAM2V6
|
|
33
|
-
xE+DH0eh2K6CYr3WXqAp9/1OY6f13wHfOm3EInX/N1QEVzTjkIuCRuoHL8iuxos0
|
|
34
|
-
5l5K0oZIdLV9Jm+3QXjkF6W4Jv/B8cA/IhimR7+AlpjrCGBj3sz3LIMbQCXAMKy0
|
|
35
|
-
bjxY1MXD/pd6Uw3fVpLMRLV475APxwMB/lhqJuv6kHlgTQ7gwIPwB5fYWHIQzlxe
|
|
36
|
-
t217eGbT7tfXnVw/ywSwbEMgekAx
|
|
37
|
-
-----END CERTIFICATE-----
|
package/examples/host-bot.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// const { createBot, LOG_LEVELS } = require("bonkbot");
|
|
2
|
-
const { createBot, LOG_LEVELS } = require("../src/index");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// Create a bot instance
|
|
6
|
-
const bot = createBot({
|
|
7
|
-
account: {
|
|
8
|
-
username: "bonkbot",
|
|
9
|
-
guest: true,
|
|
10
|
-
},
|
|
11
|
-
PROTOCOL_VERSION: 49,
|
|
12
|
-
logLevel: LOG_LEVELS.WARN,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// Handle ready event
|
|
16
|
-
bot.events.on("ready", async () => {
|
|
17
|
-
console.log("Bot is ready!");
|
|
18
|
-
|
|
19
|
-
// Connect to the server
|
|
20
|
-
await bot.connect()
|
|
21
|
-
|
|
22
|
-
// Create a room after connecting
|
|
23
|
-
await bot.createRoom({
|
|
24
|
-
roomname: "BonkBot's Room",
|
|
25
|
-
maxplayers: 2,
|
|
26
|
-
roompassword: "",
|
|
27
|
-
hidden: false
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Handle connect event
|
|
32
|
-
bot.events.on("ready", function() {
|
|
33
|
-
bot.events.on("ROOM_SHARE_LINK", () => {
|
|
34
|
-
console.log(`Bot created room!\nURL: ${bot.getShareLink()}`);
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
// Set up packet handler
|
|
38
|
-
bot.events.on("PACKET", function(packet) {
|
|
39
|
-
bot.autoHandlePacket(packet);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Handle chat messages
|
|
43
|
-
bot.events.on("CHAT_MESSAGE", function(message) {
|
|
44
|
-
console.log(message.player.username + ": " + message.message);
|
|
45
|
-
|
|
46
|
-
// Check for players command
|
|
47
|
-
if (message.message === "!players") {
|
|
48
|
-
var players = bot.getAllPlayers(true);
|
|
49
|
-
var playerNames = [];
|
|
50
|
-
|
|
51
|
-
for (var i = 0; i < players.length; i++) {
|
|
52
|
-
playerNames.push(players[i].username);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
bot.chat("Players online (" + players.length + "): " + playerNames.join(", "));
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Initialize the bot
|
|
61
|
-
bot.init().catch((error) => {
|
|
62
|
-
console.error("Failed to initialize bot:", error);
|
|
63
|
-
});
|
package/examples/simple-bot.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
const { createBot, LOG_LEVELS } = require("bonkbot");
|
|
2
|
-
|
|
3
|
-
// Create a bot instance
|
|
4
|
-
const bot = createBot({
|
|
5
|
-
account: {
|
|
6
|
-
username: "bonkbot",
|
|
7
|
-
guest: true,
|
|
8
|
-
},
|
|
9
|
-
PROTOCOL_VERSION: 49,
|
|
10
|
-
logLevel: LOG_LEVELS.WARN,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// Handle ready event
|
|
14
|
-
bot.events.on("ready", async () => {
|
|
15
|
-
console.log("Bot is ready!");
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
// Find a room by name
|
|
19
|
-
const roomInfo = await bot.getAddressFromRoomName("test");
|
|
20
|
-
// const roomInfo = await bot.getAddressFromUrl("https://bonk.io/533118qkpuw");
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
console.log(`Found room: ${roomInfo.roomname}`);
|
|
24
|
-
|
|
25
|
-
// Set the room address
|
|
26
|
-
bot.setAddress(roomInfo);
|
|
27
|
-
|
|
28
|
-
// Connect to the server
|
|
29
|
-
await bot.connect();
|
|
30
|
-
|
|
31
|
-
// Join the room
|
|
32
|
-
await bot.joinRoom();
|
|
33
|
-
|
|
34
|
-
// with a password
|
|
35
|
-
|
|
36
|
-
// await bot.joinRoom({
|
|
37
|
-
// password: "32",
|
|
38
|
-
// });
|
|
39
|
-
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error("Failed to find or connect to room:", error);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Handle connect event
|
|
46
|
-
bot.events.on("connect", () => {
|
|
47
|
-
console.log("Bot connected to server!");
|
|
48
|
-
|
|
49
|
-
bot.events.on("JOIN", () => {
|
|
50
|
-
bot.chat("Connected to the room!")
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
bot.events.on("COUNTDOWN", (msg) => {
|
|
54
|
-
bot.chat(`${msg.countdown}!`);
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
bot.events.on("GAME_START", () => {
|
|
58
|
-
bot.chat(`start!`);
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
bot.events.on("GAMEMODE_CHANGE", (msg) => {
|
|
62
|
-
bot.chat(`Gamemode changed to ${msg.mode} with engine ${msg.engine}`);
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
// Set up packet handler
|
|
66
|
-
bot.events.on("PACKET", (packet) => {
|
|
67
|
-
bot.autoHandlePacket(packet);
|
|
68
|
-
|
|
69
|
-
// Ignore spammy packets
|
|
70
|
-
if (packet.type === "TIMESYNC" || packet.type === "PLAYER_PINGS") {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
console.log("Received packet:", packet);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Handle chat messages
|
|
78
|
-
bot.events.on("CHAT_MESSAGE", (message) => {
|
|
79
|
-
console.log(`${message.player.username}: ${message.message}`);
|
|
80
|
-
|
|
81
|
-
// Respond to commands
|
|
82
|
-
switch (message.message) {
|
|
83
|
-
case "!ping":
|
|
84
|
-
bot.chat("Pong!");
|
|
85
|
-
break;
|
|
86
|
-
|
|
87
|
-
case "!help":
|
|
88
|
-
bot.chat("Available commands: !ping, !help, !players, !host");
|
|
89
|
-
break;
|
|
90
|
-
|
|
91
|
-
case "!players":
|
|
92
|
-
const players = bot.getAllPlayers();
|
|
93
|
-
bot.chat(`Players online: ${players.map((p) => p.username).join(", ")}`);
|
|
94
|
-
break;
|
|
95
|
-
|
|
96
|
-
case "!host":
|
|
97
|
-
bot.chat(`The host is ${bot.getHost().username}`);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// Handle player join events
|
|
103
|
-
bot.events.on("PLAYER_JOIN", (event) => {
|
|
104
|
-
const player = event.player;
|
|
105
|
-
if (player) {
|
|
106
|
-
console.log(`${player.username} joined the room!`);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Handle player leave events
|
|
111
|
-
bot.events.on("PLAYER_LEAVE", (event) => {
|
|
112
|
-
const player = event.player;
|
|
113
|
-
if (player) {
|
|
114
|
-
console.log(`${player.username} left the room!`);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// Handle disconnection
|
|
119
|
-
bot.events.on("disconnect", () => {
|
|
120
|
-
console.log("Bot disconnected from the room!");
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// Initialize the bot
|
|
125
|
-
bot.init().catch((error) => {
|
|
126
|
-
console.error("Failed to initialize bot:", error);
|
|
127
|
-
});
|