restricting new accounts to join or chat , account verification

This commit is contained in:
imayushsaini 2021-11-12 09:54:30 +05:30
parent dbe040a017
commit ce8183fd1f
23 changed files with 387 additions and 70 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -180,32 +180,31 @@
"bobmsquadhttpapi.HeySmoothy": {
"enabled": true
},
"importcustomcharacters.HeySmoothy": {
"enabled": true
}
},
"Port": 43210,
"Region Pings": {
"af-south-1": 327.18719999684254,
"ap-northeast-1": 151.53256140253507,
"ap-northeast-2": 152.49581260020204,
"ap-south-1": 47.787964598392136,
"ap-southeast-1": 89.0280472006998,
"ap-southeast-2": 175.50485959724756,
"ca-central-1": 240.4051362004975,
"eu-central-1": 149.9327108011057,
"eu-north-1": 173.90180000074906,
"eu-south-1": 156.9542148008477,
"eu-west-1": 178.51566700279363,
"eu-west-2": 161.71073320005962,
"eu-west-3": 162.05250060249818,
"me-south-1": 75.2198157979874,
"sa-east-1": 338.33079999749316,
"us-east-1": 248.01100000331644,
"us-east-2": 245.55200000031618,
"us-west-1": 261.6065999973216,
"us-west-2": 289.57720000471454
"af-south-1": 310.4873846001974,
"ap-northeast-1": 160.38350760028334,
"ap-northeast-2": 151.66848159996152,
"ap-south-1": 42.999430000327266,
"ap-southeast-1": 85.54219160010689,
"ap-southeast-2": 177.78437579947786,
"ca-central-1": 235.28795540041756,
"eu-central-1": 157.53134780030814,
"eu-north-1": 178.57811620054417,
"eu-south-1": 148.7286152001907,
"eu-west-1": 174.8420205996481,
"eu-west-2": 164.6547662004923,
"eu-west-3": 163.58985420019962,
"me-south-1": 74.75811940041604,
"sa-east-1": 346.15190239976437,
"us-east-1": 225.80962139903568,
"us-east-2": 244.04948919953313,
"us-west-1": 267.5949521999537,
"us-west-2": 280.6645522005638
},
"Show Tutorial": false,
"Signed In Last Session": false,
@ -452,7 +451,7 @@
}
]
},
"launchCount": 202,
"launchCount": 252,
"lc14173": 1,
"lc14292": 1
}

View file

@ -1,7 +1,127 @@
{
"Achievements": {
"Boom Goes the Dynamite": {
"Complete": false
},
"Boxer": {
"Complete": false
},
"Dual Wielding": {
"Complete": false
},
"Flawless Victory": {
"Complete": false
},
"Free Loader": {
"Complete": false
},
"Gold Miner": {
"Complete": false
},
"Got the Moves": {
"Complete": false
},
"In Control": {
"Complete": false
},
"Last Stand God": {
"Complete": false
},
"Last Stand Master": {
"Complete": false
},
"Last Stand Wizard": {
"Complete": false
},
"Mine Games": {
"Complete": false
},
"Off You Go Then": {
"Complete": false
},
"Onslaught God": {
"Complete": false
},
"Onslaught Master": {
"Complete": false
},
"Onslaught Training Victory": {
"Complete": false
},
"Onslaught Wizard": {
"Complete": false
},
"Precision Bombing": {
"Complete": false
},
"Pro Boxer": {
"Complete": false
},
"Pro Football Shutout": {
"Complete": false
},
"Pro Football Victory": {
"Complete": false
},
"Pro Onslaught Victory": {
"Complete": false
},
"Pro Runaround Victory": {
"Complete": false
},
"Rookie Football Shutout": {
"Complete": false
},
"Rookie Football Victory": {
"Complete": false
},
"Rookie Onslaught Victory": {
"Complete": false
},
"Runaround God": {
"Complete": false
},
"Runaround Master": {
"Complete": false
},
"Runaround Wizard": {
"Complete": false
},
"Sharing is Caring": {
"Complete": false
},
"Stayin' Alive": {
"Complete": false
},
"Super Mega Punch": {
"Complete": false
},
"Super Punch": {
"Complete": false
},
"TNT Terror": {
"Complete": false
},
"Team Player": {
"Complete": true
},
"The Great Wall": {
"Complete": false
},
"The Wall": {
"Complete": false
},
"Uber Football Shutout": {
"Complete": false
},
"Uber Football Victory": {
"Complete": false
},
"Uber Onslaught Victory": {
"Complete": false
},
"Uber Runaround Victory": {
"Complete": false
}
},
"Auto Account State": "Server",
@ -69,25 +189,25 @@
},
"Port": 43210,
"Region Pings": {
"af-south-1": 313.8089999993099,
"ap-northeast-1": 156.75180000107503,
"ap-northeast-2": 154.02499999618158,
"ap-south-1": 37.20841020118678,
"ap-southeast-1": 84.8912163998466,
"ap-southeast-2": 177.8273999952944,
"ca-central-1": 229.13120000157505,
"eu-central-1": 159.85509999882197,
"eu-north-1": 174.3445999964024,
"eu-south-1": 146.988317201467,
"eu-west-1": 185.86729999515228,
"eu-west-2": 160.16889999445993,
"eu-west-3": 160.48560000490397,
"me-south-1": 68.75965099866153,
"sa-east-1": 352.87809999863384,
"us-east-1": 237.88300000160234,
"us-east-2": 258.0398999998579,
"us-west-1": 273.01389999774983,
"us-west-2": 276.10180000192486
"af-south-1": 310.3448000001663,
"ap-northeast-1": 166.10779999973602,
"ap-northeast-2": 151.27690000008442,
"ap-south-1": 42.999430000327266,
"ap-southeast-1": 85.54219160010689,
"ap-southeast-2": 179.14919999930135,
"ca-central-1": 234.70910000105505,
"eu-central-1": 161.19810000054713,
"eu-north-1": 181.7263000011735,
"eu-south-1": 147.98619999965013,
"eu-west-1": 170.556499999293,
"eu-west-2": 166.20810000131314,
"eu-west-3": 168.4557999997196,
"me-south-1": 74.75811940041604,
"sa-east-1": 347.53679999994347,
"us-east-1": 226.50029999931576,
"us-east-2": 251.41959999928076,
"us-west-1": 267.6188999994338,
"us-west-2": 277.7994000007311
},
"Show Tutorial": false,
"Signed In Last Session": false,
@ -334,7 +454,7 @@
}
]
},
"launchCount": 202,
"launchCount": 252,
"lc14173": 1,
"lc14292": 1
}

View file

@ -5,8 +5,9 @@ from serverData import serverdata
from chatHandle.ChatCommands import Main
from tools import Logger
import ba, _ba
import setting
settings = setting.get_settings_data()
def filter_chat_message(msg, client_id):
@ -22,10 +23,17 @@ def filter_chat_message(msg, client_id):
if serverdata.clients[acid]["isMuted"]:
_ba.screenmessage("You are on mute", transient=True, clients=[client_id])
return None
elif serverdata.clients[acid]["accountAge"] < settings['minAgeToChatInHours']:
_ba.screenmessage("New accounts not allowed to chat here", transient=True, clients=[client_id])
return None
else:
return msg
else:
_ba.screenmessage("Fetching your account info , Wait a minute", transient=True, clients=[client_id])
return None
return msg
"""
if chatfilter.isAbuse(msg):

View file

@ -29,7 +29,7 @@ def playerspaz_init(player):
def bootstraping():
print("starting server configuration")
_ba.disconnect_client=new_disconnect
#_ba.disconnect_client=new_disconnect
settings = setting.get_settings_data()
_ba.set_server_device_name(settings["HostDeviceName"])
_ba.set_server_name(settings["HostName"])

View file

@ -1,6 +1,6 @@
# Released under the MIT License. See LICENSE for details.
import _ba, os, json
from serverData import serverdata
roles = {}
@ -31,7 +31,7 @@ def commit_profiles(profiles):
json.dump(profiles,f,indent=4)
def add_profile(id,display_string,currentname):
def add_profile(id,display_string,currentname,age):
f=open(data_path+"profiles.json","r")
profiles=json.load(f)
f.close()
@ -40,6 +40,7 @@ def add_profile(id,display_string,currentname):
"name":currentname,
"isBan":False,
"isMuted":False,
"accountAge":age,
"totaltimeplayer":0,
"lastseen":0}
@ -47,8 +48,14 @@ def add_profile(id,display_string,currentname):
f=open(data_path+"profiles.json","w")
json.dump(profiles,f,indent=4)
serverdata.clients[id]=profiles[id]
f.close()
def update_displayString(id,display_string):
profiles=get_profiles()
if id in profiles:
profiles[id]["display_string"]=display_string
commit_profiles(profiles)
def update_profile(id,display_string=None,allprofiles=[],name=None):

View file

@ -1,5 +1,5 @@
{
"pb-IF4TVWwZUQ==": {
"pb-IF4TVWwZUQ=9=": {
"display_string": "\ue030PC295588",
"profiles": [],
"name": "\ue030PC295588",
@ -7,5 +7,55 @@
"isMuted": false,
"totaltimeplayer": 0,
"lastseen": 0
},
"pb-IF4TVWwZUQ=d=": {
"display_string": [
"\ue030Android48444292",
"\ue030PC295588"
],
"profiles": [],
"name": "\ue030PC295588",
"isBan": false,
"isMuted": false,
"accountAge": 8231.662564509445,
"totaltimeplayer": 0,
"lastseen": 0
},
"pb-IF4TVWwZUQ==": {
"display_string": [
"\ue030Android48444292",
"\ue030PC295588"
],
"profiles": [],
"name": "\ue030PC295588",
"isBan": false,
"isMuted": false,
"accountAge": 8231.7627117525,
"totaltimeplayer": 0,
"lastseen": 0
},
"pb-IF4oUmwDFQ==": {
"display_string": [
"\ue030PC401824"
],
"profiles": [],
"name": "\ue030PC401824",
"isBan": false,
"isMuted": false,
"accountAge": 0.15915736722222223,
"totaltimeplayer": 0,
"lastseen": 0
},
"pb-IF4dUmwsIg==": {
"display_string": [
"\ue030PC401877"
],
"profiles": [],
"name": "\ue030PC401877",
"isBan": false,
"isMuted": false,
"accountAge": 0.01221103722222222,
"totaltimeplayer": 0,
"lastseen": 0
}
}

View file

@ -26,7 +26,8 @@
"HostName":"BCS",
"ShowKickVoteStarterName":true,
"KickVoteMsgType":"chat",
"minAgeToChatInHours":78,
"minAgeToJoinInHours":48,
"enabletags": true,
"enablehptag": true,
"enablerank": true,

View file

@ -18,9 +18,9 @@
"total_damage": 0.0,
"kills": 1,
"deaths": 73,
"games": 53,
"games": 54,
"kd": 0.013,
"avg_score": 11.509,
"avg_score": 11.296,
"aid": "pb-IF4TVWwZUQ=="
},
"pb-JiNJARBaXEFBVF9HFkNXXF1EF0ZaRlZE": {

View file

@ -47,7 +47,7 @@
<td>610</td>
<td>1</td>
<td>73</td>
<td>53</td>
<td>54</td>
</tr>
<tr>
<td>5</td>

View file

@ -6,6 +6,14 @@
from serverData import serverdata
from playersData import pdata
import _ba
import urllib.request
import json
import datetime
import time
import ba
from ba._general import Call
import threading
import setting
# class ServerChecker:
# def __init__():
@ -48,40 +56,164 @@ import _ba
# pdata.update_profile(serverdata.cachedclients[player])
settings = setting.get_settings_data()
def on_player_join(pbid):
player_data=pdata.get_info(pbid)
if player_data!=None:
if player_data["isBan"]:
device_strin=""
if player_data["isBan"] or player_data["accountAge"] < settings["minAgeToJoinInHours"]:
for ros in _ba.get_game_roster():
if ros['account_id']==pbid:
if not player_data["isBan"]:
_ba.screenmessage("New Accounts not allowed here , come back later",transient=True,clients=[ros['client_id']])
_ba.disconnect_client(ros['client_id'])
return
serverdata.clients[pbid]=player_data
else:
serverdata.clients[pbid]=player_data
verify_account(pbid,player_data)
else:
d_string=""
for ros in _ba.get_game_roster():
if ros['account_id']==pbid:
d_string=ros['display_string']
pdata.add_profile(pbid,d_string,d_string)
thread = FetchThread(
target=my_acc_age,
callback=save_age,
pb_id=pbid,
display_string=d_string
)
thread.start()
#pdata.add_profile(pbid,d_string,d_string)
def verify_account(pb_id,p_data):
d_string=""
for ros in _ba.get_game_roster():
if ros['account_id']==pb_id:
d_string=ros['display_string']
if d_string not in p_data['display_string']:
thread2 = FetchThread(
target=get_device_accounts,
callback=save_ids,
pb_id=pb_id,
display_string=d_string
)
thread2.start()
#============== IGNORE BLOW CODE , ELSE DIE =======================
def _make_request_safe(request, retries=2, raise_err=True):
try:
return request()
except:
if retries > 0:
time.sleep(1)
return _make_request_safe(request, retries=retries-1, raise_err=raise_err)
if raise_err:
raise
def get_account_age_in_hours(pb_id):
# thanks rikko
account_creation_url = "http://bombsquadgame.com/accountquery?id=" + pb_id
account_creation = _make_request_safe(lambda: urllib.request.urlopen(account_creation_url))
if account_creation is not None:
try:
account_creation = json.loads(account_creation.read())
except ValueError:
pass
else:
creation_time = account_creation["created"]
creation_time = map(str, creation_time)
creation_time = datetime.datetime.strptime("/".join(creation_time), "%Y/%m/%d/%H/%M/%S")
# Convert to IST
creation_time += datetime.timedelta(hours=5, minutes=30)
print(creation_time)
now = datetime.datetime.now()
delta = now - creation_time
delta_hours = delta.total_seconds() / (60 * 60)
return delta_hours
def get_device_accounts(pb_id):
url="http://bombsquadgame.com/bsAccountInfo?buildNumber=20258&accountID="+pb_id
data=_make_request_safe(lambda:urllib.request.urlopen(url))
if data is not None:
try:
accounts=json.loads(data.read())["accountDisplayStrings"]
except ValueError:
return ['???']
else:
return accounts
# ======= yes fucking threading code , dont touch ==============
class FetchThread(threading.Thread):
def __init__(self,target, callback=None,pb_id="ji",display_string="XXX"):
super(FetchThread, self).__init__(target=self.target_with_callback, args=(pb_id,display_string,))
self.callback = callback
self.method = target
def target_with_callback(self,pb_id,display_string):
data=self.method(pb_id)
if self.callback is not None:
self.callback(data,pb_id,display_string)
def my_acc_age(pb_id):
return get_account_age_in_hours(pb_id)
def save_age(age, pb_id,display_string):
pdata.add_profile(pb_id,display_string,display_string,age)
time.sleep(2)
thread2 = FetchThread(
target=get_device_accounts,
callback=save_ids,
pb_id=pb_id,
display_string=display_string
)
thread2.start()
if age < settings["minAgeToJoinInHours"]:
msg="New Accounts not allowed to play here , come back tmrw."
_ba.pushcall(Call(kick_by_pb_id,pb_id,msg),from_other_thread=True)
def save_ids(ids,pb_id,display_string):
pdata.update_displayString(pb_id,ids)
if display_string not in ids:
msg="Spoofed Id detected , Goodbye"
_ba.pushcall(Call(kick_by_pb_id,pb_id,msg),from_other_thread=True)
def kick_by_pb_id(pb_id,msg):
for ros in _ba.get_game_roster():
if ros['account_id']==pb_id:
_ba.screenmessage(msg, transient=True, clients=[ros['client_id']])
_ba.disconnect_client(ros['client_id'])
_ba.chatmessage("id spoofer kicked")

Binary file not shown.