Merge branch 'pr/37' into public-server

This commit is contained in:
Ayush Saini 2022-04-02 14:26:37 +05:30
commit 0585b4ec9b
2 changed files with 108 additions and 79 deletions

View file

@ -7,27 +7,44 @@ import time
import setting import setting
from tools import logger from tools import logger
import _thread import _thread
from playersData import pdata
settings = setting.get_settings_data() settings = setting.get_settings_data()
def check_permissions(accountid):
roles = pdata.get_roles()
for role in roles:
if accountid in roles[role]["ids"] and ( role == "bypass-warn" or role=="owner") :
return True
return False
def filter(msg,pb_id,client_id): def filter(msg,pb_id,client_id):
new_msg=profanity.censor(msg) new_msg=profanity.censor(msg)
if new_msg!=msg: if new_msg!=msg:
_ba.screenmessage("Don\'t ABUSE!", color=(1,0,0), transient=True, clients=[client_id])
if not check_permissions(pb_id):
addWarn(pb_id,client_id) addWarn(pb_id,client_id)
else:
_ba.screenmessage("Special role found, Warn BYPASSED!", color=(0,1,0), transient=True, clients=[client_id])
now = time.time() now = time.time()
if pb_id not in serverdata.clients:
return None
if "lastMsgTime" in serverdata.clients[pb_id]: if "lastMsgTime" in serverdata.clients[pb_id]:
count=serverdata.clients[pb_id]["cMsgCount"] count=serverdata.clients[pb_id]["cMsgCount"]
smsgcount=serverdata.clients[pb_id]['cSameMsg'] smsgcount=serverdata.clients[pb_id]['cSameMsg']
if now - serverdata.clients[pb_id]["lastMsgTime"] < 5: if now - serverdata.clients[pb_id]["lastMsgTime"] < 8:
count+=1 count+=1
if count >=2: if count == 2: #when 3 msgs
_ba.screenmessage("Sending messages too fast, cool down...", color=(1,0.40,0.50), transient=True, clients=[client_id])
elif count >=3: #when 4 msgs
_ba.screenmessage("Don\'t SPAM!", color=(1,0,0), transient=True, clients=[client_id])
if not check_permissions(pb_id):
addWarn(pb_id,client_id) addWarn(pb_id,client_id)
else:
_ba.screenmessage("Special role found, Warn BYPASSED!", color=(0,1,0), transient=True, clients=[client_id])
count =0 count =0
elif now - serverdata.clients[pb_id]["lastMsgTime"] < 30: elif now - serverdata.clients[pb_id]["lastMsgTime"] < 20:
# < 30
if serverdata.clients[pb_id]["lastMsg"]==msg: if serverdata.clients[pb_id]["lastMsg"]==msg:
if len(msg)>5: if len(msg)>5:
smsgcount+=1 smsgcount+=1
@ -35,7 +52,11 @@ def filter(msg,pb_id,client_id):
logger.log(pb_id+" | kicked for chat spam") logger.log(pb_id+" | kicked for chat spam")
_ba.disconnect_client(client_id) _ba.disconnect_client(client_id)
smsgcount=0 smsgcount=0
_ba.screenmessage("Don\'t SPAM!", color=(1,0,0), transient=True, clients=[client_id])
if not check_permissions(pb_id):
addWarn(pb_id,client_id) addWarn(pb_id,client_id)
else:
_ba.screenmessage("Special role found, Warn BYPASSED!", color=(0,1,0), transient=True, clients=[client_id])
else: else:
smsgcount=0 smsgcount=0
else: else:
@ -69,7 +90,7 @@ def addWarn(pb_id,client_id):
_thread.start_new_thread(servercheck.reportSpam,(pb_id,)) _thread.start_new_thread(servercheck.reportSpam,(pb_id,))
else: else:
_ba.screenmessage(settings["warnMsg"],color=(1,0,0),transient=True,clients=[client_id]) _ba.screenmessage(settings["warnMsg"]+f"\n\nWarn Count = {warn}/3!!!",color=(1,0,0),transient=True,clients=[client_id])
else: else:
warn=0 warn=0
serverdata.clients[pb_id]["warnCount"]=warn serverdata.clients[pb_id]["warnCount"]=warn

View file

@ -46,5 +46,13 @@
], ],
"commands": [], "commands": [],
"ids": ["pb-IF5XUm9eAg==", "pb-IF43VUwlAg==", "pb-IF4iVUc5Cg==", "pb-IF4vNnMJ", "pb-IF4TVWwZUQ=="] "ids": ["pb-IF5XUm9eAg==", "pb-IF43VUwlAg==", "pb-IF4iVUc5Cg==", "pb-IF4vNnMJ", "pb-IF4TVWwZUQ=="]
},
"bypass-warn": {
"tag": "", "tagcolor": [1,
1,
1
],
"commands": [],
"ids": ["pb-IF5XUm9eAg==", "pb-IF43VUwlAg==", "pb-IF4iVUc5Cg==", "pb-IF4vNnMJ", "pb-IF4TVWwZUQ=="]
} }
} }