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
|
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',
|
'party', 'quit', 'kickvote', 'maxplayers', 'playlist', 'ban',
|
||||||
'kick', 'remove', 'end', 'quit', 'mute', 'unmute', 'slowmo', 'nv',
|
'kick', 'remove', 'end', 'quit', 'mute', 'unmute', 'slowmo', 'nv',
|
||||||
'dv', 'pause', 'tint',
|
'dv', 'pause', 'tint',
|
||||||
|
|
@ -42,6 +42,8 @@ def ExcelCommand(command, arguments, clientid, accountid):
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
match command:
|
match command:
|
||||||
|
case 'unban':
|
||||||
|
unban(arguments)
|
||||||
case 'recents':
|
case 'recents':
|
||||||
get_recents(clientid)
|
get_recents(clientid)
|
||||||
case 'info':
|
case 'info':
|
||||||
|
|
@ -288,6 +290,19 @@ def ban(arguments):
|
||||||
pass
|
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):
|
def quit(arguments):
|
||||||
if arguments == [] or arguments == ['']:
|
if arguments == [] or arguments == ['']:
|
||||||
babase.quit()
|
babase.quit()
|
||||||
|
|
@ -370,28 +385,28 @@ def nv(arguments):
|
||||||
activity = bs.get_foreground_host_activity()
|
activity = bs.get_foreground_host_activity()
|
||||||
nv_tint = (0.5, 0.5, 1.0)
|
nv_tint = (0.5, 0.5, 1.0)
|
||||||
nv_ambient = (1.5, 1.5, 1.5)
|
nv_ambient = (1.5, 1.5, 1.5)
|
||||||
|
|
||||||
if is_close(activity.globalsnode.tint, nv_tint):
|
if is_close(activity.globalsnode.tint, nv_tint):
|
||||||
activity.globalsnode.tint = (1, 1, 1)
|
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)
|
activity.globalsnode.ambient_color = (1, 1, 1)
|
||||||
#print(activity.globalsnode.tint)
|
# print(activity.globalsnode.tint)
|
||||||
else:
|
else:
|
||||||
activity.globalsnode.tint = nv_tint
|
activity.globalsnode.tint = nv_tint
|
||||||
activity.globalsnode.ambient_color = nv_ambient
|
activity.globalsnode.ambient_color = nv_ambient
|
||||||
#print(activity.globalsnode.tint)
|
# print(activity.globalsnode.tint)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def tint(arguments):
|
def tint(arguments):
|
||||||
|
|
||||||
if len(arguments) == 3:
|
if len(arguments) == 3:
|
||||||
args = arguments
|
args = arguments
|
||||||
r, g, b = float(args[0]), float(args[1]), float(args[2])
|
r, g, b = float(args[0]), float(args[1]), float(args[2])
|
||||||
try:
|
try:
|
||||||
# print(dir(activity.globalsnode))
|
# print(dir(activity.globalsnode))
|
||||||
|
|
||||||
activity = bs.get_foreground_host_activity()
|
activity = bs.get_foreground_host_activity()
|
||||||
activity.globalsnode.tint = (r, g, b)
|
activity.globalsnode.tint = (r, g, b)
|
||||||
except:
|
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):
|
def filter_chat_message(msg, client_id):
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
# bypassing chat filter for host
|
||||||
if client_id == -1:
|
if client_id == -1:
|
||||||
if msg.startswith("/"):
|
if msg.startswith("/"):
|
||||||
command_executor.execute(msg, client_id)
|
command_executor.execute(msg, client_id)
|
||||||
|
|
@ -37,6 +38,11 @@ def filter_chat_message(msg, client_id):
|
||||||
displaystring = i['display_string']
|
displaystring = i['display_string']
|
||||||
if acid:
|
if acid:
|
||||||
msg = chatfilter.filter(msg, acid, client_id)
|
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:
|
if msg == None:
|
||||||
return
|
return
|
||||||
logger.log(f'{acid} | {displaystring}| {currentname} | {msg}', "chat")
|
logger.log(f'{acid} | {displaystring}| {currentname} | {msg}', "chat")
|
||||||
|
|
@ -56,16 +62,16 @@ def filter_chat_message(msg, client_id):
|
||||||
return
|
return
|
||||||
|
|
||||||
elif acid in pdata.get_blacklist()[
|
elif acid in pdata.get_blacklist()[
|
||||||
"muted-ids"] and now < datetime.strptime(
|
"muted-ids"] and now < datetime.strptime(
|
||||||
pdata.get_blacklist()["muted-ids"][acid]["till"],
|
pdata.get_blacklist()["muted-ids"][acid]["till"],
|
||||||
"%Y-%m-%d %H:%M:%S"):
|
"%Y-%m-%d %H:%M:%S"):
|
||||||
bs.broadcastmessage(
|
bs.broadcastmessage(
|
||||||
"You are on mute, maybe try after some time", transient=True,
|
"You are on mute, maybe try after some time", transient=True,
|
||||||
clients=[client_id])
|
clients=[client_id])
|
||||||
return None
|
return None
|
||||||
elif servercheck.get_account_age(
|
elif servercheck.get_account_age(
|
||||||
serverdata.clients[acid]["accountAge"]) < settings[
|
serverdata.clients[acid]["accountAge"]) < settings[
|
||||||
'minAgeToChatInHours']:
|
'minAgeToChatInHours']:
|
||||||
bs.broadcastmessage("New accounts not allowed to chat here",
|
bs.broadcastmessage("New accounts not allowed to chat here",
|
||||||
transient=True, clients=[client_id])
|
transient=True, clients=[client_id])
|
||||||
return None
|
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()
|
profiles = get_profiles()
|
||||||
for key, value in profiles.items():
|
for key, value in profiles.items():
|
||||||
if ("lastIP" in value and value["lastIP"] == ip) or (
|
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"])
|
otheraccounts += ' '.join(value["display_string"])
|
||||||
return f"Accounts:{linked_accounts} \n other accounts {otheraccounts} \n created on {dob}"
|
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,
|
checkSpammer({'id': account_id, 'display': display_string,
|
||||||
'ip': ip, 'device': device_id})
|
'ip': ip, 'device': device_id})
|
||||||
if device_id in get_blacklist()["ban"]["deviceids"] or account_id in \
|
if device_id in get_blacklist()["ban"]["deviceids"] or account_id in \
|
||||||
get_blacklist()["ban"]["ids"]:
|
get_blacklist()["ban"]["ids"]:
|
||||||
bs.disconnect_client(cid)
|
bs.disconnect_client(cid)
|
||||||
serverdata.clients[account_id]["deviceUUID"] = device_id
|
serverdata.clients[account_id]["deviceUUID"] = device_id
|
||||||
|
|
||||||
|
|
@ -314,6 +314,11 @@ def unban_player(account_id):
|
||||||
if account_id in current_profiles:
|
if account_id in current_profiles:
|
||||||
ip = current_profiles[account_id]["lastIP"]
|
ip = current_profiles[account_id]["lastIP"]
|
||||||
device_id = current_profiles[account_id]["deviceUUID"]
|
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"]["ips"].pop(ip, None)
|
||||||
CacheData.blacklist["ban"]["deviceids"].pop(device_id, 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] = [
|
||||||
custom["customeffects"][account_id]] if type(
|
custom["customeffects"][account_id]] if type(
|
||||||
custom["customeffects"][account_id]) is str else \
|
custom["customeffects"][account_id]) is str else \
|
||||||
custom["customeffects"][account_id]
|
custom["customeffects"][account_id]
|
||||||
|
|
||||||
return CacheData.custom
|
return CacheData.custom
|
||||||
|
|
||||||
|
|
@ -626,7 +631,7 @@ def set_effect(effect: str, account_id: str) -> None:
|
||||||
if account_id in custom["customeffects"]:
|
if account_id in custom["customeffects"]:
|
||||||
effects = [custom["customeffects"][account_id]] if type(
|
effects = [custom["customeffects"][account_id]] if type(
|
||||||
custom["customeffects"][account_id]) is str else \
|
custom["customeffects"][account_id]) is str else \
|
||||||
custom["customeffects"][account_id]
|
custom["customeffects"][account_id]
|
||||||
effects.append(effect)
|
effects.append(effect)
|
||||||
custom["customeffects"][account_id] = effects
|
custom["customeffects"][account_id] = effects
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ class BsDataThread(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
global stats
|
global stats
|
||||||
stats["name"] = _babase.app.classic.server._config.party_name
|
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"]
|
stats["vapidKey"] = notification_manager.get_vapid_keys()["public_key"]
|
||||||
|
|
||||||
self.refresh_stats_cache_timer = bs.AppTimer(8, babase.Call(
|
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
|
"BrodcastCommand": true
|
||||||
},
|
},
|
||||||
"HostDeviceName": "v1.4",
|
"HostDeviceName": "v1.4",
|
||||||
"HostName": "BCS",
|
"HostName": "BCSv2",
|
||||||
"KickVoteMsgType": "chat",
|
"KickVoteMsgType": "chat",
|
||||||
"ScoreScreenAnnouncement": {
|
"ScoreScreenAnnouncement": {
|
||||||
"enable": true,
|
"enable": true,
|
||||||
|
|
@ -36,8 +36,9 @@
|
||||||
},
|
},
|
||||||
"autoTeamBalance": true,
|
"autoTeamBalance": true,
|
||||||
"ballistica_web": {
|
"ballistica_web": {
|
||||||
"enable": false,
|
"enable": true,
|
||||||
"server_password": "my_secerT_password_very_hard"
|
"server_password": "my_secerT_password_very_hard",
|
||||||
|
"discord_link": "https://discord.gg/ucyaesh"
|
||||||
},
|
},
|
||||||
"character_chooser": {
|
"character_chooser": {
|
||||||
"enable": true
|
"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:
|
else:
|
||||||
deviceClientMap[device_id].append(ros["client_id"])
|
deviceClientMap[device_id].append(ros["client_id"])
|
||||||
if len(deviceClientMap[device_id]) >= settings[
|
if len(deviceClientMap[device_id]) >= settings[
|
||||||
'maxAccountPerIP']:
|
'maxAccountPerIP']:
|
||||||
bs.chatmessage(
|
bs.chatmessage(
|
||||||
f"Only {settings['maxAccountPerIP']} player per IP allowed, disconnecting this device.",
|
f"Only {settings['maxAccountPerIP']} player per IP allowed, disconnecting this device.",
|
||||||
clients=[
|
clients=[
|
||||||
|
|
@ -74,7 +74,7 @@ class checkserver(object):
|
||||||
continue
|
continue
|
||||||
newPlayers.append(ros['account_id'])
|
newPlayers.append(ros['account_id'])
|
||||||
if ros['account_id'] not in self.players and ros[
|
if ros['account_id'] not in self.players and ros[
|
||||||
'client_id'] != -1:
|
'client_id'] != -1:
|
||||||
# new player joined lobby
|
# new player joined lobby
|
||||||
|
|
||||||
d_str = ros['display_string']
|
d_str = ros['display_string']
|
||||||
|
|
@ -103,8 +103,8 @@ class checkserver(object):
|
||||||
if settings["whitelist"] and ros["account_id"] is not None:
|
if settings["whitelist"] and ros["account_id"] is not None:
|
||||||
if ros["account_id"] not in pdata.CacheData.whitelist:
|
if ros["account_id"] not in pdata.CacheData.whitelist:
|
||||||
bs.broadcastmessage("Not in whitelist,contact admin",
|
bs.broadcastmessage("Not in whitelist,contact admin",
|
||||||
color=(1, 0, 0), transient=True,
|
color=(1, 0, 0), transient=True,
|
||||||
clients=[ros['client_id']])
|
clients=[ros['client_id']])
|
||||||
logger.log(
|
logger.log(
|
||||||
f'{d_str} || {ros["account_id"]} | kicked > not in whitelist')
|
f'{d_str} || {ros["account_id"]} | kicked > not in whitelist')
|
||||||
bs.disconnect_client(ros['client_id'])
|
bs.disconnect_client(ros['client_id'])
|
||||||
|
|
@ -141,9 +141,9 @@ def on_player_join_server(pbid, player_data, ip, device_id):
|
||||||
joincount += 1
|
joincount += 1
|
||||||
if joincount > 2:
|
if joincount > 2:
|
||||||
bs.broadcastmessage("Joining too fast , slow down dude",
|
bs.broadcastmessage("Joining too fast , slow down dude",
|
||||||
# its not possible now tho, network layer will catch it before reaching here
|
# its not possible now tho, network layer will catch it before reaching here
|
||||||
color=(1, 0, 1), transient=True,
|
color=(1, 0, 1), transient=True,
|
||||||
clients=[clid])
|
clients=[clid])
|
||||||
logger.log(f'{pbid} || kicked for joining too fast')
|
logger.log(f'{pbid} || kicked for joining too fast')
|
||||||
bs.disconnect_client(clid)
|
bs.disconnect_client(clid)
|
||||||
_thread.start_new_thread(reportSpam, (pbid,))
|
_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
|
if player_data is not None: # player data is in serevrdata or in local.json cache
|
||||||
serverdata.recents.append(
|
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:]
|
serverdata.recents = serverdata.recents[-20:]
|
||||||
if check_ban(ip, device_id, pbid):
|
if check_ban(ip, device_id, pbid):
|
||||||
_babase.chatmessage(
|
_babase.chatmessage(
|
||||||
|
|
@ -169,7 +169,7 @@ def on_player_join_server(pbid, player_data, ip, device_id):
|
||||||
bs.disconnect_client(clid)
|
bs.disconnect_client(clid)
|
||||||
return
|
return
|
||||||
if get_account_age(player_data["accountAge"]) < \
|
if get_account_age(player_data["accountAge"]) < \
|
||||||
settings["minAgeToJoinInHours"]:
|
settings["minAgeToJoinInHours"]:
|
||||||
for ros in bs.get_game_roster():
|
for ros in bs.get_game_roster():
|
||||||
if ros['account_id'] == pbid:
|
if ros['account_id'] == pbid:
|
||||||
bs.broadcastmessage(
|
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]["rejoincount"] = 1
|
||||||
serverdata.clients[pbid]["lastJoin"] = time.time()
|
serverdata.clients[pbid]["lastJoin"] = time.time()
|
||||||
if pbid in blacklist[
|
if pbid in blacklist[
|
||||||
"kick-vote-disabled"] and current_time < datetime.strptime(
|
"kick-vote-disabled"] and current_time < datetime.strptime(
|
||||||
blacklist["kick-vote-disabled"][pbid]["till"],
|
blacklist["kick-vote-disabled"][pbid]["till"],
|
||||||
"%Y-%m-%d %H:%M:%S"):
|
"%Y-%m-%d %H:%M:%S"):
|
||||||
_babase.disable_kickvote(pbid)
|
_babase.disable_kickvote(pbid)
|
||||||
|
|
||||||
serverdata.clients[pbid]["lastIP"] = ip
|
serverdata.clients[pbid]["lastIP"] = ip
|
||||||
|
|
@ -235,15 +235,15 @@ def check_ban(ip, device_id, pbid, log=True):
|
||||||
current_time = datetime.now()
|
current_time = datetime.now()
|
||||||
|
|
||||||
if ip in blacklist["ban"]['ips'] and current_time < datetime.strptime(
|
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"]}'
|
msg = f' reason: matched IP | {blacklist["ban"]["ips"][ip]["reason"]} , Till : {blacklist["ban"]["ips"][ip]["till"]}'
|
||||||
if log:
|
if log:
|
||||||
logger.log(f'{pbid} | kicked > {msg}')
|
logger.log(f'{pbid} | kicked > {msg}')
|
||||||
return True
|
return True
|
||||||
return msg
|
return msg
|
||||||
elif device_id in blacklist["ban"][
|
elif device_id in blacklist["ban"][
|
||||||
"deviceids"] and current_time < datetime.strptime(
|
"deviceids"] and current_time < datetime.strptime(
|
||||||
blacklist["ban"]["deviceids"][device_id]["till"], "%Y-%m-%d %H:%M:%S"):
|
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"]}'
|
msg = f'reason: matched deviceId | {blacklist["ban"]["deviceids"][device_id]["reason"]}, Till : {blacklist["ban"]["deviceids"][device_id]["till"]}'
|
||||||
if log:
|
if log:
|
||||||
logger.log(
|
logger.log(
|
||||||
|
|
@ -251,7 +251,7 @@ def check_ban(ip, device_id, pbid, log=True):
|
||||||
return True
|
return True
|
||||||
return msg
|
return msg
|
||||||
elif pbid in blacklist["ban"]["ids"] and current_time < datetime.strptime(
|
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"]}'
|
msg = f'reason: matched ID | {blacklist["ban"]["ids"][pbid]["reason"]} , Till : {blacklist["ban"]["ids"][pbid]["till"]}'
|
||||||
if log:
|
if log:
|
||||||
logger.log(
|
logger.log(
|
||||||
|
|
@ -401,7 +401,7 @@ def kick_by_pb_id(pb_id, msg):
|
||||||
for ros in bs.get_game_roster():
|
for ros in bs.get_game_roster():
|
||||||
if ros['account_id'] == pb_id:
|
if ros['account_id'] == pb_id:
|
||||||
bs.broadcastmessage(msg, transient=True,
|
bs.broadcastmessage(msg, transient=True,
|
||||||
clients=[ros['client_id']])
|
clients=[ros['client_id']])
|
||||||
bs.disconnect_client(ros['client_id'])
|
bs.disconnect_client(ros['client_id'])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue