2021-04-17 22:34:48 +05:30
|
|
|
# Released under the MIT License. See LICENSE for details.
|
|
|
|
|
|
2021-04-22 14:54:47 +05:30
|
|
|
from playersData import pdata
|
2021-11-10 17:26:07 +05:30
|
|
|
from serverData import serverdata
|
2021-04-22 14:54:47 +05:30
|
|
|
from chatHandle.ChatCommands import Main
|
2021-11-14 17:02:13 +05:30
|
|
|
from tools import Logger, servercheck
|
2021-11-26 13:18:24 +05:30
|
|
|
from chatHandle.chatFilter import ChatFilter
|
2021-04-17 22:34:48 +05:30
|
|
|
import ba, _ba
|
2021-11-12 09:54:30 +05:30
|
|
|
import setting
|
2021-04-17 22:34:48 +05:30
|
|
|
|
2021-11-12 09:54:30 +05:30
|
|
|
settings = setting.get_settings_data()
|
2021-04-17 22:34:48 +05:30
|
|
|
|
|
|
|
|
def filter_chat_message(msg, client_id):
|
2021-11-29 18:52:58 +05:30
|
|
|
|
2021-11-14 17:02:13 +05:30
|
|
|
if client_id ==-1:
|
2021-12-29 13:23:22 +05:30
|
|
|
if msg.startswith("/"):
|
|
|
|
|
Main.Command(msg,client_id)
|
|
|
|
|
return None
|
2021-11-14 17:02:13 +05:30
|
|
|
return msg
|
2021-10-23 15:57:59 +05:30
|
|
|
acid=""
|
2021-12-29 13:23:22 +05:30
|
|
|
displaystring=""
|
|
|
|
|
currentname=""
|
2021-11-29 18:52:58 +05:30
|
|
|
|
2021-10-23 15:57:59 +05:30
|
|
|
for i in _ba.get_game_roster():
|
|
|
|
|
if i['client_id'] == client_id:
|
|
|
|
|
acid = i['account_id']
|
2021-12-29 13:23:22 +05:30
|
|
|
try:
|
|
|
|
|
currentname=i['players'][0]['name_full']
|
|
|
|
|
except:
|
|
|
|
|
currentname="<in-lobby>"
|
|
|
|
|
displaystring=i['display_string']
|
2021-11-29 18:52:58 +05:30
|
|
|
if acid:
|
|
|
|
|
msg=ChatFilter.filter(msg,acid,client_id)
|
|
|
|
|
|
|
|
|
|
if msg.startswith("/"):
|
|
|
|
|
return Main.Command(msg, client_id)
|
|
|
|
|
|
2022-01-30 15:46:50 +05:30
|
|
|
if msg.startswith(",") and settings["allowTeamChat"]:
|
|
|
|
|
return Main.QuickAccess(msg,client_id)
|
|
|
|
|
|
2021-12-29 13:23:22 +05:30
|
|
|
Logger.log(acid+" | "+displaystring+"|"+currentname+"| " +msg,"chat")
|
2021-11-10 17:26:07 +05:30
|
|
|
|
2021-11-26 13:18:24 +05:30
|
|
|
if acid in serverdata.clients and serverdata.clients[acid]["verified"]:
|
2021-11-29 18:52:58 +05:30
|
|
|
|
|
|
|
|
if serverdata.muted:
|
|
|
|
|
_ba.screenmessage("Server on mute", transient=True, clients=[client_id])
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
elif serverdata.clients[acid]["isMuted"]:
|
2021-11-10 17:26:07 +05:30
|
|
|
_ba.screenmessage("You are on mute", transient=True, clients=[client_id])
|
|
|
|
|
return None
|
2021-11-14 17:02:13 +05:30
|
|
|
elif servercheck.get_account_age(serverdata.clients[acid]["accountAge"]) < settings['minAgeToChatInHours']:
|
2021-11-12 09:54:30 +05:30
|
|
|
_ba.screenmessage("New accounts not allowed to chat here", transient=True, clients=[client_id])
|
|
|
|
|
return None
|
|
|
|
|
else:
|
2021-11-29 18:52:58 +05:30
|
|
|
return msg
|
2021-11-10 17:26:07 +05:30
|
|
|
|
|
|
|
|
|
2021-11-12 09:54:30 +05:30
|
|
|
else:
|
|
|
|
|
_ba.screenmessage("Fetching your account info , Wait a minute", transient=True, clients=[client_id])
|
2021-11-26 13:18:24 +05:30
|
|
|
return None
|
|
|
|
|
|