From 2bf32603335f8fc17fb15d3415cfb0d3f2dcb6d1 Mon Sep 17 00:00:00 2001 From: IdiNium <47635037+idinium96@users.noreply.github.com> Date: Thu, 9 Jun 2022 01:03:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20add=20`pricecheckAfterTrade`=20?= =?UTF-8?q?option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../offer/accepted/updateListings.ts | 31 ++++++++++--------- src/classes/Options.ts | 4 +++ src/schemas/options-json/options.ts | 6 +++- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/classes/MyHandler/offer/accepted/updateListings.ts b/src/classes/MyHandler/offer/accepted/updateListings.ts index 1bee61999..76b7cb1ee 100644 --- a/src/classes/MyHandler/offer/accepted/updateListings.ts +++ b/src/classes/MyHandler/offer/accepted/updateListings.ts @@ -38,6 +38,7 @@ export default function updateListings( craftWeapons = weapons; + const isPricecheckRequestEnabled = opt.miscSettings.pricecheckAfterTrade.enable; const alwaysRemoveCustomTexture = opt.miscSettings.alwaysRemoveItemAttributes.customTexture.enable; const skus: string[] = []; @@ -212,7 +213,7 @@ export default function updateListings( } } - addToQueu(paintedSKU, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(paintedSKU, isNotPure, existInPricelist); }) .catch(err => { const msg = @@ -229,7 +230,7 @@ export default function updateListings( } } - addToQueu(paintedSKU, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(paintedSKU, isNotPure, existInPricelist); }); // } else if (isAutoAddPaintedFromAdmin) { @@ -290,7 +291,7 @@ export default function updateListings( } } - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }) .catch(err => { const msg = `❌ Failed to add ${name} (${sku}) to sell automatically: ${(err as Error).message}`; @@ -305,7 +306,7 @@ export default function updateListings( } } - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }); // } else if (isAutoaddInvalidItems) { @@ -325,11 +326,11 @@ export default function updateListings( .addPrice(entry, true) .then(() => { log.debug(`✅ Automatically added ${name} (${sku}) to sell.`); - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }) .catch(err => { log.warn(`❌ Failed to add ${name} (${sku}) to sell automatically: ${(err as Error).message}`); - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }); // } else if (receivedHighValueNotInPricelist) { @@ -354,7 +355,7 @@ export default function updateListings( } } - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); } else if (receivedUnusualNotInPricelist) { // if the item sku is not in pricelist, not craftweapons or pure or skins AND it's a Unusual (bought with Generic Unusual), and not // from ADMINS, and opt.pricelist.autoAddInvalidUnusual is false, then notify admin. @@ -370,7 +371,7 @@ export default function updateListings( } } - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); } else if (isAutoDisableHighValueItems) { // If item received is high value, temporarily disable that item so it will not be sellable. const oldGroup = inPrice.group; @@ -423,11 +424,11 @@ export default function updateListings( } } - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }) .catch(err => { log.warn(`❌ Failed to disable high value ${sku}: `, err); - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }); // } else if (isAutoRemoveIntentSell) { @@ -437,7 +438,7 @@ export default function updateListings( .removePrice(sku, true) .then(() => { log.debug(`✅ Automatically removed ${name} (${sku}) from pricelist.`); - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }) .catch(err => { const msg = `❌ Failed to automatically remove ${name} (${sku}) from pricelist: ${ @@ -453,7 +454,7 @@ export default function updateListings( } } - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }); } else if (isUpdatePartialPricedItem) { // If item exist in pricelist with "isPartialPriced" set to true and we no longer have that in stock, @@ -499,7 +500,7 @@ export default function updateListings( } } - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }) .catch(err => { const msg = `❌ Failed to automatically update prices for ${name} (${sku}): ${ @@ -515,10 +516,10 @@ export default function updateListings( } } - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); }); } else { - addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); } if ( diff --git a/src/classes/Options.ts b/src/classes/Options.ts index 61d9e7047..09c267a0e 100644 --- a/src/classes/Options.ts +++ b/src/classes/Options.ts @@ -57,6 +57,9 @@ export const DEFAULTS: JsonOptions = { reputationCheck: { checkMptfBanned: false, reptfAsPrimarySource: false + }, + pricecheckAfterTrade: { + enable: true } }, @@ -1134,6 +1137,7 @@ interface MiscSettings { alwaysRemoveItemAttributes?: AlwaysRemoveItemAttributes; deleteUntradableJunk?: OnlyEnable; reputationCheck?: ReputationCheck; + pricecheckAfterTrade?: OnlyEnable; } interface ReputationCheck { diff --git a/src/schemas/options-json/options.ts b/src/schemas/options-json/options.ts index 18659ab01..dda0b843b 100644 --- a/src/schemas/options-json/options.ts +++ b/src/schemas/options-json/options.ts @@ -443,6 +443,9 @@ export const optionsSchema: jsonschema.Schema = { }, required: ['checkMptfBanned', 'reptfAsPrimarySource'], additionalProperties: false + }, + pricecheckAfterTrade: { + $ref: '#/definitions/only-enable' } }, required: [ @@ -458,7 +461,8 @@ export const optionsSchema: jsonschema.Schema = { 'game', 'alwaysRemoveItemAttributes', 'deleteUntradableJunk', - 'reputationCheck' + 'reputationCheck', + 'pricecheckAfterTrade' ], additionalProperties: false }, From 097d01fe9d16f7b9cd49966de3c32f1e898bb527 Mon Sep 17 00:00:00 2001 From: IdiNium <47635037+idinium96@users.noreply.github.com> Date: Thu, 9 Jun 2022 01:08:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A8=20fix=20typo,=20simplify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../offer/accepted/updateListings.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/classes/MyHandler/offer/accepted/updateListings.ts b/src/classes/MyHandler/offer/accepted/updateListings.ts index 76b7cb1ee..00b81bf20 100644 --- a/src/classes/MyHandler/offer/accepted/updateListings.ts +++ b/src/classes/MyHandler/offer/accepted/updateListings.ts @@ -213,7 +213,7 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(paintedSKU, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(paintedSKU, isNotPure, existInPricelist); }) .catch(err => { const msg = @@ -230,7 +230,7 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(paintedSKU, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(paintedSKU, isNotPure, existInPricelist); }); // } else if (isAutoAddPaintedFromAdmin) { @@ -291,7 +291,7 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }) .catch(err => { const msg = `❌ Failed to add ${name} (${sku}) to sell automatically: ${(err as Error).message}`; @@ -306,7 +306,7 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }); // } else if (isAutoaddInvalidItems) { @@ -326,11 +326,11 @@ export default function updateListings( .addPrice(entry, true) .then(() => { log.debug(`✅ Automatically added ${name} (${sku}) to sell.`); - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }) .catch(err => { log.warn(`❌ Failed to add ${name} (${sku}) to sell automatically: ${(err as Error).message}`); - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }); // } else if (receivedHighValueNotInPricelist) { @@ -355,7 +355,7 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); } else if (receivedUnusualNotInPricelist) { // if the item sku is not in pricelist, not craftweapons or pure or skins AND it's a Unusual (bought with Generic Unusual), and not // from ADMINS, and opt.pricelist.autoAddInvalidUnusual is false, then notify admin. @@ -371,7 +371,7 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); } else if (isAutoDisableHighValueItems) { // If item received is high value, temporarily disable that item so it will not be sellable. const oldGroup = inPrice.group; @@ -424,11 +424,11 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }) .catch(err => { log.warn(`❌ Failed to disable high value ${sku}: `, err); - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }); // } else if (isAutoRemoveIntentSell) { @@ -438,7 +438,7 @@ export default function updateListings( .removePrice(sku, true) .then(() => { log.debug(`✅ Automatically removed ${name} (${sku}) from pricelist.`); - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }) .catch(err => { const msg = `❌ Failed to automatically remove ${name} (${sku}) from pricelist: ${ @@ -454,7 +454,7 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }); } else if (isUpdatePartialPricedItem) { // If item exist in pricelist with "isPartialPriced" set to true and we no longer have that in stock, @@ -500,7 +500,7 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }) .catch(err => { const msg = `❌ Failed to automatically update prices for ${name} (${sku}): ${ @@ -516,10 +516,10 @@ export default function updateListings( } } - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); }); } else { - if (isPricecheckRequestEnabled) addToQueu(sku, isNotPure, existInPricelist); + if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist); } if ( @@ -556,7 +556,7 @@ export default function updateListings( } } -function addToQueu(sku: string, isNotPure: boolean, isExistInPricelist: boolean): void { +function addToQ(sku: string, isNotPure: boolean, isExistInPricelist: boolean): void { /** * Request priceheck on each sku involved in the trade, except craft weapons (if weaponsAsCurrency enabled) and pure. */