Nicklason / tf2-automatic

A free and open source, fully automated TF2 trading bot, advertising on backpack.tf using prices from prices.tf
https://tf2automatic.com
MIT License
82 stars 41 forks source link

Fix: ensure that item is intended to be bought / sold by bot #472

Closed HilliamT closed 3 years ago

HilliamT commented 3 years ago

if (match !== null && (sku !== '5021;6' || !exchange.contains.items)) { .... } else if (sku === '5021;6' && exchange.contains.items) { { .... } if (match === null || match.intent === (buying ? 1 : 0)) { .... }

If a bot owner has populated their pricelist with buy and sell prices, then clearly match is non-null.

Even if the current intent of the bot to buy that item is set to the opposite of what is being performed (e.g a user sends a trade offer buying items off the bot when the bot is only buying), the first case will apply and perform item price calculating (previous lines 428 - 466) regardless, accepting if the user is able to guess the sell / buy price.

This also means that we don't 'throw' the INVALID_ITEMS error as item intent is checked after the first if statement case.

Commit is to swap the order of condition checks to make item buying/selling intent stricter.

Nicklason commented 3 years ago

I am pretty sure it is in that order to account for key banking. I think the key banking logic would break if it is the other way around.

HilliamT commented 3 years ago

Forgot about the differentiation (keys being used to buy an item vs key banking) - thanks! I've now just strengthened the first if statement to ensure that the item fetched from the pricelist has to be of the current intent that is being evaluated.

Key banking / trading should still fall through to the other cases as before.

idinium96 commented 3 years ago

this is broken image image

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.