harshil

smash-karts-bot

Type "@game" in a WhatsApp group, and a bot makes a game room and sends back the invite link.

prototypeNode.js2026-10solo, with an AI agent (22 of 34 commits)github ↗

what
A WhatsApp bot for a group of friends. One message, and it sets up a private Smash Karts game with the arena, weapons and round length you asked for.
the hard part
The game has no buttons a program can find - it is one big picture. The bot has to click like a person, and check its own work.
where it is
Works on the real game. A room takes about 65–80 seconds.

How it works

  • Clicking without buttons. The game is one WebGL — The browser's interface to the graphics card, used to draw 2D and 3D scenes fast. picture. I recorded one run through the menus. With each click, the bot saved a small picture of what was under the mouse. Before it clicks again, it waits until the screen shows that picture. A slow load only delays a click.
  • The exact link. The game copies its invite link with its own function, window.copyText. The bot listens to that function, so it gets the link exactly. No screen reading.
  • Checking its own work. The link hides the room settings inside it — the weapons, the round length, team mode. The bot reads them back and checks them before posting. A wrong click fails the try instead of reaching the group.

What went wrong

  • Taking a screenshot of only part of the page made the browser redraw, and the game then missed the next click. Now the bot always takes the full screen and cuts it in code.
  • On a machine without a graphics card, the game checks the mouse only a few times per second. A click only counts if the mouse is on the button both when it presses and when it lets go. So the bot now waits 400 ms after each move.

numbers

valuewhatsource
65–80 sto make a room, on the first try (game version 2.16.007)README
85–130 son version 2.16.008, across 6 arenas and 1 to 12 weaponsREADME
3tries at most. Each failure sends a screenshot to the group.README

explore the code

Explorer 6 parts · tap one
src/whatsapp.js

Connects to WhatsApp and reads "@game" messages from the allowed groups. Reconnects if the connection drops. source ↗

src/roomManager.js

Makes one room at a time. If two friends ask at once, they share the same room. source ↗

src/host.js

Opens the game in a real browser and grabs the invite link. source ↗

src/replay.js

Replays clicks that I recorded once. Before each click, it waits until the screen looks like it did in the recording. source ↗

src/vision.js

Compares small 40×40 pixel squares of the screen, so a button that changes color when you hover still matches. source ↗

src/photon.js

Decodes the game's own network messages (the Photon protocol) into plain data. source ↗

keys

This page reads like any web page. If you use vim, it also works like vim.

move
j / knext / previous line
gg / Gtop / bottom
Ctrl-d / Ctrl-uhalf a page down / up
]] / [[next / previous heading
H / Lprevious / next project or post
act
Enter or gfopen the link on the current line
Kexplain the term on the current line
/ then n / Nsearch this page
:command line: a page name, help, q
Spacemenu: f find, p projects, w writing
Space a / Ctrl-e / Alt-1…4pin a page, list pins, jump to a pin
Ctrl-oback
Escclose, clear search