added unban command

This commit is contained in:
Ayush Saini 2025-02-22 21:52:49 +05:30
parent a334c3201d
commit c0722a6916
6 changed files with 65 additions and 37 deletions

View file

@ -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()

View file

@ -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")

View file

@ -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)

View file

@ -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(

View file

@ -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

View file

@ -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(