Skip to content

Commit

Permalink
🔀 Merge pull request #1157 from TF2Autobot/option-disable-pricecheck
Browse files Browse the repository at this point in the history
✨ add `pricecheckAfterTrade` option
  • Loading branch information
idinium96 authored Jun 8, 2022
2 parents 6cd4048 + 097d01f commit 99e620c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
33 changes: 17 additions & 16 deletions src/classes/MyHandler/offer/accepted/updateListings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];

Expand Down Expand Up @@ -212,7 +213,7 @@ export default function updateListings(
}
}

addToQueu(paintedSKU, isNotPure, existInPricelist);
if (isPricecheckRequestEnabled) addToQ(paintedSKU, isNotPure, existInPricelist);
})
.catch(err => {
const msg =
Expand All @@ -229,7 +230,7 @@ export default function updateListings(
}
}

addToQueu(paintedSKU, isNotPure, existInPricelist);
if (isPricecheckRequestEnabled) addToQ(paintedSKU, isNotPure, existInPricelist);
});
//
} else if (isAutoAddPaintedFromAdmin) {
Expand Down Expand Up @@ -290,7 +291,7 @@ export default function updateListings(
}
}

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}`;
Expand All @@ -305,7 +306,7 @@ export default function updateListings(
}
}

addToQueu(sku, isNotPure, existInPricelist);
if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist);
});
//
} else if (isAutoaddInvalidItems) {
Expand All @@ -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) addToQ(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) addToQ(sku, isNotPure, existInPricelist);
});
//
} else if (receivedHighValueNotInPricelist) {
Expand All @@ -354,7 +355,7 @@ export default function updateListings(
}
}

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.
Expand All @@ -370,7 +371,7 @@ export default function updateListings(
}
}

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;
Expand Down Expand Up @@ -423,11 +424,11 @@ export default function updateListings(
}
}

addToQueu(sku, isNotPure, existInPricelist);
if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist);
})
.catch(err => {
log.warn(`❌ Failed to disable high value ${sku}: `, err);
addToQueu(sku, isNotPure, existInPricelist);
if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist);
});
//
} else if (isAutoRemoveIntentSell) {
Expand All @@ -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) addToQ(sku, isNotPure, existInPricelist);
})
.catch(err => {
const msg = `❌ Failed to automatically remove ${name} (${sku}) from pricelist: ${
Expand All @@ -453,7 +454,7 @@ export default function updateListings(
}
}

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,
Expand Down Expand Up @@ -499,7 +500,7 @@ export default function updateListings(
}
}

addToQueu(sku, isNotPure, existInPricelist);
if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist);
})
.catch(err => {
const msg = `❌ Failed to automatically update prices for ${name} (${sku}): ${
Expand All @@ -515,10 +516,10 @@ export default function updateListings(
}
}

addToQueu(sku, isNotPure, existInPricelist);
if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist);
});
} else {
addToQueu(sku, isNotPure, existInPricelist);
if (isPricecheckRequestEnabled) addToQ(sku, isNotPure, existInPricelist);
}

if (
Expand Down Expand Up @@ -555,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.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/classes/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export const DEFAULTS: JsonOptions = {
reputationCheck: {
checkMptfBanned: false,
reptfAsPrimarySource: false
},
pricecheckAfterTrade: {
enable: true
}
},

Expand Down Expand Up @@ -1134,6 +1137,7 @@ interface MiscSettings {
alwaysRemoveItemAttributes?: AlwaysRemoveItemAttributes;
deleteUntradableJunk?: OnlyEnable;
reputationCheck?: ReputationCheck;
pricecheckAfterTrade?: OnlyEnable;
}

interface ReputationCheck {
Expand Down
6 changes: 5 additions & 1 deletion src/schemas/options-json/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ export const optionsSchema: jsonschema.Schema = {
},
required: ['checkMptfBanned', 'reptfAsPrimarySource'],
additionalProperties: false
},
pricecheckAfterTrade: {
$ref: '#/definitions/only-enable'
}
},
required: [
Expand All @@ -458,7 +461,8 @@ export const optionsSchema: jsonschema.Schema = {
'game',
'alwaysRemoveItemAttributes',
'deleteUntradableJunk',
'reputationCheck'
'reputationCheck',
'pricecheckAfterTrade'
],
additionalProperties: false
},
Expand Down

0 comments on commit 99e620c

Please sign in to comment.