Initial commit: POE2 automated trade bot
Monitors pathofexile.com/trade2 for new listings, travels to seller hideouts, buys items from public stash tabs, and stores them. Includes persistent C# OCR daemon for fast screen capture + Windows native OCR, web dashboard for managing trade links and settings, and full game automation via Win32 SendInput. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
41d174195e
28 changed files with 6449 additions and 0 deletions
24
src/util/retry.ts
Normal file
24
src/util/retry.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { sleep } from './sleep.js';
|
||||
import { logger } from './logger.js';
|
||||
|
||||
export async function retry<T>(
|
||||
fn: () => Promise<T>,
|
||||
options: { maxAttempts?: number; delayMs?: number; label?: string } = {},
|
||||
): Promise<T> {
|
||||
const { maxAttempts = 3, delayMs = 1000, label = 'operation' } = options;
|
||||
|
||||
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
||||
try {
|
||||
return await fn();
|
||||
} catch (err) {
|
||||
if (attempt === maxAttempts) {
|
||||
logger.error({ err, attempt, label }, `${label} failed after ${maxAttempts} attempts`);
|
||||
throw err;
|
||||
}
|
||||
logger.warn({ err, attempt, label }, `${label} failed, retrying in ${delayMs}ms...`);
|
||||
await sleep(delayMs * attempt);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Unreachable');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue