Skip to content

Commit

Permalink
add an option to disable accepting friend request
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Jul 15, 2020
1 parent b0c7495 commit c4b3e85
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/classes/Friends.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { UnknownDictionary } from '../types/common';
import Bot from './Bot';

import request from '@nicklason/request-retry';
import MyHandler from './MyHandler';

export = class Friends {
private readonly bot: Bot;
Expand Down Expand Up @@ -85,10 +86,13 @@ export = class Friends {
const result = body.response;
const level = result.player_level;

const friendToKeep = (this.bot.handler as MyHandler).getFriendToKeep();
const disableAddFriends = process.env.DISABLE_ADD_FRIENDS === 'true';

const base = 250;
const multiplier = 5;

this.maxFriends = base + level * multiplier;
this.maxFriends = disableAddFriends ? friendToKeep : base + level * multiplier;

resolve(this.maxFriends);
});
Expand Down
4 changes: 4 additions & 0 deletions src/classes/MyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ export = class MyHandler extends Handler {
}, 1000);
}

getFriendToKeep(): number {
return this.friendsToKeep.length;
}

hasDupeCheckEnabled(): boolean {
return this.dupeCheckEnabled;
}
Expand Down
1 change: 1 addition & 0 deletions template.ecosystem.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"DISABLE_MESSAGES": false,
"DISABLE_SOMETHING_WRONG_ALERT": false,
"DISABLE_CRAFTWEAPON_AS_CURRENCY": false,
"DISABLE_ADD_FRIENDS": false,

"TRADES_MADE_STARTER_VALUE": 0,
"LAST_TOTAL_TRADES": 0,
Expand Down
1 change: 1 addition & 0 deletions template.env
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ DISABLE_CRAFTING_WEAPONS=false
DISABLE_MESSAGES=false
DISABLE_SOMETHING_WRONG_ALERT=false
DISABLE_CRAFTWEAPON_AS_CURRENCY=false
DISABLE_ADD_FRIENDS=false

TRADES_MADE_STARTER_VALUE=0
LAST_TOTAL_TRADES=0
Expand Down

0 comments on commit c4b3e85

Please sign in to comment.