feat: discord linking, @tags, music and sfx sliders, required device ids

- Discord: the account page links a player's Discord account through
  Discord's sign-in (lib/discord.js); only linked names are shown on cards
  (typed ones are cleared). A bot keeps the Server Booster badge on linked
  accounts that boost. The game tells the client where the player is, for
  the client's Discord rich presence (flashvars discordAppId).
- @username tags in chat, chat balloons and wall posts: only real players'
  names (asked of the server, "xmn"), names with spaces too, drawn on a
  blue box; a click opens the player's card.
- Settings: separate Music and SFX volume sliders for the old one.
- Device ids required: a launcher that sends none (before 1.3.0) is told
  at the game's login "Your client is outdated. Update at
  https://burrow.moe/download". AJ_REQUIRE_DEVICE=0 turns it off.
- Panels: clear a player's Jammer Wall posts; turning away masterpieces
  and player items asks first.
- Item Giver: negative colour ids (the same colour written signed).
- buildVersion 71; the client rebuilt with Snipzil's sitting fix.
This commit is contained in:
Burrowdev committed 2026-10-18 19:35:51 +03:00
1 parent 1d9b70f32e
commit 33f56074a4
35 files changed
+2076 -101

No files matched your search

+43 -9
View File
@@ -12,6 +12,7 @@ const config = require("../config.js");
const limits = require("./limits.js");
const achievements = require("./achievements.js");
const badges = require("./badges.js");
const discord = require("./discord.js");
const bans = require("./bans.js");
const captcha = require("./captcha.js");
const chatlog = require("./chatlog.js");
@@ -40,6 +41,12 @@ const world = require("./world.js");
const COOKIE = "ajc_account";
// A device that gave its two-step code keeps this for 30 days (lib/totp.js).
const DEVICE_COOKIE = "ajc_device";
// a Discord link under way (lib/discord.js): the browser that started it
// must be the one that comes back. Lax, as Discord's redirect back is from
// another site, which the page's own (Strict) cookie is not sent from.
const DISCORD_COOKIE = "ajc_dlink";
const discordCookie = (value, maxAgeSeconds) =>
`${DISCORD_COOKIE}=${value}; Path=/account/discord; HttpOnly; SameSite=Lax; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`;
const SESSION_HOURS = 12;
const TEN_MINUTES_MS = 600000;
const MAX_NOTE = 120;
@@ -164,6 +171,8 @@ const profile = (account, from) => {
locked: account.locked,
twoStep: twoStepOf(account),
discord: account.discord,
discordLinked: Boolean(account.discordId),
discordLinking: discord.linking(),
bio: account.bio,
bioLimit: badges.MAX_BIO,
badges: badges.of(account).map(badge => badge.label),
@@ -403,16 +412,15 @@ const act = (account, body, req, from, res) => {
account.playtimePublic = body.on === true;
accounts.save(account);
return {ok: account.playtimePublic ? "Others can see your playtime on your card." : "Your playtime is private."};
// their Discord username, for their card in the game. empty takes it off.
case "discord": {
const name = badges.discordName(body.name);
if (name === null) {
return {error: "Not a Discord username."};
// their Discord account, for their card in the game: it is linked by
// signing in to Discord (GET /account/discord/link), and only taken off
// here, with the booster badge it brought.
case "discord":
if (String(body.name || "") !== "") {
return {error: "Link your Discord account instead."};
}
account.discord = name;
accounts.save(account);
return {ok: name ? "Saved." : "Removed."};
}
discord.unlink(account);
return {ok: "Removed."};
// the player's own words about a buddy; only they see them.
case "buddyNote": {
const key = String(body.name || "").toLowerCase();
@@ -570,12 +578,38 @@ const handle = async (req, res, url, from, web) => {
}
}
// back from Discord (lib/discord.js): the state and the nonce must be the
// ones the link began with. the page then says how it went.
if (route === "GET /account/discord/callback") {
const nonce = (new RegExp(`(?:^|;\\s*)${DISCORD_COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || "") || [])[1];
const result = url.searchParams.get("error") ? {error: "cancelled"}
: await discord.finish(url.searchParams.get("state"), nonce, url.searchParams.get("code"));
res.setHeader("Set-Cookie", discordCookie("", 0));
res.writeHead(302, {Location: `/account?discord=${result.ok ? "linked" : result.error}`});
res.end();
return;
}
const account = signedInAs(req);
if (!account) {
reply(401, {error: "Sign in first."});
return;
}
switch (route) {
// the page's "Link Discord": off to Discord's sign-in, which comes back
// to /account/discord/callback.
case "GET /account/discord/link": {
if (!discord.linking() || banFor(account, from)) {
res.writeHead(302, {Location: "/account?discord=off"});
res.end();
return;
}
const {url: to, nonce} = discord.start(account);
res.setHeader("Set-Cookie", discordCookie(nonce, 600));
res.writeHead(302, {Location: to});
res.end();
return;
}
// A copy of their data, as a file. also from the page of a ban.
case "GET /account/api/export":
if (!writesPerTenMinutes.allow(account.id)) {