From 715a28f198ea0ec9e7c57f45907346dc7502f5e9 Mon Sep 17 00:00:00 2001 From: rosalina Date: Sun, 14 Jan 2024 18:11:03 -0500 Subject: [PATCH] use s3si.ts fetcher and send a user agent --- src/app.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app.ts b/src/app.ts index 70e49cb..7c214af 100644 --- a/src/app.ts +++ b/src/app.ts @@ -11,6 +11,7 @@ import { GameFetcher } from "./GameFetcher.ts"; import { DEFAULT_ENV, Env } from "./env.ts"; import { SplashcatExporter } from "./exporters/splashcat.ts"; import { SPLATOON3_TITLE_ID } from "./constant.ts"; +import { USERAGENT } from "./constant.ts"; export type Opts = { profilePath: string; @@ -424,11 +425,17 @@ export class App { } async monitorWithNxapi() { this.env.logger.debug("Monitoring with nxapi presence"); + const fetcher = this.env.newFetcher(); await this.exportOnce(); while (true) { await this.countDown(this.profile.state.monitorInterval); - const nxapiResponse = await fetch(this.opts.nxapiPresenceUrl!); + const nxapiResponse = await fetcher.get({ + url: this.opts.nxapiPresenceUrl!, + headers: { + "User-Agent": USERAGENT, + }, + }); const nxapiData = await nxapiResponse.json(); const isSplatoon3Active = nxapiData.title?.id === SPLATOON3_TITLE_ID; if (isSplatoon3Active || this.splatoon3PreviouslyActive) {