logging fix , playlist fallback

This commit is contained in:
Ayush Saini 2023-01-06 01:55:43 +05:30
parent 436ee54ba2
commit 0dfe2de8e5
6 changed files with 109 additions and 110 deletions

View file

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

View file

@ -9,50 +9,50 @@ 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

View file

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

View file

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

View file

@ -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()
@ -32,8 +35,6 @@ def push_log(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))
@ -84,7 +85,7 @@ async def refresh_stats():
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)

View file

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