From 6773c26bc87491ba1893701a882e133fc30247d2 Mon Sep 17 00:00:00 2001
From: dumbasPL <29180158+dumbasPL@users.noreply.github.com>
Date: Fri, 4 Jun 2021 13:54:31 +0200
Subject: [PATCH] fix overwatch bans showing expiration time

---
 helpers/util.js | 13 +++++++++++++
 main.js         |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/helpers/util.js b/helpers/util.js
index 6242e3d..5ef51ed 100644
--- a/helpers/util.js
+++ b/helpers/util.js
@@ -1,5 +1,6 @@
 module.exports = {
   penalty_reason_string,
+  penalty_reason_permanent,
   protoDecode,
   protoEncode
 }
@@ -29,6 +30,18 @@ function penalty_reason_string(id) {
   }
 }
 
+function penalty_reason_permanent(id) {
+  switch (id)
+  {
+  case 8: 
+  case 14:
+  case 10:
+    return true;
+  default: 
+    return false;
+  }
+}
+
 function protoDecode(proto, obj) {
   return proto.toObject(proto.decode(obj), { defaults: true });
 }
diff --git a/main.js b/main.js
index 3dbcc57..cba62ba 100644
--- a/main.js
+++ b/main.js
@@ -7,7 +7,7 @@ var User = require('steam-user');
 const fs = require('fs');
 const util = require('util');
 const {EOL} = require('os');
-const { penalty_reason_string, protoDecode, protoEncode } = require('./helpers/util.js');
+const { penalty_reason_string, protoDecode, protoEncode, penalty_reason_permanent } = require('./helpers/util.js');
 const Protos = require('./helpers/protos.js')([{
     name: 'csgo',
     protos: [
@@ -361,7 +361,7 @@ function check_account(username, pass) {
                             currently_checking = currently_checking.filter(x => x !== username);
                             // console.log(util.inspect(msg, false, null));
                             data.penalty_reason = steamClient.limitations.communityBanned ? 'Community ban' : msg.penalty_reason > 0 ? penalty_reason_string(msg.penalty_reason) : msg.vac_banned ? 'VAC' : 0;
-                            data.penalty_seconds = msg.vac_banned || steamClient.limitations.communityBanned ? -1 : msg.penalty_seconds > 0 ? (Math.floor(Date.now() / 1000) + msg.penalty_seconds) : 0;
+                            data.penalty_seconds = msg.vac_banned || steamClient.limitations.communityBanned || penalty_reason_permanent(msg.penalty_reason) ? -1 : msg.penalty_seconds > 0 ? (Math.floor(Date.now() / 1000) + msg.penalty_seconds) : 0;
                             data.wins = msg.vac_banned ? -1 : attempts < 5 ? msg.ranking.wins : 0;
                             data.rank = msg.vac_banned ? -1 : attempts < 5 ? msg.ranking.rank_id : 0;
                             data.name = steamClient.accountInfo.name;