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(),
transition='out_right')
import privateserver as pvt
import custom_hooks as chooks
def filter_chat_message(msg: str, client_id: int) -> Optional[str]:
"""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
to ignore the message.
"""
pvt.handlechat(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.
"""
import privateserver as pvt
pvt.handlerequest(player)
from tools import whitelist
whitelist.handle_player_request(player)
# Limit player counts *unless* we're in a stress test.
if _ba.app.stress_test_reset_timer is None:

View file

@ -38,9 +38,12 @@ def check_permissions(accountid, command):
Boolean
"""
roles = pdata.get_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 False

View file

@ -57,7 +57,7 @@ def ExcelCommand(command, arguments, clientid, accountid):
rotate_camera()
elif command == 'createrole':
create_role_call(arguments)
create_role(arguments)
elif command == 'addrole':
add_role_to_player(arguments)
@ -72,7 +72,7 @@ def ExcelCommand(command, arguments, clientid, accountid):
remove_command_to_role(arguments)
elif command == 'changetag':
change_role_tag_call(arguments)
change_role_tag(arguments)
elif command in ['add', 'whitelist']:
whitelst_it(accountid, arguments)
@ -280,15 +280,20 @@ def whitelst_it(accountid : str, arguments):
settings = setting.get_settings_data()
if arguments[0] == 'on':
settings["white_list"]["whitelist_on"] = True
setting.commit(settings)
cmsg("whitelist on")
if settings["white_list"]["whitelist_on"]:
_ba.chatmessage("Already on")
else:
settings["white_list"]["whitelist_on"] = True
setting.commit(settings)
_ba.chatmessage("whitelist on")
from tools import whitelist
whitelist.Whitelist()
return
elif arguments[0] == 'off':
settings["white_list"]["whitelist_on"] = False
setting.commit(settings)
cmsg("whitelist off")
_ba.chatmessage("whitelist off")
return
else:
@ -297,7 +302,7 @@ def whitelst_it(accountid : str, arguments):
for i in rost:
if i['client_id'] == int(arguments[0]):
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'])
@ -311,12 +316,12 @@ def spectators(arguments):
if arguments[0] == 'on':
settings["white_list"]["spectators"] = True
setting.commit(settings)
cmsg("spectators on")
_ba.chatmessage("spectators on")
elif arguments[0] == 'off':
settings["white_list"]["spectators"] = False
setting.commit(settings)
cmsg("spectators off")
_ba.chatmessage("spectators off")
@ -325,8 +330,8 @@ def change_lobby_check_time(arguments):
try:
argument = int(arguments[0])
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["white_list"]["lobbychecktime"] = argument
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
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():
pass
from tools import whitelist
whitelist.Whitelist()
#something
def score_screen_on_begin(_stats):

View file

@ -1,90 +1,11 @@
{
"owner": {
"tag": "pranav",
"tagcolor": [
1,
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"
],
"tag": "owner",
"tagcolor": [1,0.6,0.4],
"commands": ["ALL"],
"ids": [
"pb-IF48VWkBFQ",
"None"
"pb-JiNJARBaXEFBVF9HFkNXXF1EF0ZaRlZE"
]
},
"test69": {

View file

@ -159,6 +159,7 @@ class private(ba.Plugin):
_ba.disconnect_client(clt['client_id'])
except:
pass

View file

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

View file

@ -38,7 +38,7 @@ class Tag(object):
mnode = ba.newnode('math',
owner=self.node,
attrs={
'input1': (0, 1.4, 0),
'input1': (0, 1.5, 0),
'operation': 'add'
})
self.node.connectattr('torso_position', mnode, 'input2')
@ -49,7 +49,7 @@ class Tag(object):
'in_world': True,
'shadow': 1.0,
'flatness': 1.0,
'color': (1,1,1),
'color': (1,0.6,0.7),
'scale': 0.01,
'h_align': 'center'
})
@ -68,7 +68,7 @@ class Rank(object):
self.rank_text = ba.newnode('text',
owner=self.node,
attrs={
'text': str(rank),
'text': "#"+str(rank),
'in_world': True,
'shadow': 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,
# 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.
print(account_kills)
print(account_scores)
if account_scores:
UpdateThread(account_kills, account_deaths, account_scores).start()
@ -183,10 +182,10 @@ class UpdateThread(threading.Thread):
self._account_kills = account_kills
self.account_deaths = account_deaths
self.account_scores = account_scores
print("init thread")
def run(self):
# pull our existing stats from disk
print("run thead")
try:
if os.path.exists(statsfile):
with open(statsfile) as f:

View file

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

View file

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