button reward updates

This commit is contained in:
legop3
2026-04-24 13:19:56 -04:00
parent d3f263c216
commit 0c93aacdf6
5 changed files with 88 additions and 43 deletions
+32 -16
View File
@@ -1,32 +1,48 @@
const LETTERS = 'abcdefghijklmnopqrstuvwxyz';
const BURST_COUNT = 18;
const MIN_BURST_SIZE = 2;
const MAX_BURST_SIZE = 8;
const MIN_BURST_DELAY_MS = 80;
const MAX_BURST_DELAY_MS = 420;
function randLetter() {
return LETTERS[Math.floor(Math.random() * LETTERS.length)];
}
function randInt(min, max) {
return min + Math.floor(Math.random() * (max - min + 1));
}
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
module.exports = {
id: 'chatSpam',
name: 'Chat Spam',
goal: 320,
async run(ctx) {
const nickname = randLetter();
const messageCount = 100;
for (let i = 0; i < messageCount; i += 1) {
const len = 3 + Math.floor(Math.random() * 14);
let text = '';
for (let j = 0; j < len; j += 1) {
text += randLetter();
}
try {
ctx.sendExternalMessage({
nickname,
role: 'spectator',
roverId: null,
text,
});
} catch {
// ignore spam errors
for (let burst = 0; burst < BURST_COUNT; burst += 1) {
const burstSize = randInt(MIN_BURST_SIZE, MAX_BURST_SIZE);
for (let i = 0; i < burstSize; i += 1) {
const len = 3 + Math.floor(Math.random() * 14);
let text = '';
for (let j = 0; j < len; j += 1) {
text += randLetter();
}
try {
ctx.sendExternalMessage({
nickname,
role: 'spectator',
roverId: null,
text,
});
} catch {
// ignore spam errors
}
}
await sleep(randInt(MIN_BURST_DELAY_MS, MAX_BURST_DELAY_MS));
}
},
};