bonktools 2.3.0 → 3.1.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.
@@ -0,0 +1,37 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIGcTCCBNmgAwIBAgIQBCOxRTvzzdaopUgt3SZ4TzANBgkqhkiG9w0BAQsFADBg
3
+ MQswCQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQD
4
+ Ey5TZWN0aWdvIFB1YmxpYyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gQ0EgRFYgUjM2
5
+ MB4XDTI1MDczMTAwMDAwMFoXDTI2MDgzMTIzNTk1OVowFDESMBAGA1UEAwwJKi5i
6
+ b25rLmlvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1KDYTKGMqzdN
7
+ u0GgjzTFnH5jRxZ9Bkifo0DiD85aGtqO8Q7v9gSe1IFzB0wMUOA4iC1L9ojpoa+9
8
+ T01uepYOHKFV0uzuGrUIA/M+B6ERIXYOETg2PoQnnf00Rh56nZbCZa5IzOELmRZH
9
+ l+QyCgxJL2kQ6qgIEsUYGJELGhobnkNJmw/9+UXHQgZHHh4mOsyYGd7XRvNCMGhR
10
+ iBkKaC6+akk5vlI5/ut6p/qK9T0YMRfYX1jHFtRKbLw77xGYfYYQAV2bk/WNLl54
11
+ HelerG4CX3whQFnlTI38jLc/gArR5ngl5kTvqLqbYpH6l40TNFyd+wMHRjTCwbJR
12
+ Q1vwtECS8QIDAQABo4IC8TCCAu0wHwYDVR0jBBgwFoAUaMASFhgOr872h6YyV6NG
13
+ UV3LBycwHQYDVR0OBBYEFFLjZvdiSom9PXwr0TBVp8MdIVyiMA4GA1UdDwEB/wQE
14
+ AwIFoDAMBgNVHRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcD
15
+ AjBJBgNVHSAEQjBAMDQGCysGAQ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ws1Fv1dsL/
31
+ u/q0h5NtdX/FuTgJ3IncfAurhSxvWLhoIuMrq4GyXfFU6NeFLOc7qxKzlWopLauZ
32
+ OdUCnhNgVDUU1cojkPdCdII7PRfF8z1mOL2CpjXcT5MglIWExPEOlyw/FYkAM2V6
33
+ xE+DH0eh2K6CYr3WXqAp9/1OY6f13wHfOm3EInX/N1QEVzTjkIuCRuoHL8iuxos0
34
+ 5l5K0oZIdLV9Jm+3QXjkF6W4Jv/B8cA/IhimR7+AlpjrCGBj3sz3LIMbQCXAMKy0
35
+ bjxY1MXD/pd6Uw3fVpLMRLV475APxwMB/lhqJuv6kHlgTQ7gwIPwB5fYWHIQzlxe
36
+ t217eGbT7tfXnVw/ywSwbEMgekAx
37
+ -----END CERTIFICATE-----
@@ -0,0 +1,63 @@
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
+ });
@@ -0,0 +1,127 @@
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
+ });