From c4b3e8554f8b19ea45a59ead1741941da0da1876 Mon Sep 17 00:00:00 2001 From: idinium96 Date: Wed, 15 Jul 2020 15:21:02 +0800 Subject: [PATCH] add an option to disable accepting friend request --- src/classes/Friends.ts | 6 +++++- src/classes/MyHandler.ts | 4 ++++ template.ecosystem.json | 1 + template.env | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/classes/Friends.ts b/src/classes/Friends.ts index 401f4acf6..ff1703ede 100644 --- a/src/classes/Friends.ts +++ b/src/classes/Friends.ts @@ -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; @@ -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); }); diff --git a/src/classes/MyHandler.ts b/src/classes/MyHandler.ts index 06defb851..31d9f3ff0 100644 --- a/src/classes/MyHandler.ts +++ b/src/classes/MyHandler.ts @@ -183,6 +183,10 @@ export = class MyHandler extends Handler { }, 1000); } + getFriendToKeep(): number { + return this.friendsToKeep.length; + } + hasDupeCheckEnabled(): boolean { return this.dupeCheckEnabled; } diff --git a/template.ecosystem.json b/template.ecosystem.json index 628b6ad23..df5ca2097 100644 --- a/template.ecosystem.json +++ b/template.ecosystem.json @@ -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, diff --git a/template.env b/template.env index 722aa6f77..fa6a90a05 100644 --- a/template.env +++ b/template.env @@ -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