Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back auto-check for missing listings #1786

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/classes/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ export default class Bot {
}

startAutoRefreshListings(): void {
return;
// Automatically check for missing listings every 30 minutes
let pricelistLength = 0;

Expand Down Expand Up @@ -634,10 +633,6 @@ export default class Bot {
if (this.options.normalize.strangeAsSecondQuality.our && listingSKU.includes(';strange')) {
listingSKU = listingSKU.replace(';strange', '');
}
} else {
if (/;[p][0-9]+/.test(listingSKU)) {
listingSKU = listingSKU.replace(/;[p][0-9]+/, '');
}
}

let match: Entry | null;
Expand Down Expand Up @@ -689,8 +684,6 @@ export default class Bot {
if (
_listings.length === 1 &&
listing.intent === 0 && // We only check if the only listing exist is buy order
entry.max > 1 &&
amountAvailable > 0 &&
amountAvailable > entry.min
) {
// here we only check if the bot already have that item
Expand Down
23 changes: 12 additions & 11 deletions src/classes/Commands/sub-classes/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import log from '../../../lib/logger';
import { pure, testPriceKey } from '../../../lib/tools/export';
import filterAxiosError from '@tf2autobot/filter-axios-error';
import { AxiosError } from 'axios';
import { Entry } from '../../Pricelist';

// Bot manager commands

Expand Down Expand Up @@ -617,13 +618,15 @@ export default class ManagerCommands {
if (opt.normalize.strangeAsSecondQuality.our && listingSKU.includes(';strange')) {
listingSKU = listingSKU.replace(';strange', '');
}
} else {
if (/;[p][0-9]+/.test(listingSKU)) {
listingSKU = listingSKU.replace(/;[p][0-9]+/, '');
}
}

const match = this.bot.pricelist.getPrice({ priceKey: listingSKU });
let match: Entry | null;
const assetIdPrice = this.bot.pricelist.getPrice({ priceKey: listing.id.slice('440_'.length) });
if (null !== assetIdPrice) {
match = assetIdPrice;
} else {
match = this.bot.pricelist.getPrice({ priceKey: listingSKU });
}

if (isFilterCantAfford && listing.intent === 0 && match !== null) {
const canAffordToBuy = inventoryManager.isCanAffordToBuy(match.buy, inventory);
Expand Down Expand Up @@ -668,8 +671,6 @@ export default class ManagerCommands {
if (
_listings.length === 1 &&
listing.intent === 0 && // We only check if the only listing exist is buy order
entry.max > 1 &&
amountAvailable > 0 &&
amountAvailable > entry.min
) {
// here we only check if the bot already have that item
Expand Down Expand Up @@ -714,8 +715,8 @@ export default class ManagerCommands {
}
}

const skusToCheck = Object.keys(pricelist);
const pricelistCount = skusToCheck.length;
const priceKeysToCheck = Object.keys(pricelist);
const pricelistCount = priceKeysToCheck.length;

if (pricelistCount > 0) {
clearTimeout(this.executeRefreshListTimeout);
Expand All @@ -724,7 +725,7 @@ export default class ManagerCommands {
log.debug(
'Checking listings for ' +
pluralize('item', pricelistCount, true) +
` [${skusToCheck.join(', ')}] ...`
` [${priceKeysToCheck.join(', ')}] ...`
);

this.bot.sendMessage(
Expand All @@ -744,7 +745,7 @@ export default class ManagerCommands {
}, (this.pricelistCount > 4000 ? 60 : 30) * 60 * 1000);

await this.bot.listings.recursiveCheckPricelist(
skusToCheck,
priceKeysToCheck,
pricelist,
true,
this.pricelistCount > 4000 ? 400 : 200,
Expand Down
Loading