This commit is contained in:
FireFighter1027 2021-05-03 16:09:47 +05:30
commit 44a934b120
12 changed files with 78 additions and 134 deletions

View file

@ -307,7 +307,7 @@ def party_invite_revoke(invite_id: str) -> None:
_ba.containerwidget(edit=win.get_root_widget(), _ba.containerwidget(edit=win.get_root_widget(),
transition='out_right') transition='out_right')
import privateserver as pvt
import custom_hooks as chooks import custom_hooks as chooks
def filter_chat_message(msg: str, client_id: int) -> Optional[str]: def filter_chat_message(msg: str, client_id: int) -> Optional[str]:
"""Intercept/filter chat messages. """Intercept/filter chat messages.
@ -317,7 +317,7 @@ def filter_chat_message(msg: str, client_id: int) -> Optional[str]:
Should filter and return the string to be displayed, or return None Should filter and return the string to be displayed, or return None
to ignore the message. to ignore the message.
""" """
pvt.handlechat(msg,client_id)
return chooks.filter_chat_message(msg,client_id) return chooks.filter_chat_message(msg,client_id)

View file

@ -206,8 +206,8 @@ class Session:
This should return True or False to accept/reject. This should return True or False to accept/reject.
""" """
import privateserver as pvt from tools import whitelist
pvt.handlerequest(player) whitelist.handle_player_request(player)
# Limit player counts *unless* we're in a stress test. # Limit player counts *unless* we're in a stress test.
if _ba.app.stress_test_reset_timer is None: if _ba.app.stress_test_reset_timer is None:

View file

@ -40,7 +40,10 @@ def check_permissions(accountid, command):
roles = pdata.get_roles() roles = pdata.get_roles()
for role in roles: for role in roles:
if accountid in roles[role]["ids"] and command in roles[role]["commands"]: if accountid in roles[role]["ids"] and "ALL" in roles[role]["commands"]:
return True
elif accountid in roles[role]["ids"] and command in roles[role]["commands"]:
return True return True
return False return False

View file

@ -57,7 +57,7 @@ def ExcelCommand(command, arguments, clientid, accountid):
rotate_camera() rotate_camera()
elif command == 'createrole': elif command == 'createrole':
create_role_call(arguments) create_role(arguments)
elif command == 'addrole': elif command == 'addrole':
add_role_to_player(arguments) add_role_to_player(arguments)
@ -72,7 +72,7 @@ def ExcelCommand(command, arguments, clientid, accountid):
remove_command_to_role(arguments) remove_command_to_role(arguments)
elif command == 'changetag': elif command == 'changetag':
change_role_tag_call(arguments) change_role_tag(arguments)
elif command in ['add', 'whitelist']: elif command in ['add', 'whitelist']:
whitelst_it(accountid, arguments) whitelst_it(accountid, arguments)
@ -280,15 +280,20 @@ def whitelst_it(accountid : str, arguments):
settings = setting.get_settings_data() settings = setting.get_settings_data()
if arguments[0] == 'on': if arguments[0] == 'on':
settings["white_list"]["whitelist_on"] = True if settings["white_list"]["whitelist_on"]:
setting.commit(settings) _ba.chatmessage("Already on")
cmsg("whitelist on") else:
settings["white_list"]["whitelist_on"] = True
setting.commit(settings)
_ba.chatmessage("whitelist on")
from tools import whitelist
whitelist.Whitelist()
return return
elif arguments[0] == 'off': elif arguments[0] == 'off':
settings["white_list"]["whitelist_on"] = False settings["white_list"]["whitelist_on"] = False
setting.commit(settings) setting.commit(settings)
cmsg("whitelist off") _ba.chatmessage("whitelist off")
return return
else: else:
@ -297,7 +302,7 @@ def whitelst_it(accountid : str, arguments):
for i in rost: for i in rost:
if i['client_id'] == int(arguments[0]): if i['client_id'] == int(arguments[0]):
add_to_white_list(i['account_id'], i['display_string']) add_to_white_list(i['account_id'], i['display_string'])
cmsg(str(i['display_string'])+" whitelisted") _ba.chatmessage(str(i['display_string'])+" whitelisted")
add_commit_to_logs(accountid+" added "+i['account_id']) add_commit_to_logs(accountid+" added "+i['account_id'])
@ -311,12 +316,12 @@ def spectators(arguments):
if arguments[0] == 'on': if arguments[0] == 'on':
settings["white_list"]["spectators"] = True settings["white_list"]["spectators"] = True
setting.commit(settings) setting.commit(settings)
cmsg("spectators on") _ba.chatmessage("spectators on")
elif arguments[0] == 'off': elif arguments[0] == 'off':
settings["white_list"]["spectators"] = False settings["white_list"]["spectators"] = False
setting.commit(settings) setting.commit(settings)
cmsg("spectators off") _ba.chatmessage("spectators off")
@ -325,8 +330,8 @@ def change_lobby_check_time(arguments):
try: try:
argument = int(arguments[0]) argument = int(arguments[0])
except: except:
cmsg("must type numbe to change lobby check time") _ba.chatmessage("must type numbe to change lobby check time")
settings = setting.get_settings_data() settings = setting.get_settings_data()
settings["white_list"]["lobbychecktime"] = argument settings["white_list"]["lobbychecktime"] = argument
setting.commit(settings) setting.commit(settings)
cmsg(f"lobby check time is {arg} now") _ba.chatmessage(f"lobby check time is {arg} now")

View file

@ -1,11 +1,13 @@
from chatHandle import handlechat from chatHandle import handlechat
def filter_chat_message(msg, client_id): def filter_chat_message(msg, client_id):
return HandleChat.filter_chat_message(msg, client_id) return handlechat.filter_chat_message(msg, client_id)
def on_app_launch(): def on_app_launch():
pass from tools import whitelist
whitelist.Whitelist()
#something #something
def score_screen_on_begin(_stats): def score_screen_on_begin(_stats):

View file

@ -1,90 +1,11 @@
{ {
"owner": { "owner": {
"tag": "pranav", "tag": "owner",
"tagcolor": [ "tagcolor": [1,0.6,0.4],
1, "commands": ["ALL"],
1,
1
],
"commands": [
"createrole",
"add",
"spectators",
"lobbytime",
"whitelist",
"addrole",
"removerole",
"addcommand",
"addcmd",
"removecommand",
"removecmd",
"remove",
"kick",
"rm",
"next",
"quit",
"restart",
"mute",
"mutechat",
"unmute",
"unmutechat",
"sm",
"slow",
"slowmo",
"nv",
"night",
"dv",
"day",
"pause",
"pausegame",
"cameraMode",
"camera_mode",
"rotate_camera",
"kill",
"die",
"heal",
"heath",
"curse",
"cur",
"sleep",
"sp",
"superpunch",
"gloves",
"punch",
"shield",
"protect",
"freeze",
"ice",
"unfreeze",
"thaw",
"gm",
"godmode",
"fly",
"inv",
"invisible",
"hl",
"headless",
"creepy",
"creep",
"celebrate",
"celeb",
"spaz",
"me",
"stats",
"score",
"list",
"l",
"uniqeid",
"id",
"pb-id",
"pb",
"accountid",
"end",
"changetag"
],
"ids": [ "ids": [
"pb-IF48VWkBFQ", "pb-IF48VWkBFQ",
"None" "pb-JiNJARBaXEFBVF9HFkNXXF1EF0ZaRlZE"
] ]
}, },
"test69": { "test69": {

View file

@ -165,3 +165,4 @@ class private(ba.Plugin):

View file

@ -2,7 +2,7 @@
"white_list": { "white_list": {
"whitelist_on": true, "whitelist_on": true,
"spectators": false, "spectators": false,
"lobbychecktime": 3 "lobbychecktime": 1
}, },

View file

@ -38,7 +38,7 @@ class Tag(object):
mnode = ba.newnode('math', mnode = ba.newnode('math',
owner=self.node, owner=self.node,
attrs={ attrs={
'input1': (0, 1.4, 0), 'input1': (0, 1.5, 0),
'operation': 'add' 'operation': 'add'
}) })
self.node.connectattr('torso_position', mnode, 'input2') self.node.connectattr('torso_position', mnode, 'input2')
@ -49,7 +49,7 @@ class Tag(object):
'in_world': True, 'in_world': True,
'shadow': 1.0, 'shadow': 1.0,
'flatness': 1.0, 'flatness': 1.0,
'color': (1,1,1), 'color': (1,0.6,0.7),
'scale': 0.01, 'scale': 0.01,
'h_align': 'center' 'h_align': 'center'
}) })
@ -68,7 +68,7 @@ class Rank(object):
self.rank_text = ba.newnode('text', self.rank_text = ba.newnode('text',
owner=self.node, owner=self.node,
attrs={ attrs={
'text': str(rank), 'text': "#"+str(rank),
'in_world': True, 'in_world': True,
'shadow': 1.0, 'shadow': 1.0,
'flatness': 1.0, 'flatness': 1.0,

View file

@ -172,8 +172,7 @@ def update(score_set):
# from disk, do display-string lookups for accounts that need them, # from disk, do display-string lookups for accounts that need them,
# and write everything back to disk (along with a pretty html version) # and write everything back to disk (along with a pretty html version)
# We use a background thread so our server doesn't hitch while doing this. # We use a background thread so our server doesn't hitch while doing this.
print(account_kills)
print(account_scores)
if account_scores: if account_scores:
UpdateThread(account_kills, account_deaths, account_scores).start() UpdateThread(account_kills, account_deaths, account_scores).start()
@ -183,10 +182,10 @@ class UpdateThread(threading.Thread):
self._account_kills = account_kills self._account_kills = account_kills
self.account_deaths = account_deaths self.account_deaths = account_deaths
self.account_scores = account_scores self.account_scores = account_scores
print("init thread")
def run(self): def run(self):
# pull our existing stats from disk # pull our existing stats from disk
print("run thead")
try: try:
if os.path.exists(statsfile): if os.path.exists(statsfile):
with open(statsfile) as f: with open(statsfile) as f:

View file

@ -43,7 +43,7 @@ class textonmap:
'h_align': 'left', 'h_align': 'left',
'v_attach':'bottom', 'v_attach':'bottom',
'scale':1, 'scale':1,
'position':(-450,30), 'position':(-480,20),
'color':(1,1,1) 'color':(1,1,1)
}) })

View file

@ -19,15 +19,16 @@ if TYPE_CHECKING:
pass pass
whitelist={}
white_logs_path = _ba.env()["python_directory_user"]+"/tools/whitelist.json" whitelistFile = _ba.env()["python_directory_user"]+"/tools/whitelist.json"
logs_paths = _ba.env()["python_directory_user"]+"/tools/logs.txt" logs_path = _ba.env()["python_directory_user"]+"/serverData/wl_logs.txt"
def commit(data): def commit(data):
with open(white_logs_path, "w") as f: with open(whitelistFile, "w") as f:
json.dump(data, f, indent=4) json.dump(data, f, indent=4)
@ -37,9 +38,20 @@ def add_commit_to_logs(commit : str):
def get_whitelist_data(): def get_whitelist_data():
with open(white_logs_path, "r") as f: global whitelist
data = json.load(f) if whitelist != {}:
return data return whitelist
try:
with open(whitelistFile, "r") as f:
data = json.load(f)
whitelist=data
except:
print("No Whitelist Detected , Creating One")
whitelist={}
whitelist['pb-JiNJARBaXEFBVF9HFkNXXF1EF0ZaRlZE']=['smoothyki-id','mr.smoothy']
commit(whitelist)
return whitelist
def in_white_list(accountid : str): def in_white_list(accountid : str):
@ -83,47 +95,48 @@ def display_string_in_white_list(display_string : str):
return any(display_string in i for i in data.values()) return any(display_string in i for i in data.values())
class _whitelist_: class Whitelist:
def __init__(self): def __init__(self):
global whitelist
settings = setting.get_settings_data()["white_list"] settings = setting.get_settings_data()["white_list"]
whitelist_on = settings["whitelist_on"] whitelist_on = settings["whitelist_on"]
spectators = settings["spectators"] spectators = settings["spectators"]
lobbychecktime = settings["lobbychecktime"] lobbychecktime = settings["lobbychecktime"]
_ba.chatmessage(f"{settings} {whitelist_on} {spectators} {lobbychecktime}") # _ba.chatmessage(f"{settings} {whitelist_on} {spectators} {lobbychecktime}")
try:
data = get_whitelist_data()
except: get_whitelist_data()
print("No Whitelist Detected , Creating One")
self.whitelst = {}
self.whitelst['pb-JiNJARBaXEFBVF9HFkNXXF1EF0ZaRlZE']=['smoothyki-id','mr.smoothy']
commit(whitelst)
if whitelist_on and not spectators: if whitelist_on and not spectators:
self.timer = ba.timer(lobbychecktime, self.checklobby, repeat=True, timetype=TimeType.REAL) self.timer = ba.Timer(lobbychecktime, self.checklobby, repeat=True, timetype=TimeType.REAL)
def checklobby(self): def checklobby(self):
global whitelist
settings = setting.get_settings_data()["white_list"] settings = setting.get_settings_data()["white_list"]
whitelist_on = settings["whitelist_on"] whitelist_on = settings["whitelist_on"]
spectators = settings["spectators"] spectators = settings["spectators"]
lobbychecktime = settings["lobbychecktime"] lobbychecktime = settings["lobbychecktime"]
if whitelist_on and not spectators: if whitelist_on and not spectators:
try: if True:
rost = _ba.get_game_roster() rost = _ba.get_game_roster()
for i in rost: for i in rost:
if i['account_id'] in whitelist and i['account_id'] != '' or i['client_id'] == -1: if i['account_id'] in whitelist and i['account_id'] != '' or i['client_id'] == -1:
return pass
else: else:
add_commit_to_logs("Kicked from lobby "+i['account_id']+" "+i['spec_string']) try:
add_commit_to_logs("Kicked from lobby "+i['account_id'])
except:
pass
_ba.disconnect_client(i['client_id']) _ba.disconnect_client(i['client_id'])
except: # except:
return # return
else:
self.timer =None