From 028cbf227f3704bb7bcbb533dc5e9e95428921e5 Mon Sep 17 00:00:00 2001 From: Sam Gaus Date: Fri, 14 Jun 2024 17:21:53 +0100 Subject: [PATCH] Include pwd by default in kol.js and bump version --- packages/autospade/compiler.ts | 4 ---- packages/kol.js/package.json | 2 +- packages/kol.js/src/Client.ts | 13 ++++++++++--- packages/oaf/src/commands/clan/_dread.ts | 2 -- packages/oaf/src/commands/kol/spade.ts | 10 ---------- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/packages/autospade/compiler.ts b/packages/autospade/compiler.ts index 48efe8d..c8c4e19 100644 --- a/packages/autospade/compiler.ts +++ b/packages/autospade/compiler.ts @@ -68,7 +68,6 @@ function compileAction({ text }: Step) { action, which: 2, whichitem: itemId || id, - pwd: true, }, }); } @@ -92,7 +91,6 @@ function compileAction({ text }: Step) { searchParams: { which: 1, whichitem: id, - pwd: true, }, }); @@ -102,7 +100,6 @@ function compileAction({ text }: Step) { searchParams: { which: 1, whichitem: id, - pwd: true, }, }); @@ -112,7 +109,6 @@ function compileAction({ text }: Step) { searchParams: { which: 1, whichitem: id, - pwd: true, }, }); diff --git a/packages/kol.js/package.json b/packages/kol.js/package.json index 2bdc8ca..32ac4f5 100644 --- a/packages/kol.js/package.json +++ b/packages/kol.js/package.json @@ -1,6 +1,6 @@ { "name": "kol.js", - "version": "0.1.0", + "version": "0.1.1", "main": "src/index.ts", "type": "module", "files": [ diff --git a/packages/kol.js/src/Client.ts b/packages/kol.js/src/Client.ts index db7274b..e8484fa 100644 --- a/packages/kol.js/src/Client.ts +++ b/packages/kol.js/src/Client.ts @@ -49,9 +49,15 @@ export class Client extends (EventEmitter as new () => TypedEmitter) { prefixUrl: "https://www.kingdomofloathing.com", handlers: [ (options, next) => { - if (options.form?.pwd === true) options.form.pwd = this.#pwd; - const searchParams = options.searchParams as URLSearchParams; - if (searchParams.has("pwd")) searchParams.set("pwd", this.#pwd); + if (options.form) { + if (options.form.pwd !== false) options.form.pwd = this.#pwd; + } + + if (options.searchParams) { + const searchParams = options.searchParams as URLSearchParams; + if (searchParams.get("pwd") !== "false") searchParams.set("pwd", this.#pwd); + } + return next(options); }, ], @@ -429,6 +435,7 @@ export class Client extends (EventEmitter as new () => TypedEmitter) { whichclan: id, action: "joinclan", confirm: "on", + pwd: true, }, }); return ( diff --git a/packages/oaf/src/commands/clan/_dread.ts b/packages/oaf/src/commands/clan/_dread.ts index 4730059..50e3335 100644 --- a/packages/oaf/src/commands/clan/_dread.ts +++ b/packages/oaf/src/commands/clan/_dread.ts @@ -227,7 +227,6 @@ export async function getMissingRaidLogs( row += 10; raidLogs = await kolClient.fetchText("clan_oldraidlogs.php", { searchParams: { - pwd: true, startrow: row, }, }); @@ -240,7 +239,6 @@ export async function getMissingRaidLogs( export async function getFinishedRaidLog(raidId: number) { return await kolClient.fetchText("clan_viewraidlog.php", { searchParams: { - pwd: true, viewlog: raidId, backstart: 0, }, diff --git a/packages/oaf/src/commands/kol/spade.ts b/packages/oaf/src/commands/kol/spade.ts index 1e4e240..73dc1ac 100644 --- a/packages/oaf/src/commands/kol/spade.ts +++ b/packages/oaf/src/commands/kol/spade.ts @@ -32,7 +32,6 @@ const ITEM_SPADING_CALLS = [ [ "inv_equip.php", { - pwd: true, action: "equip", which: 2, whichitem: id, @@ -47,7 +46,6 @@ const ITEM_SPADING_CALLS = [ [ "inv_equip.php", { - pwd: true, action: "equip", which: 2, whichitem: id, @@ -61,7 +59,6 @@ const ITEM_SPADING_CALLS = [ [ "inv_eat.php", { - pwd: true, which: 1, whichitem: id, }, @@ -74,7 +71,6 @@ const ITEM_SPADING_CALLS = [ [ "inv_booze.php", { - pwd: true, which: 1, whichitem: id, }, @@ -87,7 +83,6 @@ const ITEM_SPADING_CALLS = [ [ "inv_spleen.php", { - pwd: true, which: 1, whichitem: id, }, @@ -159,7 +154,6 @@ export async function execute(interaction: ChatInputCommandInteraction) { async function testEquipmentAgainstCurrentFamiliar(itemId: number) { const responseText = await kolClient.fetchText("inv_equip.php", { searchParams: { - pwd: true, action: "equip", which: 2, whichitem: itemId, @@ -250,7 +244,6 @@ async function spadeItem(itemId: number) { const exists = !/Nopers/.test( await kolClient.fetchText("inv_equip.php", { searchParams: { - pwd: true, action: "equip", which: 2, whichitem: itemId, @@ -273,7 +266,6 @@ async function spadeItem(itemId: number) { const tradeable = !/That item cannot be sold or transferred/.test( await kolClient.fetchText("town_sellflea.php", { searchParams: { - pwd: true, whichitem: itemId, sellprice: "", selling: "Yep.", @@ -326,7 +318,6 @@ async function spadeFamiliars(interaction: ChatInputCommandInteraction) { async function spadeFamiliar(famId: number) { const page = await kolClient.fetchText("desc_familiar.php", { searchParams: { - pwd: true, which: famId, }, }); @@ -382,7 +373,6 @@ async function spadeSkill(skillId: number) { const page = await kolClient.fetchText("runskillz.php", { searchParams: { - pwd: true, action: "Skillz", whichskill: skillId, targetplayer: 1,