mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-10-20 00:00:39 +00:00
in game chat feature
This commit is contained in:
parent
db5782b6f1
commit
07f6b304f5
3 changed files with 100 additions and 88 deletions
181
dist/ba_root/mods/chatHandle/ChatCommands/Main.py
vendored
181
dist/ba_root/mods/chatHandle/ChatCommands/Main.py
vendored
|
|
@ -9,110 +9,119 @@ from .commands import Cheats
|
||||||
from .Handlers import clientid_to_accountid
|
from .Handlers import clientid_to_accountid
|
||||||
from .Handlers import check_permissions
|
from .Handlers import check_permissions
|
||||||
from chatHandle.chatFilter import ChatFilter
|
from chatHandle.chatFilter import ChatFilter
|
||||||
|
from bastd.actor import popuptext
|
||||||
import ba, _ba
|
import ba, _ba
|
||||||
import setting
|
import setting
|
||||||
|
|
||||||
from serverData import serverdata
|
from serverData import serverdata
|
||||||
|
|
||||||
settings = setting.get_settings_data()
|
settings = setting.get_settings_data()
|
||||||
|
|
||||||
|
|
||||||
def command_type(command):
|
def command_type(command):
|
||||||
"""
|
"""
|
||||||
Checks The Command Type
|
Checks The Command Type
|
||||||
|
|
||||||
Parameters:
|
|
||||||
command : str
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
any
|
|
||||||
"""
|
|
||||||
if command in NormalCommands.Commands or command in NormalCommands.CommandAliases:
|
|
||||||
return "Normal"
|
|
||||||
|
|
||||||
if command in Management.Commands or command in Management.CommandAliases:
|
|
||||||
return "Manage"
|
|
||||||
|
|
||||||
if command in Fun.Commands or command in Fun.CommandAliases:
|
|
||||||
return "Fun"
|
|
||||||
|
|
||||||
if command in Cheats.Commands or command in Cheats.CommandAliases:
|
|
||||||
return "Cheats"
|
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
command : str
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
any
|
||||||
|
"""
|
||||||
|
if command in NormalCommands.Commands or command in NormalCommands.CommandAliases:
|
||||||
|
return "Normal"
|
||||||
|
|
||||||
|
if command in Management.Commands or command in Management.CommandAliases:
|
||||||
|
return "Manage"
|
||||||
|
|
||||||
|
if command in Fun.Commands or command in Fun.CommandAliases:
|
||||||
|
return "Fun"
|
||||||
|
|
||||||
|
if command in Cheats.Commands or command in Cheats.CommandAliases:
|
||||||
|
return "Cheats"
|
||||||
|
|
||||||
|
|
||||||
def Command(msg, clientid):
|
def Command(msg, clientid):
|
||||||
"""
|
"""
|
||||||
Command Execution
|
Command Execution
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
msg : str
|
msg : str
|
||||||
clientid : int
|
clientid : int
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
any
|
any
|
||||||
"""
|
"""
|
||||||
command = msg.lower().split(" ")[0].split("/")[1]
|
command = msg.lower().split(" ")[0].split("/")[1]
|
||||||
arguments = msg.lower().split(" ")[1:]
|
arguments = msg.lower().split(" ")[1:]
|
||||||
accountid = clientid_to_accountid(clientid)
|
accountid = clientid_to_accountid(clientid)
|
||||||
|
|
||||||
|
if command_type(command) == "Normal":
|
||||||
if command_type(command) == "Normal":
|
NormalCommands.ExcelCommand(command, arguments, clientid, accountid)
|
||||||
NormalCommands.ExcelCommand(command, arguments, clientid, accountid)
|
|
||||||
|
|
||||||
|
|
||||||
elif command_type(command) == "Manage":
|
|
||||||
if check_permissions(accountid, command):
|
|
||||||
Management.ExcelCommand(command, arguments, clientid, accountid)
|
|
||||||
_ba.screenmessage("Executed", transient=True, clients=[clientid])
|
|
||||||
else:
|
|
||||||
_ba.screenmessage("access denied", transient=True, clients=[clientid])
|
|
||||||
|
|
||||||
|
|
||||||
elif command_type(command) == "Fun":
|
|
||||||
if check_permissions(accountid, command):
|
|
||||||
Fun.ExcelCommand(command, arguments, clientid, accountid)
|
|
||||||
_ba.screenmessage("Executed", transient=True, clients=[clientid])
|
|
||||||
else:
|
|
||||||
_ba.screenmessage("access denied", transient=True, clients=[clientid])
|
|
||||||
|
|
||||||
|
|
||||||
elif command_type(command) == "Cheats":
|
|
||||||
if check_permissions(accountid, command):
|
|
||||||
Cheats.ExcelCommand(command, arguments, clientid, accountid)
|
|
||||||
_ba.screenmessage("Executed", transient=True, clients=[clientid])
|
|
||||||
else:
|
|
||||||
_ba.screenmessage("access denied", transient=True, clients=[clientid])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if accountid in serverdata.clients:
|
|
||||||
if serverdata.clients[accountid]["isMuted"]:
|
|
||||||
_ba.screenmessage("You are on mute", transient=True, clients=[clientid])
|
|
||||||
return None
|
|
||||||
if serverdata.muted:
|
|
||||||
return None
|
|
||||||
if settings["ChatCommands"]["BrodcastCommand"]:
|
|
||||||
return msg
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def QuickAccess(msg,client_id):
|
elif command_type(command) == "Manage":
|
||||||
if msg.startswith(","):
|
if check_permissions(accountid, command):
|
||||||
acid=""
|
Management.ExcelCommand(command, arguments, clientid, accountid)
|
||||||
teamid=0
|
_ba.screenmessage("Executed", transient=True, clients=[clientid])
|
||||||
for i in _ba.get_foreground_host_session().sessionplayers:
|
else:
|
||||||
if i.inputdevice.client_id==client_id:
|
_ba.screenmessage("access denied", transient=True, clients=[clientid])
|
||||||
teamid=i.sessionteam.id
|
|
||||||
|
|
||||||
for i in _ba.get_foreground_host_session().sessionplayers:
|
|
||||||
if i.sessionteam and teamid==i.sessionteam.id and i.inputdevice.client_id!=client_id:
|
elif command_type(command) == "Fun":
|
||||||
_ba.screenmessage(i.getname(True)+":"+msg[1:],clients=[i.inputdevice.client_id],color=(0.3,0.6,0.3),transient=True)
|
if check_permissions(accountid, command):
|
||||||
|
Fun.ExcelCommand(command, arguments, clientid, accountid)
|
||||||
return None;
|
_ba.screenmessage("Executed", transient=True, clients=[clientid])
|
||||||
|
else:
|
||||||
|
_ba.screenmessage("access denied", transient=True, clients=[clientid])
|
||||||
|
|
||||||
|
|
||||||
|
elif command_type(command) == "Cheats":
|
||||||
|
if check_permissions(accountid, command):
|
||||||
|
Cheats.ExcelCommand(command, arguments, clientid, accountid)
|
||||||
|
_ba.screenmessage("Executed", transient=True, clients=[clientid])
|
||||||
|
else:
|
||||||
|
_ba.screenmessage("access denied", transient=True, clients=[clientid])
|
||||||
|
|
||||||
|
if accountid in serverdata.clients:
|
||||||
|
if serverdata.clients[accountid]["isMuted"]:
|
||||||
|
_ba.screenmessage("You are on mute", transient=True, clients=[clientid])
|
||||||
|
return None
|
||||||
|
if serverdata.muted:
|
||||||
|
return None
|
||||||
|
if settings["ChatCommands"]["BrodcastCommand"]:
|
||||||
|
return msg
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def QuickAccess(msg, client_id):
|
||||||
|
if msg.startswith(","):
|
||||||
|
acid = ""
|
||||||
|
teamid = 0
|
||||||
|
for i in _ba.get_foreground_host_session().sessionplayers:
|
||||||
|
if i.inputdevice.client_id == client_id:
|
||||||
|
teamid = i.sessionteam.id
|
||||||
|
|
||||||
|
for i in _ba.get_foreground_host_session().sessionplayers:
|
||||||
|
if i.sessionteam and teamid == i.sessionteam.id and i.inputdevice.client_id != client_id:
|
||||||
|
_ba.screenmessage(i.getname(True) + ":" + msg[1:], clients=[i.inputdevice.client_id],
|
||||||
|
color=(0.3, 0.6, 0.3), transient=True)
|
||||||
|
|
||||||
|
return None
|
||||||
|
elif msg.startswith("."):
|
||||||
|
msg=msg[1:]
|
||||||
|
msgAr=msg.split(" ")
|
||||||
|
if len(msg) > 25 or int(len(msg)/5) > len(msgAr):
|
||||||
|
_ba.screenmessage("msg/word length too long", clients=[client_id], transient=True)
|
||||||
|
return None
|
||||||
|
msgAr.insert(int(len(msgAr)/2),"\n")
|
||||||
|
for player in _ba.get_foreground_host_activity().players:
|
||||||
|
if player.sessionplayer.inputdevice.client_id == client_id:
|
||||||
|
pos=player.actor.node.position
|
||||||
|
with _ba.Context(_ba.get_foreground_host_activity()):
|
||||||
|
popuptext.PopupText(" ".join(msgAr), (pos[0],pos[1]+1,pos[2])).autoretain()
|
||||||
|
return None
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
6
dist/ba_root/mods/chatHandle/handlechat.py
vendored
6
dist/ba_root/mods/chatHandle/handlechat.py
vendored
|
|
@ -38,10 +38,12 @@ def filter_chat_message(msg, client_id):
|
||||||
|
|
||||||
if msg.startswith(",") and settings["allowTeamChat"]:
|
if msg.startswith(",") and settings["allowTeamChat"]:
|
||||||
return Main.QuickAccess(msg, client_id)
|
return Main.QuickAccess(msg, client_id)
|
||||||
|
if msg.startswith(".") and settings["allowInGameChat"]:
|
||||||
|
return Main.QuickAccess(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")
|
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"]:
|
||||||
|
|
|
||||||
1
dist/ba_root/mods/setting.json
vendored
1
dist/ba_root/mods/setting.json
vendored
|
|
@ -88,6 +88,7 @@
|
||||||
},
|
},
|
||||||
"allowTeamChat":true,
|
"allowTeamChat":true,
|
||||||
"allowEndVote":true,
|
"allowEndVote":true,
|
||||||
|
"allowInGameChat":true,
|
||||||
"sameCharacterForTeam":false,
|
"sameCharacterForTeam":false,
|
||||||
"newResultBoard":true,
|
"newResultBoard":true,
|
||||||
"HostDeviceName":"v1.4",
|
"HostDeviceName":"v1.4",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue