mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-10-20 00:00:39 +00:00
added unban command
This commit is contained in:
parent
a334c3201d
commit
c0722a6916
6 changed files with 65 additions and 37 deletions
|
|
@ -14,7 +14,7 @@ import bascenev1 as bs
|
|||
from tools import logger
|
||||
|
||||
|
||||
Commands = ['recents', 'info', 'createteam', 'showid', 'hideid', 'lm', 'gp',
|
||||
Commands = ['unban', 'recents', 'info', 'createteam', 'showid', 'hideid', 'lm', 'gp',
|
||||
'party', 'quit', 'kickvote', 'maxplayers', 'playlist', 'ban',
|
||||
'kick', 'remove', 'end', 'quit', 'mute', 'unmute', 'slowmo', 'nv',
|
||||
'dv', 'pause', 'tint',
|
||||
|
|
@ -42,6 +42,8 @@ def ExcelCommand(command, arguments, clientid, accountid):
|
|||
None
|
||||
"""
|
||||
match command:
|
||||
case 'unban':
|
||||
unban(arguments)
|
||||
case 'recents':
|
||||
get_recents(clientid)
|
||||
case 'info':
|
||||
|
|
@ -288,6 +290,19 @@ def ban(arguments):
|
|||
pass
|
||||
|
||||
|
||||
def unban(arguments):
|
||||
try:
|
||||
for account in serverdata.recents:
|
||||
if account['client_id'] == int(arguments[0]):
|
||||
pdata.unban_player(
|
||||
account["pbid"])
|
||||
logger.log(
|
||||
f'unbanned {account["pbid"]} by chat command, recents')
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def quit(arguments):
|
||||
if arguments == [] or arguments == ['']:
|
||||
babase.quit()
|
||||
|
|
@ -370,28 +385,28 @@ def nv(arguments):
|
|||
activity = bs.get_foreground_host_activity()
|
||||
nv_tint = (0.5, 0.5, 1.0)
|
||||
nv_ambient = (1.5, 1.5, 1.5)
|
||||
|
||||
|
||||
if is_close(activity.globalsnode.tint, nv_tint):
|
||||
activity.globalsnode.tint = (1, 1, 1)
|
||||
#adding ambient color to imitate moonlight reflection on objects
|
||||
# adding ambient color to imitate moonlight reflection on objects
|
||||
activity.globalsnode.ambient_color = (1, 1, 1)
|
||||
#print(activity.globalsnode.tint)
|
||||
# print(activity.globalsnode.tint)
|
||||
else:
|
||||
activity.globalsnode.tint = nv_tint
|
||||
activity.globalsnode.ambient_color = nv_ambient
|
||||
#print(activity.globalsnode.tint)
|
||||
# print(activity.globalsnode.tint)
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
def tint(arguments):
|
||||
|
||||
|
||||
if len(arguments) == 3:
|
||||
args = arguments
|
||||
r, g, b = float(args[0]), float(args[1]), float(args[2])
|
||||
try:
|
||||
# print(dir(activity.globalsnode))
|
||||
|
||||
|
||||
activity = bs.get_foreground_host_activity()
|
||||
activity.globalsnode.tint = (r, g, b)
|
||||
except:
|
||||
|
|
|
|||
16
dist/ba_root/mods/chathandle/handlechat.py
vendored
16
dist/ba_root/mods/chathandle/handlechat.py
vendored
|
|
@ -17,6 +17,7 @@ settings = setting.get_settings_data()
|
|||
|
||||
def filter_chat_message(msg, client_id):
|
||||
now = datetime.now()
|
||||
# bypassing chat filter for host
|
||||
if client_id == -1:
|
||||
if msg.startswith("/"):
|
||||
command_executor.execute(msg, client_id)
|
||||
|
|
@ -37,6 +38,11 @@ def filter_chat_message(msg, client_id):
|
|||
displaystring = i['display_string']
|
||||
if acid:
|
||||
msg = chatfilter.filter(msg, acid, client_id)
|
||||
else:
|
||||
bs.broadcastmessage("Fetching your account info , please wait",
|
||||
transient=True, clients=[client_id])
|
||||
return
|
||||
|
||||
if msg == None:
|
||||
return
|
||||
logger.log(f'{acid} | {displaystring}| {currentname} | {msg}', "chat")
|
||||
|
|
@ -56,16 +62,16 @@ def filter_chat_message(msg, client_id):
|
|||
return
|
||||
|
||||
elif acid in pdata.get_blacklist()[
|
||||
"muted-ids"] and now < datetime.strptime(
|
||||
pdata.get_blacklist()["muted-ids"][acid]["till"],
|
||||
"%Y-%m-%d %H:%M:%S"):
|
||||
"muted-ids"] and now < datetime.strptime(
|
||||
pdata.get_blacklist()["muted-ids"][acid]["till"],
|
||||
"%Y-%m-%d %H:%M:%S"):
|
||||
bs.broadcastmessage(
|
||||
"You are on mute, maybe try after some time", transient=True,
|
||||
clients=[client_id])
|
||||
return None
|
||||
elif servercheck.get_account_age(
|
||||
serverdata.clients[acid]["accountAge"]) < settings[
|
||||
'minAgeToChatInHours']:
|
||||
serverdata.clients[acid]["accountAge"]) < settings[
|
||||
'minAgeToChatInHours']:
|
||||
bs.broadcastmessage("New accounts not allowed to chat here",
|
||||
transient=True, clients=[client_id])
|
||||
return None
|
||||
|
|
|
|||
13
dist/ba_root/mods/playersdata/pdata.py
vendored
13
dist/ba_root/mods/playersdata/pdata.py
vendored
|
|
@ -160,7 +160,7 @@ def get_detailed_info(pbid):
|
|||
profiles = get_profiles()
|
||||
for key, value in profiles.items():
|
||||
if ("lastIP" in value and value["lastIP"] == ip) or (
|
||||
"deviceUUID" in value and value["deviceUUID"] == deviceid):
|
||||
"deviceUUID" in value and value["deviceUUID"] == deviceid):
|
||||
otheraccounts += ' '.join(value["display_string"])
|
||||
return f"Accounts:{linked_accounts} \n other accounts {otheraccounts} \n created on {dob}"
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ def add_profile(
|
|||
checkSpammer({'id': account_id, 'display': display_string,
|
||||
'ip': ip, 'device': device_id})
|
||||
if device_id in get_blacklist()["ban"]["deviceids"] or account_id in \
|
||||
get_blacklist()["ban"]["ids"]:
|
||||
get_blacklist()["ban"]["ids"]:
|
||||
bs.disconnect_client(cid)
|
||||
serverdata.clients[account_id]["deviceUUID"] = device_id
|
||||
|
||||
|
|
@ -314,6 +314,11 @@ def unban_player(account_id):
|
|||
if account_id in current_profiles:
|
||||
ip = current_profiles[account_id]["lastIP"]
|
||||
device_id = current_profiles[account_id]["deviceUUID"]
|
||||
else:
|
||||
for account in serverdata.recents:
|
||||
if account["pbid"] == account_id:
|
||||
ip = account["ip"]
|
||||
device_id = account["device_uuid"]
|
||||
|
||||
CacheData.blacklist["ban"]["ips"].pop(ip, None)
|
||||
CacheData.blacklist["ban"]["deviceids"].pop(device_id, None)
|
||||
|
|
@ -607,7 +612,7 @@ def get_custom() -> dict:
|
|||
custom["customeffects"][account_id] = [
|
||||
custom["customeffects"][account_id]] if type(
|
||||
custom["customeffects"][account_id]) is str else \
|
||||
custom["customeffects"][account_id]
|
||||
custom["customeffects"][account_id]
|
||||
|
||||
return CacheData.custom
|
||||
|
||||
|
|
@ -626,7 +631,7 @@ def set_effect(effect: str, account_id: str) -> None:
|
|||
if account_id in custom["customeffects"]:
|
||||
effects = [custom["customeffects"][account_id]] if type(
|
||||
custom["customeffects"][account_id]) is str else \
|
||||
custom["customeffects"][account_id]
|
||||
custom["customeffects"][account_id]
|
||||
effects.append(effect)
|
||||
custom["customeffects"][account_id] = effects
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ class BsDataThread(object):
|
|||
def __init__(self):
|
||||
global stats
|
||||
stats["name"] = _babase.app.classic.server._config.party_name
|
||||
stats["discord"] = "https://discord.gg/ucyaesh"
|
||||
stats["discord"] = get_server_settings(
|
||||
)["ballistica_web"]["server_password"]
|
||||
stats["vapidKey"] = notification_manager.get_vapid_keys()["public_key"]
|
||||
|
||||
self.refresh_stats_cache_timer = bs.AppTimer(8, babase.Call(
|
||||
|
|
|
|||
7
dist/ba_root/mods/setting.json
vendored
7
dist/ba_root/mods/setting.json
vendored
|
|
@ -4,7 +4,7 @@
|
|||
"BrodcastCommand": true
|
||||
},
|
||||
"HostDeviceName": "v1.4",
|
||||
"HostName": "BCS",
|
||||
"HostName": "BCSv2",
|
||||
"KickVoteMsgType": "chat",
|
||||
"ScoreScreenAnnouncement": {
|
||||
"enable": true,
|
||||
|
|
@ -36,8 +36,9 @@
|
|||
},
|
||||
"autoTeamBalance": true,
|
||||
"ballistica_web": {
|
||||
"enable": false,
|
||||
"server_password": "my_secerT_password_very_hard"
|
||||
"enable": true,
|
||||
"server_password": "my_secerT_password_very_hard",
|
||||
"discord_link": "https://discord.gg/ucyaesh"
|
||||
},
|
||||
"character_chooser": {
|
||||
"enable": true
|
||||
|
|
|
|||
34
dist/ba_root/mods/tools/servercheck.py
vendored
34
dist/ba_root/mods/tools/servercheck.py
vendored
|
|
@ -48,7 +48,7 @@ class checkserver(object):
|
|||
else:
|
||||
deviceClientMap[device_id].append(ros["client_id"])
|
||||
if len(deviceClientMap[device_id]) >= settings[
|
||||
'maxAccountPerIP']:
|
||||
'maxAccountPerIP']:
|
||||
bs.chatmessage(
|
||||
f"Only {settings['maxAccountPerIP']} player per IP allowed, disconnecting this device.",
|
||||
clients=[
|
||||
|
|
@ -74,7 +74,7 @@ class checkserver(object):
|
|||
continue
|
||||
newPlayers.append(ros['account_id'])
|
||||
if ros['account_id'] not in self.players and ros[
|
||||
'client_id'] != -1:
|
||||
'client_id'] != -1:
|
||||
# new player joined lobby
|
||||
|
||||
d_str = ros['display_string']
|
||||
|
|
@ -103,8 +103,8 @@ class checkserver(object):
|
|||
if settings["whitelist"] and ros["account_id"] is not None:
|
||||
if ros["account_id"] not in pdata.CacheData.whitelist:
|
||||
bs.broadcastmessage("Not in whitelist,contact admin",
|
||||
color=(1, 0, 0), transient=True,
|
||||
clients=[ros['client_id']])
|
||||
color=(1, 0, 0), transient=True,
|
||||
clients=[ros['client_id']])
|
||||
logger.log(
|
||||
f'{d_str} || {ros["account_id"]} | kicked > not in whitelist')
|
||||
bs.disconnect_client(ros['client_id'])
|
||||
|
|
@ -141,9 +141,9 @@ def on_player_join_server(pbid, player_data, ip, device_id):
|
|||
joincount += 1
|
||||
if joincount > 2:
|
||||
bs.broadcastmessage("Joining too fast , slow down dude",
|
||||
# its not possible now tho, network layer will catch it before reaching here
|
||||
color=(1, 0, 1), transient=True,
|
||||
clients=[clid])
|
||||
# its not possible now tho, network layer will catch it before reaching here
|
||||
color=(1, 0, 1), transient=True,
|
||||
clients=[clid])
|
||||
logger.log(f'{pbid} || kicked for joining too fast')
|
||||
bs.disconnect_client(clid)
|
||||
_thread.start_new_thread(reportSpam, (pbid,))
|
||||
|
|
@ -160,7 +160,7 @@ def on_player_join_server(pbid, player_data, ip, device_id):
|
|||
|
||||
if player_data is not None: # player data is in serevrdata or in local.json cache
|
||||
serverdata.recents.append(
|
||||
{"client_id": clid, "deviceId": device_string, "pbid": pbid})
|
||||
{"client_id": clid, "deviceId": device_string, "pbid": pbid, "ip": ip, "device_uuid": device_id})
|
||||
serverdata.recents = serverdata.recents[-20:]
|
||||
if check_ban(ip, device_id, pbid):
|
||||
_babase.chatmessage(
|
||||
|
|
@ -169,7 +169,7 @@ def on_player_join_server(pbid, player_data, ip, device_id):
|
|||
bs.disconnect_client(clid)
|
||||
return
|
||||
if get_account_age(player_data["accountAge"]) < \
|
||||
settings["minAgeToJoinInHours"]:
|
||||
settings["minAgeToJoinInHours"]:
|
||||
for ros in bs.get_game_roster():
|
||||
if ros['account_id'] == pbid:
|
||||
bs.broadcastmessage(
|
||||
|
|
@ -191,9 +191,9 @@ def on_player_join_server(pbid, player_data, ip, device_id):
|
|||
serverdata.clients[pbid]["rejoincount"] = 1
|
||||
serverdata.clients[pbid]["lastJoin"] = time.time()
|
||||
if pbid in blacklist[
|
||||
"kick-vote-disabled"] and current_time < datetime.strptime(
|
||||
blacklist["kick-vote-disabled"][pbid]["till"],
|
||||
"%Y-%m-%d %H:%M:%S"):
|
||||
"kick-vote-disabled"] and current_time < datetime.strptime(
|
||||
blacklist["kick-vote-disabled"][pbid]["till"],
|
||||
"%Y-%m-%d %H:%M:%S"):
|
||||
_babase.disable_kickvote(pbid)
|
||||
|
||||
serverdata.clients[pbid]["lastIP"] = ip
|
||||
|
|
@ -235,15 +235,15 @@ def check_ban(ip, device_id, pbid, log=True):
|
|||
current_time = datetime.now()
|
||||
|
||||
if ip in blacklist["ban"]['ips'] and current_time < datetime.strptime(
|
||||
blacklist["ban"]["ips"][ip]["till"], "%Y-%m-%d %H:%M:%S"):
|
||||
blacklist["ban"]["ips"][ip]["till"], "%Y-%m-%d %H:%M:%S"):
|
||||
msg = f' reason: matched IP | {blacklist["ban"]["ips"][ip]["reason"]} , Till : {blacklist["ban"]["ips"][ip]["till"]}'
|
||||
if log:
|
||||
logger.log(f'{pbid} | kicked > {msg}')
|
||||
return True
|
||||
return msg
|
||||
elif device_id in blacklist["ban"][
|
||||
"deviceids"] and current_time < datetime.strptime(
|
||||
blacklist["ban"]["deviceids"][device_id]["till"], "%Y-%m-%d %H:%M:%S"):
|
||||
"deviceids"] and current_time < datetime.strptime(
|
||||
blacklist["ban"]["deviceids"][device_id]["till"], "%Y-%m-%d %H:%M:%S"):
|
||||
msg = f'reason: matched deviceId | {blacklist["ban"]["deviceids"][device_id]["reason"]}, Till : {blacklist["ban"]["deviceids"][device_id]["till"]}'
|
||||
if log:
|
||||
logger.log(
|
||||
|
|
@ -251,7 +251,7 @@ def check_ban(ip, device_id, pbid, log=True):
|
|||
return True
|
||||
return msg
|
||||
elif pbid in blacklist["ban"]["ids"] and current_time < datetime.strptime(
|
||||
blacklist["ban"]["ids"][pbid]["till"], "%Y-%m-%d %H:%M:%S"):
|
||||
blacklist["ban"]["ids"][pbid]["till"], "%Y-%m-%d %H:%M:%S"):
|
||||
msg = f'reason: matched ID | {blacklist["ban"]["ids"][pbid]["reason"]} , Till : {blacklist["ban"]["ids"][pbid]["till"]}'
|
||||
if log:
|
||||
logger.log(
|
||||
|
|
@ -401,7 +401,7 @@ def kick_by_pb_id(pb_id, msg):
|
|||
for ros in bs.get_game_roster():
|
||||
if ros['account_id'] == pb_id:
|
||||
bs.broadcastmessage(msg, transient=True,
|
||||
clients=[ros['client_id']])
|
||||
clients=[ros['client_id']])
|
||||
bs.disconnect_client(ros['client_id'])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue