Update servercheck.py

This commit is contained in:
Sarasayed0118 2024-04-14 05:33:30 +05:30 committed by GitHub
parent 21d077e25b
commit c809d01a1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -232,25 +232,34 @@ def on_player_join_server(pbid, player_data, ip, device_id):
if ros["account_id"] == pbid: if ros["account_id"] == pbid:
clid = ros["client_id"] clid = ros["client_id"]
device_string = ros['display_string'] device_string = ros['display_string']
# Check if the IP is in the join dictionary
if ip in ipjoin: if ip in ipjoin:
lastjoin = ipjoin[ip]["lastJoin"] lastjoin = ipjoin[ip]["lastJoin"]
joincount = ipjoin[ip]["count"] joincount = ipjoin[ip]["count"]
#Check if fast joining is enabled # Check if fast joining is enabled
if settings["JoiningFast"]["enable"]: if settings.get("JoiningFast", {}).get("enable", False):
max_join_count = int(settings["JoiningFast"]["JoiningCount"]) # Get the maximum allowed join count from settings
max_join_count = int(settings["JoiningFast"].get("JoiningCount", 5)) # Adjust this value as needed
# Check if the player is joining too fast
if now - lastjoin < 15: if now - lastjoin < 15:
# Increment the join count
joincount += 1 joincount += 1
if joincount > max_join_count: # Send a warning message to player
_ba.screenmessage("Joining too fast , slow down dude", # its not possible now tho, network layer will catch it before reaching here ba.screenmessage(f"You are joining too fast ({joincount}/{max_join_count}). "
"Slow down or you will be kicked.",
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') if joincount == max_join_count: # This line checks against the maximum allowed join count
# Kick the player
ba.screenmessage("You were kicked for joining too fast.",
color=(1, 0, 0), transient=True,
clients=[clid])
ba.internal.disconnect_client(clid) ba.internal.disconnect_client(clid)
_thread.start_new_thread(reportSpam, (pbid,)) _thread.start_new_thread(reportSpam, (pbid,))
return return # Exit the function after kicking the player
else: else:
joincount = 0 joincount = 0
# Update the join count and time for the IP
ipjoin[ip]["count"] = joincount ipjoin[ip]["count"] = joincount
ipjoin[ip]["lastJoin"] = now ipjoin[ip]["lastJoin"] = now
else: else: