Rework pacing, pause poll, add user search, voice overview, and DM list

This commit is contained in:
Fisto
2026-09-13 15:47:43 +02:00
parent 32201b34cf
commit 4e1046fae7
13 changed files with 539 additions and 81 deletions
+24 -4
View File
@@ -19,13 +19,13 @@ import {
parseCommand,
parsePoll,
parseTier,
randomActionDelay,
redactSecrets,
stripMentions,
toCachedMessage,
type CachedMessage,
type PuppetMessage
} from "./communication.js";
import { PACING, planSend } from "./pacing.js";
function cached(id: number, content = `m${id}`): CachedMessage {
return { id: String(id), authorId: "1", authorName: "a", content, timestamp: "" };
@@ -77,11 +77,31 @@ function entry(id: number, trusted: boolean): PuppetMessage {
assert.equal(isTrusted("stranger", "owner", ["trusted"]), false);
}
// pacing stays in the 500-2800 ms window
// pacing: fast first send in a burst, 500-2800 ms afterwards, variable reset
{
for (let i = 0; i < 200; i++) {
const delay = randomActionDelay();
assert.ok(delay >= 500 && delay <= 2800, `delay out of range: ${delay}`);
const first = planSend(1_000_000, 0);
assert.ok(
first.delay >= PACING.firstMinMs && first.delay <= PACING.firstMaxMs,
`first delay out of range: ${first.delay}`
);
assert.ok(
first.burstUntil - 1_000_000 >= PACING.idleMinMs && first.burstUntil - 1_000_000 <= PACING.idleMaxMs,
`burst window out of range: ${first.burstUntil}`
);
const followUp = planSend(1_000_000, 1_001_000);
assert.ok(
followUp.delay >= PACING.burstMinMs && followUp.delay <= PACING.burstMaxMs,
`burst delay out of range: ${followUp.delay}`
);
// A fresh burst after the window expired is fast again.
const resumed = planSend(2_000_000, 1_000_000);
assert.ok(
resumed.delay >= PACING.firstMinMs && resumed.delay <= PACING.firstMaxMs,
`resumed delay out of range: ${resumed.delay}`
);
}
}