Skip to content

Commit

Permalink
Include pwd by default in kol.js and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
gausie committed Jun 14, 2024
1 parent 19c1c91 commit 028cbf2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
4 changes: 0 additions & 4 deletions packages/autospade/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function compileAction({ text }: Step) {
action,
which: 2,
whichitem: itemId || id,
pwd: true,
},
});
}
Expand All @@ -92,7 +91,6 @@ function compileAction({ text }: Step) {
searchParams: {
which: 1,
whichitem: id,
pwd: true,
},
});

Expand All @@ -102,7 +100,6 @@ function compileAction({ text }: Step) {
searchParams: {
which: 1,
whichitem: id,
pwd: true,
},
});

Expand All @@ -112,7 +109,6 @@ function compileAction({ text }: Step) {
searchParams: {
which: 1,
whichitem: id,
pwd: true,
},
});

Expand Down
2 changes: 1 addition & 1 deletion packages/kol.js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kol.js",
"version": "0.1.0",
"version": "0.1.1",
"main": "src/index.ts",
"type": "module",
"files": [
Expand Down
13 changes: 10 additions & 3 deletions packages/kol.js/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ export class Client extends (EventEmitter as new () => TypedEmitter<Events>) {
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);
},
],
Expand Down Expand Up @@ -429,6 +435,7 @@ export class Client extends (EventEmitter as new () => TypedEmitter<Events>) {
whichclan: id,
action: "joinclan",
confirm: "on",
pwd: true,
},
});
return (
Expand Down
2 changes: 0 additions & 2 deletions packages/oaf/src/commands/clan/_dread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ export async function getMissingRaidLogs(
row += 10;
raidLogs = await kolClient.fetchText("clan_oldraidlogs.php", {
searchParams: {
pwd: true,
startrow: row,
},
});
Expand All @@ -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,
},
Expand Down
10 changes: 0 additions & 10 deletions packages/oaf/src/commands/kol/spade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const ITEM_SPADING_CALLS = [
[
"inv_equip.php",
{
pwd: true,
action: "equip",
which: 2,
whichitem: id,
Expand All @@ -47,7 +46,6 @@ const ITEM_SPADING_CALLS = [
[
"inv_equip.php",
{
pwd: true,
action: "equip",
which: 2,
whichitem: id,
Expand All @@ -61,7 +59,6 @@ const ITEM_SPADING_CALLS = [
[
"inv_eat.php",
{
pwd: true,
which: 1,
whichitem: id,
},
Expand All @@ -74,7 +71,6 @@ const ITEM_SPADING_CALLS = [
[
"inv_booze.php",
{
pwd: true,
which: 1,
whichitem: id,
},
Expand All @@ -87,7 +83,6 @@ const ITEM_SPADING_CALLS = [
[
"inv_spleen.php",
{
pwd: true,
which: 1,
whichitem: id,
},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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.",
Expand Down Expand Up @@ -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,
},
});
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 028cbf2

Please sign in to comment.