Skip to content

Commit

Permalink
🔀Merge pull request #421 from TF2Autobot/show-amount-offered
Browse files Browse the repository at this point in the history
🎨 show amount offering/offered/taking/taken in overstocked/understocked review/trade summary
  • Loading branch information
idinium96 committed Mar 6, 2021
2 parents 4ea0561 + c526099 commit b2c6102
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
12 changes: 8 additions & 4 deletions src/classes/MyHandler/MyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,8 @@ export default class MyHandler extends Handler {
sku: sku,
buying: isBuying,
diff: diff,
amountCanTrade: amountCanTrade
amountCanTrade: amountCanTrade,
amountOffered: amount
});

this.bot.listings.checkBySKU(match.sku, null, which === 'their', true);
Expand Down Expand Up @@ -1120,7 +1121,8 @@ export default class MyHandler extends Handler {
sku: sku,
selling: !isBuying,
diff: diff,
amountCanTrade: amountCanTrade
amountCanTrade: amountCanTrade,
amountTaking: amount
});

this.bot.listings.checkBySKU(match.sku, null, which === 'their', true);
Expand Down Expand Up @@ -1289,7 +1291,8 @@ export default class MyHandler extends Handler {
sku: '5021;6',
buying: isBuying,
diff: diff,
amountCanTrade: amountCanTrade
amountCanTrade: amountCanTrade,
amountOffered: itemsDict['their']['5021;6']
});

log.debug('OVERSTOCKED', {
Expand All @@ -1312,7 +1315,8 @@ export default class MyHandler extends Handler {
sku: '5021;6',
selling: !isBuying,
diff: diff,
amountCanTrade: amountCanTrade
amountCanTrade: amountCanTrade,
amountTaking: itemsDict['our']['5021;6']
});

this.bot.listings.checkBySKU('5021;6', null, false, true);
Expand Down
4 changes: 2 additions & 2 deletions src/classes/MyHandler/offer/accepted/processAccepted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function processAccepted(
isWebhookEnabled
? `_${bot.schema.getName(SKU.fromString(el.sku), false)}_`
: bot.schema.getName(SKU.fromString(el.sku), false)
} (amount can buy was ${el.amountCanTrade})`
} (amount can buy was ${el.amountCanTrade}, offered ${el.amountOffered})`
);
});
}
Expand All @@ -81,7 +81,7 @@ export default function processAccepted(
isWebhookEnabled
? `_${bot.schema.getName(SKU.fromString(el.sku), false)}_`
: bot.schema.getName(SKU.fromString(el.sku), false)
} (amount can sell was ${el.amountCanTrade})`
} (amount can sell was ${el.amountCanTrade}, taken ${el.amountTaking})`
);
});
}
Expand Down
8 changes: 6 additions & 2 deletions src/classes/MyHandler/offer/review/reasons/overstocked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ export default function overstocked(meta: Meta, bot: Bot): { note: string; name:
(meta.reasons.filter(el => el.reason.includes('🟦_OVERSTOCKED')) as Overstocked[]).forEach(el => {
if (opt.enable && opt.url !== '') {
overstockedForOur.push(
`_${bot.schema.getName(SKU.fromString(el.sku), false)}_ (can only buy ${el.amountCanTrade})`
`_${bot.schema.getName(SKU.fromString(el.sku), false)}_ (can only buy ${el.amountCanTrade}, offering ${
el.amountOffered
})`
);
} else {
overstockedForOur.push(
`${bot.schema.getName(SKU.fromString(el.sku), false)} (can only buy ${el.amountCanTrade})`
`${bot.schema.getName(SKU.fromString(el.sku), false)} (can only buy ${el.amountCanTrade}, offering ${
el.amountOffered
})`
);
}
overstockedForTheir.push(`${el.amountCanTrade} - ${bot.schema.getName(SKU.fromString(el.sku), false)}`);
Expand Down
8 changes: 6 additions & 2 deletions src/classes/MyHandler/offer/review/reasons/understocked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ export default function understocked(meta: Meta, bot: Bot): { note: string; name
(meta.reasons.filter(el => el.reason.includes('🟩_UNDERSTOCKED')) as Understocked[]).forEach(el => {
if (opt.enable && opt.url !== '') {
understockedForOur.push(
`_${bot.schema.getName(SKU.fromString(el.sku), false)}_ (can only sell ${el.amountCanTrade})`
`_${bot.schema.getName(SKU.fromString(el.sku), false)}_ (can only sell ${el.amountCanTrade}, taking ${
el.amountTaking
})`
);
} else {
understockedForOur.push(
`${bot.schema.getName(SKU.fromString(el.sku), false)} (can only sell ${el.amountCanTrade})`
`${bot.schema.getName(SKU.fromString(el.sku), false)} (can only sell ${el.amountCanTrade}, taking ${
el.amountTaking
})`
);
}
understockedForTheir.push(`${el.amountCanTrade} - ${bot.schema.getName(SKU.fromString(el.sku), false)}`);
Expand Down
2 changes: 2 additions & 0 deletions src/types/modules/@tf2autobot/tradeoffer-manager/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ declare module '@tf2autobot/tradeoffer-manager' {
buying: boolean;
diff: number;
amountCanTrade: number;
amountOffered: number;
}

export interface Understocked {
Expand All @@ -168,6 +169,7 @@ declare module '@tf2autobot/tradeoffer-manager' {
selling: boolean;
diff: number;
amountCanTrade: number;
amountTaking: number;
}

export interface DisabledItems {
Expand Down

0 comments on commit b2c6102

Please sign in to comment.