mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-11-14 17:46:03 +00:00
logging fix , playlist fallback
This commit is contained in:
parent
436ee54ba2
commit
0dfe2de8e5
6 changed files with 109 additions and 110 deletions
11
dist/ba_data/python/ba/_multiteamsession.py
vendored
11
dist/ba_data/python/ba/_multiteamsession.py
vendored
|
|
@ -105,9 +105,16 @@ class MultiTeamSession(Session):
|
||||||
add_resolved_type=True,
|
add_resolved_type=True,
|
||||||
name='default teams' if self.use_teams else 'default ffa',
|
name='default teams' if self.use_teams else 'default ffa',
|
||||||
)
|
)
|
||||||
|
default_playlist_resolved = _playlist.filter_playlist(
|
||||||
|
_playlist.get_default_teams_playlist(),
|
||||||
|
sessiontype=type(self),
|
||||||
|
add_resolved_type=True,
|
||||||
|
name='default teams' if self.use_teams else 'default ffa',
|
||||||
|
)
|
||||||
if not playlist_resolved:
|
if not playlist_resolved:
|
||||||
raise RuntimeError('Playlist contains no valid games.')
|
print("PLAYLIST CONTAINS NO VALID GAMES , FALLING BACK TO DEFAULT TEAM PLAYLIST")
|
||||||
|
playlist_resolved = default_playlist_resolved
|
||||||
|
# raise RuntimeError('Playlist contains no valid games.')
|
||||||
|
|
||||||
self._playlist = ShuffleList(
|
self._playlist = ShuffleList(
|
||||||
playlist_resolved, shuffle=self._playlist_randomize
|
playlist_resolved, shuffle=self._playlist_randomize
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,58 @@
|
||||||
# Released under the MIT License. See LICENSE for details.
|
# Released under the MIT License. See LICENSE for details.
|
||||||
|
|
||||||
from playersData import pdata
|
from playersData import pdata
|
||||||
import ba
|
import ba
|
||||||
import ba.internal
|
import ba.internal
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def clientid_to_accountid(clientid):
|
def clientid_to_accountid(clientid):
|
||||||
"""
|
"""
|
||||||
Transform Clientid To Accountid
|
Transform Clientid To Accountid
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
clientid : int
|
clientid : int
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
for i in ba.internal.get_game_roster():
|
for i in ba.internal.get_game_roster():
|
||||||
if i['client_id'] == clientid:
|
if i['client_id'] == clientid:
|
||||||
return i['account_id']
|
return i['account_id']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def check_permissions(accountid, command):
|
def check_permissions(accountid, command):
|
||||||
"""
|
"""
|
||||||
Checks The Permission To Player To Executive Command
|
Checks The Permission To Player To Executive Command
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
accountid : str
|
accountid : str
|
||||||
command : str
|
command : str
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Boolean
|
Boolean
|
||||||
"""
|
"""
|
||||||
roles = pdata.get_roles()
|
roles = pdata.get_roles()
|
||||||
|
|
||||||
if is_server(accountid):
|
if is_server(accountid):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for role in roles:
|
for role in roles:
|
||||||
if accountid in roles[role]["ids"] and "ALL" in roles[role]["commands"]:
|
if accountid in roles[role]["ids"] and "ALL" in roles[role]["commands"]:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif accountid in roles[role]["ids"] and command in roles[role]["commands"]:
|
elif accountid in roles[role]["ids"] and command in roles[role]["commands"]:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def is_server(accid):
|
def is_server(accid):
|
||||||
for i in ba.internal.get_game_roster():
|
for i in ba.internal.get_game_roster():
|
||||||
if i['account_id']==accid and i['client_id']==-1:
|
if i['account_id']==accid and i['client_id']==-1:
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -5,43 +5,30 @@ import ba.internal
|
||||||
|
|
||||||
|
|
||||||
def send(msg, clientid):
|
def send(msg, clientid):
|
||||||
"""Shortcut To Send Private Msg To Client"""
|
"""Shortcut To Send Private Msg To Client"""
|
||||||
|
for m in msg.split("\n"):
|
||||||
ba.internal.chatmessage(str(msg), clients=[clientid])
|
ba.internal.chatmessage(str(m), clients=[clientid])
|
||||||
_ba.screenmessage(str(msg), transient=True, clients=[clientid])
|
_ba.screenmessage(str(msg), transient=True, clients=[clientid])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def clientid_to_myself(clientid):
|
def clientid_to_myself(clientid):
|
||||||
"""Return Player Index Of Self Player"""
|
"""Return Player Index Of Self Player"""
|
||||||
|
|
||||||
for i , player in enumerate(_ba.get_foreground_host_activity().players):
|
|
||||||
if player.sessionplayer.inputdevice.client_id == clientid:
|
|
||||||
return i
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for i , player in enumerate(_ba.get_foreground_host_activity().players):
|
||||||
|
if player.sessionplayer.inputdevice.client_id == clientid:
|
||||||
|
return i
|
||||||
|
|
||||||
def handlemsg(client, msg):
|
def handlemsg(client, msg):
|
||||||
"""Handles Spaz Msg For Single Player"""
|
"""Handles Spaz Msg For Single Player"""
|
||||||
|
activity = _ba.get_foreground_host_activity()
|
||||||
activity = _ba.get_foreground_host_activity()
|
activity.players[client].actor.node.handlemessage(msg)
|
||||||
activity.players[client].actor.node.handlemessage(msg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def handlemsg_all(msg):
|
def handlemsg_all(msg):
|
||||||
"""Handle Spaz message for all players in activity"""
|
"""Handle Spaz message for all players in activity"""
|
||||||
|
|
||||||
activity = _ba.get_foreground_host_activity()
|
activity = _ba.get_foreground_host_activity()
|
||||||
|
|
||||||
for i in activity.players:
|
for i in activity.players:
|
||||||
i.actor.node.handlemessage(msg)
|
i.actor.node.handlemessage(msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
4
dist/ba_root/mods/chatHandle/handlechat.py
vendored
4
dist/ba_root/mods/chatHandle/handlechat.py
vendored
|
|
@ -18,6 +18,7 @@ def filter_chat_message(msg, client_id):
|
||||||
if msg.startswith("/"):
|
if msg.startswith("/"):
|
||||||
Main.Command(msg, client_id)
|
Main.Command(msg, client_id)
|
||||||
return None
|
return None
|
||||||
|
logger.log("Host msg: |" + msg , "chat")
|
||||||
return msg
|
return msg
|
||||||
acid = ""
|
acid = ""
|
||||||
displaystring = ""
|
displaystring = ""
|
||||||
|
|
@ -35,6 +36,7 @@ def filter_chat_message(msg, client_id):
|
||||||
msg = ChatFilter.filter(msg, acid, client_id)
|
msg = ChatFilter.filter(msg, acid, client_id)
|
||||||
if msg == None:
|
if msg == None:
|
||||||
return
|
return
|
||||||
|
logger.log(acid + " | " + displaystring + " | " + currentname + " | " + msg, "chat")
|
||||||
if msg.startswith("/"):
|
if msg.startswith("/"):
|
||||||
return Main.Command(msg, client_id)
|
return Main.Command(msg, client_id)
|
||||||
|
|
||||||
|
|
@ -46,8 +48,6 @@ def filter_chat_message(msg, client_id):
|
||||||
if msg == "end" and settings["allowEndVote"]:
|
if msg == "end" and settings["allowEndVote"]:
|
||||||
EndVote.vote_end(acid, client_id)
|
EndVote.vote_end(acid, client_id)
|
||||||
|
|
||||||
logger.log(acid + " | " + displaystring + "|" + currentname + "| " + msg, "chat")
|
|
||||||
|
|
||||||
if acid in serverdata.clients and serverdata.clients[acid]["verified"]:
|
if acid in serverdata.clients and serverdata.clients[acid]["verified"]:
|
||||||
|
|
||||||
if serverdata.muted:
|
if serverdata.muted:
|
||||||
|
|
|
||||||
35
dist/ba_root/mods/features/discord_bot.py
vendored
35
dist/ba_root/mods/features/discord_bot.py
vendored
|
|
@ -12,7 +12,10 @@ import os
|
||||||
import _thread
|
import _thread
|
||||||
import logging
|
import logging
|
||||||
logging.getLogger('asyncio').setLevel(logging.WARNING)
|
logging.getLogger('asyncio').setLevel(logging.WARNING)
|
||||||
client = Bot(command_prefix='!')
|
intents = discord.Intents().all()
|
||||||
|
|
||||||
|
client = Bot(command_prefix='!', intents=intents)
|
||||||
|
|
||||||
|
|
||||||
# client = discord.Client()
|
# client = discord.Client()
|
||||||
|
|
||||||
|
|
@ -31,12 +34,10 @@ def push_log(msg):
|
||||||
logs.append(msg)
|
logs.append(msg)
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.create_task(client.start(token))
|
loop.create_task(client.start(token))
|
||||||
|
|
||||||
Thread(target=loop.run_forever).start()
|
Thread(target=loop.run_forever).start()
|
||||||
|
|
||||||
channel=None
|
channel=None
|
||||||
|
|
@ -46,7 +47,7 @@ async def on_message(message):
|
||||||
if message.author == client.user:
|
if message.author == client.user:
|
||||||
return
|
return
|
||||||
channel=message.channel
|
channel=message.channel
|
||||||
|
|
||||||
if message.channel.id==logsChannelID:
|
if message.channel.id==logsChannelID:
|
||||||
_ba.pushcall(Call(ba.internal.chatmessage,message.content),from_other_thread=True)
|
_ba.pushcall(Call(ba.internal.chatmessage,message.content),from_other_thread=True)
|
||||||
|
|
||||||
|
|
@ -54,7 +55,7 @@ async def on_message(message):
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print("Discord bot logged in as: %s, %s" % (client.user.name, client.user.id))
|
print("Discord bot logged in as: %s, %s" % (client.user.name, client.user.id))
|
||||||
|
|
||||||
await verify_channel()
|
await verify_channel()
|
||||||
|
|
||||||
async def verify_channel():
|
async def verify_channel():
|
||||||
|
|
@ -81,10 +82,10 @@ async def refresh_stats():
|
||||||
await client.wait_until_ready()
|
await client.wait_until_ready()
|
||||||
|
|
||||||
while not client.is_closed():
|
while not client.is_closed():
|
||||||
|
|
||||||
await livestatsmsgs[0].edit(content=get_live_players_msg())
|
await livestatsmsgs[0].edit(content=get_live_players_msg())
|
||||||
await livestatsmsgs[1].edit(content=get_chats())
|
await livestatsmsgs[1].edit(content=get_chats())
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(10)
|
||||||
|
|
||||||
async def send_logs():
|
async def send_logs():
|
||||||
global logs
|
global logs
|
||||||
|
|
@ -101,7 +102,7 @@ async def send_logs():
|
||||||
if msg:
|
if msg:
|
||||||
await channel.send(msg)
|
await channel.send(msg)
|
||||||
|
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -143,7 +144,7 @@ class BsDataThread(object):
|
||||||
self.refreshStats()
|
self.refreshStats()
|
||||||
self.Timer = ba.Timer( 8,ba.Call(self.refreshStats),repeat = True)
|
self.Timer = ba.Timer( 8,ba.Call(self.refreshStats),repeat = True)
|
||||||
# self.Timerr = ba.Timer( 10,ba.Call(self.refreshLeaderboard),timetype = ba.TimeType.REAL,repeat = True)
|
# self.Timerr = ba.Timer( 10,ba.Call(self.refreshLeaderboard),timetype = ba.TimeType.REAL,repeat = True)
|
||||||
|
|
||||||
# def refreshLeaderboard(self):
|
# def refreshLeaderboard(self):
|
||||||
# global leaderboard
|
# global leaderboard
|
||||||
# global top200
|
# global top200
|
||||||
|
|
@ -152,7 +153,7 @@ class BsDataThread(object):
|
||||||
# lboard=json.loads(f.read())
|
# lboard=json.loads(f.read())
|
||||||
# leaderboard=lboard
|
# leaderboard=lboard
|
||||||
# entries = [(a['scores'], a['kills'], a['deaths'], a['games'], a['name_html'], a['aid'],a['last_seen']) for a in lboard.values()]
|
# entries = [(a['scores'], a['kills'], a['deaths'], a['games'], a['name_html'], a['aid'],a['last_seen']) for a in lboard.values()]
|
||||||
|
|
||||||
# entries.sort(reverse=True)
|
# entries.sort(reverse=True)
|
||||||
# rank=0
|
# rank=0
|
||||||
# for entry in entries:
|
# for entry in entries:
|
||||||
|
|
@ -161,25 +162,25 @@ class BsDataThread(object):
|
||||||
# break
|
# break
|
||||||
# _t200[entry[5]]={"rank":rank,"scores":int(entry[0]),"games":int(entry[3]),"kills":int(entry[1]),"deaths":int(entry[2]),"name_html":entry[4],"last_seen":entry[6]}
|
# _t200[entry[5]]={"rank":rank,"scores":int(entry[0]),"games":int(entry[3]),"kills":int(entry[1]),"deaths":int(entry[2]),"name_html":entry[4],"last_seen":entry[6]}
|
||||||
# top200=_t200
|
# top200=_t200
|
||||||
|
|
||||||
def refreshStats(self):
|
def refreshStats(self):
|
||||||
|
|
||||||
liveplayers={}
|
liveplayers={}
|
||||||
nextMap=''
|
nextMap=''
|
||||||
currentMap=''
|
currentMap=''
|
||||||
global stats
|
global stats
|
||||||
|
|
||||||
for i in ba.internal.get_game_roster():
|
for i in ba.internal.get_game_roster():
|
||||||
try:
|
try:
|
||||||
liveplayers[i['account_id']]={'name':i['players'][0]['name_full'],'client_id':i['client_id'],'device_id':i['display_string']}
|
liveplayers[i['account_id']]={'name':i['players'][0]['name_full'],'client_id':i['client_id'],'device_id':i['display_string']}
|
||||||
except:
|
except:
|
||||||
liveplayers[i['account_id']]={'name':"<in-lobby>",'clientid':i['client_id'],'device_id':i['display_string']}
|
liveplayers[i['account_id']]={'name':"<in-lobby>",'clientid':i['client_id'],'device_id':i['display_string']}
|
||||||
try:
|
try:
|
||||||
nextMap=ba.internal.get_foreground_host_session().get_next_game_description().evaluate()
|
nextMap=ba.internal.get_foreground_host_session().get_next_game_description().evaluate()
|
||||||
|
|
||||||
current_game_spec=ba.internal.get_foreground_host_session()._current_game_spec
|
current_game_spec=ba.internal.get_foreground_host_session()._current_game_spec
|
||||||
gametype: Type[GameActivity] =current_game_spec['resolved_type']
|
gametype: Type[GameActivity] =current_game_spec['resolved_type']
|
||||||
|
|
||||||
currentMap=gametype.get_settings_display_string(current_game_spec).evaluate()
|
currentMap=gametype.get_settings_display_string(current_game_spec).evaluate()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
@ -191,6 +192,6 @@ class BsDataThread(object):
|
||||||
stats['chats']=ba.internal.get_chat_messages()
|
stats['chats']=ba.internal.get_chat_messages()
|
||||||
stats['playlist']=minigame
|
stats['playlist']=minigame
|
||||||
|
|
||||||
|
|
||||||
# stats['teamInfo']=self.getTeamInfo()
|
# stats['teamInfo']=self.getTeamInfo()
|
||||||
|
|
||||||
|
|
|
||||||
10
dist/ba_root/mods/tools/servercheck.py
vendored
10
dist/ba_root/mods/tools/servercheck.py
vendored
|
|
@ -1,8 +1,6 @@
|
||||||
# Released under the MIT License. See LICENSE for details.
|
# Released under the MIT License. See LICENSE for details.
|
||||||
|
|
||||||
|
|
||||||
# NOT COMPLETED YET
|
|
||||||
|
|
||||||
from serverData import serverdata
|
from serverData import serverdata
|
||||||
from playersData import pdata
|
from playersData import pdata
|
||||||
import _ba
|
import _ba
|
||||||
|
|
@ -123,6 +121,10 @@ def on_player_join_server(pbid, player_data):
|
||||||
color=(1, 0, 0), transient=True,
|
color=(1, 0, 0), transient=True,
|
||||||
clients=[ros['client_id']])
|
clients=[ros['client_id']])
|
||||||
logger.log(pbid + " | kicked > reason:Banned account")
|
logger.log(pbid + " | kicked > reason:Banned account")
|
||||||
|
_ba.screenmessage(
|
||||||
|
"Contact server owner, your account not allowed here",
|
||||||
|
color=(1, 0, 0), transient=True,
|
||||||
|
clients=[ros['client_id']])
|
||||||
ba.internal.disconnect_client(ros['client_id'])
|
ba.internal.disconnect_client(ros['client_id'])
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -152,7 +154,7 @@ def on_player_join_server(pbid, player_data):
|
||||||
if(device_id==None):
|
if(device_id==None):
|
||||||
device_id = _ba.get_client_device_uuid(cid)
|
device_id = _ba.get_client_device_uuid(cid)
|
||||||
serverdata.clients[pbid]["deviceUUID"] = device_id
|
serverdata.clients[pbid]["deviceUUID"] = device_id
|
||||||
logger.log("ip:"+serverdata.clients[pbid]["lastIP"]+",Device id"+device_id)
|
logger.log(pbid+" ip: "+serverdata.clients[pbid]["lastIP"]+", Device id: "+device_id)
|
||||||
_ba.screenmessage(settings["regularWelcomeMsg"] + " " + d_st,
|
_ba.screenmessage(settings["regularWelcomeMsg"] + " " + d_st,
|
||||||
color=(0.60, 0.8, 0.6), transient=True,
|
color=(0.60, 0.8, 0.6), transient=True,
|
||||||
clients=[cid])
|
clients=[cid])
|
||||||
|
|
@ -187,6 +189,7 @@ def check_ban(clid,pbid):
|
||||||
device_id = _ba.get_client_device_uuid(clid)
|
device_id = _ba.get_client_device_uuid(clid)
|
||||||
if (ip in blacklist["ban"]['ips'] or device_id in blacklist['ban']['deviceids'] or pbid in blacklist["ban"]["ids"]):
|
if (ip in blacklist["ban"]['ips'] or device_id in blacklist['ban']['deviceids'] or pbid in blacklist["ban"]["ids"]):
|
||||||
_ba.chatmessage('sad ,your account is flagged contact server owner for unban',clients=[clid])
|
_ba.chatmessage('sad ,your account is flagged contact server owner for unban',clients=[clid])
|
||||||
|
logger.log(pbid + " | kicked > reason: Banned account")
|
||||||
ba.internal.disconnect_client(clid)
|
ba.internal.disconnect_client(clid)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
@ -348,6 +351,7 @@ def reportSpam(id):
|
||||||
if now - profiles[id]["lastSpam"] < 2 * 24 * 60 * 60:
|
if now - profiles[id]["lastSpam"] < 2 * 24 * 60 * 60:
|
||||||
count += 1
|
count += 1
|
||||||
if count > 3:
|
if count > 3:
|
||||||
|
logger.log(id+" auto banned for spamming")
|
||||||
profiles[id]["isBan"] = True
|
profiles[id]["isBan"] = True
|
||||||
else:
|
else:
|
||||||
count = 0
|
count = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue