Skip to content

Commit

Permalink
🔀Merge pull request #336 from TF2Autobot/development
Browse files Browse the repository at this point in the history
#336 for v3.3.0

## Added
- ✨ option to filter buy order that the bot can't afford to buy. Read: #332 - @idinium96
- ✨🎨 An option to replace keys & pure metals with emoji (Discord Webhook) - @idinium96
    - added `showPureInEmoji` under `tradeSummary` option parent property.
    - this option is `false` by default. Set it to `true` (by sending `!config tradeSummary.showPureInEmoji=true` to your bot) if you want to enable this feature.
    - screenshot: 
![image](https://user-images.githubusercontent.com/47635037/107742639-6554dd00-6d4a-11eb-8a64-fa9d81b2d8cc.png)
![image](https://user-images.githubusercontent.com/47635037/107866197-0063c900-6ea9-11eb-8996-42ea98142637.png)

- ✨ add missing `isFull` attribute (for duel/noise) - @idinium96
- ✨🔨 add missing highValue meta, only define if true, and 🎨🔨 simplified - @idinium96
- ✨ add `!offerinfo` command - @idinium96

## Changed/Updated
- 💡 refactor: always show `group` on item add/update (#324) - @Bonfire
- 🔨 refactor: Commands, from functions to sub-classes - @idinium96
- 🔨 refactor: take out `meta` from `action` - @idinium96
    - 🔥 remove `notify` & `meta` from polldata on successful accepted, declined, cancelled, and invalidItems trades (reduce polldata file size)
- ⬆ increase setTimeout retry time from 3 seconds to 30 seconds - @idinium96
- ⬆ increase pollInterval from 1 second to 30 seconds (use less CPU) - @idinium96
- 🎨 bring back square bracket if `showChanges` is enabled - @idinium96
- ⭕ ignore trades from admins to count in profit (#299) - @idinium96
- 🔔 notify the owner if there's an error while trying to accept mobile confirmation (will not perform automatic retry here) - @idinium96
    - if the error is `HTTP error 502`, there is a high chance that the offer is still active, otherwise, it's most likely canceled (idk how to make it not to cancel the trade).
- 🔄 update `options` schema - @idinium96
    - get rid of `allOf` - prevent the owner from putting invalid option property.
    - **those that might already add some foreign properties (such as `enabled` for an actual `enable` key), your bot might not be able to start if you update to this version. Be sure to check your bot logs.**

## Fixed
- 🔄 update `bptf-listings-2` library
    - 🐛 fix not detect Festivized items ([`bptf-listings-2: cc136f0`](idinium96/node-bptf-listings-2@cc136f0)) - @idinium96
    - 🐛 fix and convert stock weapon defindex into upgradeable weapon defindex (`bptf-listings-2:` [`387e0a3`](idinium96/node-bptf-listings-2@387e0a3), [`b029d59`](idinium96/node-bptf-listings-2@b029d59)) - @idinium96
    - 🐛 fix defindex for Killstreak (Basic) Kit ([`bptf-listings-2: e2f0152`](idinium96/node-bptf-listings-2@e2f0152)) - @idinium96
    - 🐛 fix exclusive promo items defindex ([`bptf-listings-2: 3076fa4`](idinium96/node-bptf-listings-2@3076fa4))  - @idinium96
    - 🐛 fix wrong wear value ([`bptf-listings-2: 953f6c3`](idinium96/node-bptf-listings-2@953f6c3)) - @idinium96
- 🐛 fix `!check` command always getting error - @idinium96
  • Loading branch information
idinium96 committed Feb 14, 2021
2 parents 8bd596f + 97611d6 commit 2d3822c
Show file tree
Hide file tree
Showing 63 changed files with 5,010 additions and 4,252 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ assignees: ''

<!--
Your issue may already be reported!
Please search on the [issue tracker](https://github.com/idinium96/tf2autobot/search?type=Issues) before creating one.
Please search on the [issue tracker](https://github.com/TF2Autobot/tf2autobot/search?type=Issues) before creating one.
-->

**Describe the bug**
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ assignees: ''

<!--
Your feature may already be requested!
Please search on the [issue tracker](https://github.com/idinium96/tf2autobot/search?type=Issues) before creating one.
Please search on the [issue tracker](https://github.com/TF2Autobot/tf2autobot/search?type=Issues) before creating one.
-->

**Is your feature request related to a problem? Please describe.**
Expand Down
6 changes: 3 additions & 3 deletions .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Before creating bug reports, please check [this list](#before-submitting-a-bug-r

#### How to submit a bug report

Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you have determined that it is a bug, create an issue and provide following information by filling in [the template](https://github.com/idinium96/tf2autobot/blob/master/.github/ISSUE_TEMPLATE/bug_report.md).
Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you have determined that it is a bug, create an issue and provide following information by filling in [the template](https://github.com/TF2Autobot/tf2autobot/blob/master/.github/ISSUE_TEMPLATE/bug_report.md).

#### Before submitting a bug report

Expand Down Expand Up @@ -70,7 +70,7 @@ Just like [bug reports](#reporting-bugs), feature requests are tracked as [GitHu

When contributing to this repository, please first discuss the change you wish to make via issue, or any other method with the owners or contributors of this repository before making a change.

All pull requests should be made to [the development branch](https://github.com/idinium96/tf2autobot/tree/development). When a new release is made the development branch will be merged with the master branch.
All pull requests should be made to [the development branch](https://github.com/TF2Autobot/tf2autobot/tree/development). When a new release is made the development branch will be merged with the master branch.

Please make sure that you follow the [style guides](#styleguides).

Expand Down Expand Up @@ -99,7 +99,7 @@ The body of the commit message should be one or more paragraphs, explaining
things in more detail. Please word-wrap to keep columns to 72 characters or
less.
Fixes: https://github.com/Nicklason/tf2autobot/issues/1337
Fixes: https://github.com/TF2Autobot/tf2autobot/issues/1337
Refs: https://eslint.org/docs/rules/space-in-parens.html
```

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 IdiNium/Nicklas Marc Pedersen
Copyright (c) 2020 - 2021 IdiNium/Nicklas Marc Pedersen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
336 changes: 214 additions & 122 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/idinium96/tf2autobot.git"
"url": "git+https://github.com/TF2Autobot/tf2autobot.git"
},
"author": "IdiNium/Nicklas Marc Pedersen",
"license": "MIT",
"bugs": {
"url": "https://github.com/idinium96/tf2autobot/issues"
"url": "https://github.com/TF2Autobot/tf2autobot/issues"
},
"homepage": "https://github.com/idinium96/tf2autobot#readme",
"homepage": "https://github.com/TF2Autobot/tf2autobot#readme",
"dependencies": {
"async": "^3.2.0",
"bluebird": "^3.7.2",
"bluebird-global": "^1.0.1",
"bptf-listings-2": "^1.1.6",
"bptf-listings-2": "^1.1.11",
"bptf-login-2": "^1.0.0",
"callback-queue": "^3.0.0",
"change-case": "^4.1.2",
Expand All @@ -37,7 +37,7 @@
"dot-prop": "^6.0.1",
"dotenv": "^8.2.0",
"eslint-config-prettier": "^7.2.0",
"graceful-fs": "^4.2.5",
"graceful-fs": "^4.2.6",
"isobject": "^4.0.0",
"js-levenshtein": "^1.1.6",
"jsonlint": "^1.6.3",
Expand All @@ -58,8 +58,8 @@
"steamid": "^1.1.3",
"tf2": "^3.0.2",
"tf2-currencies": "^1.2.4",
"tf2-schema-2": "^1.2.3",
"tf2-sku-2": "^1.0.1",
"tf2-schema-2": "^1.2.4",
"tf2-sku-2": "^1.0.3",
"url": "^0.11.0",
"valid-url": "^1.0.9",
"websocket-extensions": "^0.1.4",
Expand All @@ -68,12 +68,12 @@
"xmlhttprequest-ts": "^1.0.1"
},
"devDependencies": {
"@babel/preset-typescript": "^7.12.13",
"@babel/preset-typescript": "^7.12.16",
"@types/async": "^3.2.5",
"@types/bluebird-global": "^3.5.12",
"@types/cheerio": "^0.22.23",
"@types/cheerio": "^0.22.24",
"@types/death": "^1.1.1",
"@types/graceful-fs": "^4.1.4",
"@types/graceful-fs": "^4.1.5",
"@types/jest": "^26.0.20",
"@types/pluralize": "0.0.29",
"@types/request": "^2.48.5",
Expand All @@ -83,16 +83,16 @@
"@types/valid-url": "^1.0.3",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"eslint": "^7.19.0",
"eslint": "^7.20.0",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-tsdoc": "^0.2.11",
"jest": "^26.6.3",
"nodemon": "^2.0.7",
"prettier": "^2.2.1",
"socket.io-mock": "^1.3.1",
"ts-jest": "^26.5.0",
"typescript": "^4.1.3"
"ts-jest": "^26.5.1",
"typescript": "^4.1.5"
},
"private": true,
"_moduleAliases": {
Expand Down
6 changes: 4 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ init(paths, options);

if (process.env.pm_id === undefined) {
log.warn(
"You are not running the bot with PM2! If the bot crashes it won't start again. Get a VPS and run your bot with PM2: https://github.com/idinium96/tf2autobot/wiki/Getting-a-VPS"
"You are not running the bot with PM2! If the bot crashes it won't start again." +
' Get a VPS and run your bot with PM2: https://github.com/TF2Autobot/tf2autobot/wiki/Getting-a-VPS'
);
}

Expand Down Expand Up @@ -104,7 +105,8 @@ ON_DEATH({ uncaughtException: true })((signalOrErr, origin) => {

if (botReady) {
log.error(
'Refer to Wiki here: https://github.com/idinium96/tf2autobot/wiki/Common-Errors OR Create an issue here: https://github.com/idinium96/tf2autobot/issues/new?assignees=&labels=bug&template=bug_report.md&title='
'Refer to Wiki here: https://github.com/TF2Autobot/tf2autobot/wiki/Common-Errors OR ' +
'Create an issue here: https://github.com/idinium96/TF2Autobot/issues/new?assignees=&labels=bug&template=bug_report.md&title='
);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ export default class Bot {
log.debug('Setting Steam API Key to schema');
this.botManager.setAPIKeyForSchema = this.manager.apiKey;

this.manager.pollInterval = 1000;
this.manager.pollInterval = 30 * 1000;
this.setReady = true;
this.handler.onReady();
this.manager.doPoll();
Expand Down
24 changes: 13 additions & 11 deletions src/classes/Carts/AdminCart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,32 @@ export default class AdminCart extends Cart {

let amount = this.getOurCount(sku);
const ourAssetids = ourInventory.findBySKU(sku, true);
const ourAssetidsCount = ourAssetids.length;

if (amount > ourAssetids.length) {
amount = ourAssetids.length;
if (amount > ourAssetidsCount) {
amount = ourAssetidsCount;
// Remove the item from the cart
this.removeOurItem(sku);

if (ourAssetids.length === 0) {
if (ourAssetidsCount === 0) {
alteredMessages.push(
"I don't have any " + pluralize(this.bot.schema.getName(SKU.fromString(sku), false))
);
} else {
alteredMessages.push(
'I only have ' +
pluralize(this.bot.schema.getName(SKU.fromString(sku), false), ourAssetids.length, true)
pluralize(this.bot.schema.getName(SKU.fromString(sku), false), ourAssetidsCount, true)
);

// Add the max amount to the offer
this.addOurItem(sku, ourAssetids.length);
this.addOurItem(sku, ourAssetidsCount);
}
}

let missing = amount;
let isSkipped = false;

for (let i = 0; i < ourAssetids.length; i++) {
for (let i = 0; i < ourAssetidsCount; i++) {
if (
this.bot.options.miscSettings.skipItemsInTrade.enable &&
this.bot.trades.isInTrade(ourAssetids[i])
Expand Down Expand Up @@ -132,13 +133,14 @@ export default class AdminCart extends Cart {

let amount = this.getTheirCount(sku);
const theirAssetids = theirInventory.findBySKU(sku, true);
const theirAssetidsCount = theirAssetids.length;

if (amount > theirAssetids.length) {
amount = theirAssetids.length;
if (amount > theirAssetidsCount) {
amount = theirAssetidsCount;
// Remove the item from the cart
this.removeTheirItem(sku);

if (theirAssetids.length === 0) {
if (theirAssetidsCount === 0) {
alteredMessages.push(
"you don't have any " + pluralize(this.bot.schema.getName(SKU.fromString(sku), false))
);
Expand All @@ -147,15 +149,15 @@ export default class AdminCart extends Cart {
'you only have ' +
pluralize(
this.bot.schema.getName(SKU.fromString(sku), false),
theirAssetids.length,
theirAssetidsCount,
true
)
);

// Add the max amount to the offer substract current added amount
this.addTheirItem(
sku,
this.their[sku] ? theirAssetids.length - this.their[sku] : theirAssetids.length
this.their[sku] ? theirAssetidsCount - this.their[sku] : theirAssetidsCount
);
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/classes/Carts/Cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,28 +213,28 @@ export default abstract class Cart {

summarize(isDonating: boolean, isBuyingPremium: boolean): string {
const ourSummary = this.summarizeOur();
const ourSummaryCount = ourSummary.length;

let ourSummaryString: string;

if (ourSummary.length > 1) {
if (ourSummaryCount > 1) {
ourSummaryString =
ourSummary.slice(0, ourSummary.length - 1).join(', ') + ' and ' + ourSummary[ourSummary.length - 1];
} else if (ourSummary.length === 0) {
ourSummary.slice(0, ourSummaryCount - 1).join(', ') + ' and ' + ourSummary[ourSummaryCount - 1];
} else if (ourSummaryCount === 0) {
ourSummaryString = 'nothing';
} else {
ourSummaryString = ourSummary.join(', ');
}

const theirSummary = this.summarizeTheir();
const theirSummaryCount = theirSummary.length;

let theirSummaryString: string;

if (theirSummary.length > 1) {
if (theirSummaryCount > 1) {
theirSummaryString =
theirSummary.slice(0, theirSummary.length - 1).join(', ') +
' and ' +
theirSummary[theirSummary.length - 1];
} else if (theirSummary.length === 0) {
theirSummary.slice(0, theirSummaryCount - 1).join(', ') + ' and ' + theirSummary[theirSummaryCount - 1];
} else if (theirSummaryCount === 0) {
theirSummaryString = 'nothing';
} else {
theirSummaryString = theirSummary.join(', ');
Expand Down
13 changes: 7 additions & 6 deletions src/classes/Carts/DonateCart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,32 @@ export default class DonateCart extends Cart {

let amount = this.getOurCount(sku);
const ourAssetids = ourInventory.findBySKU(sku, true);
const ourAssetidsCount = ourAssetids.length;

if (amount > ourAssetids.length) {
amount = ourAssetids.length;
if (amount > ourAssetidsCount) {
amount = ourAssetidsCount;
// Remove the item from the cart
this.removeOurItem(sku);

if (ourAssetids.length === 0) {
if (ourAssetidsCount === 0) {
alteredMessages.push(
"I don't have any " + pluralize(this.bot.schema.getName(SKU.fromString(sku), false))
);
} else {
alteredMessages.push(
'I only have ' +
pluralize(this.bot.schema.getName(SKU.fromString(sku), false), ourAssetids.length, true)
pluralize(this.bot.schema.getName(SKU.fromString(sku), false), ourAssetidsCount, true)
);

// Add the max amount to the offer
this.addOurItem(sku, ourAssetids.length);
this.addOurItem(sku, ourAssetidsCount);
}
}

let missing = amount;
let isSkipped = false;

for (let i = 0; i < ourAssetids.length; i++) {
for (let i = 0; i < ourAssetidsCount; i++) {
if (
this.bot.options.miscSettings.skipItemsInTrade.enable &&
this.bot.trades.isInTrade(ourAssetids[i])
Expand Down
13 changes: 7 additions & 6 deletions src/classes/Carts/PremiumCart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,32 @@ export default class PremiumCart extends Cart {

let amount = this.getOurCount(sku);
const ourAssetids = ourInventory.findBySKU(sku, true);
const ourAssetidsCount = ourAssetids.length;

if (amount > ourAssetids.length) {
amount = ourAssetids.length;
if (amount > ourAssetidsCount) {
amount = ourAssetidsCount;
// Remove the item from the cart
this.removeOurItem(sku);

if (ourAssetids.length === 0) {
if (ourAssetidsCount === 0) {
alteredMessages.push(
"I don't have any " + pluralize(this.bot.schema.getName(SKU.fromString(sku), false))
);
} else {
alteredMessages.push(
'I only have ' +
pluralize(this.bot.schema.getName(SKU.fromString(sku), false), ourAssetids.length, true)
pluralize(this.bot.schema.getName(SKU.fromString(sku), false), ourAssetidsCount, true)
);

// Add the max amount to the offer
this.addOurItem(sku, ourAssetids.length);
this.addOurItem(sku, ourAssetidsCount);
}
}

let missing = amount;
let isSkipped = false;

for (let i = 0; i < ourAssetids.length; i++) {
for (let i = 0; i < ourAssetidsCount; i++) {
if (
this.bot.options.miscSettings.skipItemsInTrade.enable &&
this.bot.trades.isInTrade(ourAssetids[i])
Expand Down
Loading

0 comments on commit 2d3822c

Please sign in to comment.