mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-10-20 00:00:39 +00:00
basic role management and chatcmd
This commit is contained in:
parent
0fd45fb29e
commit
826f433e38
15 changed files with 236 additions and 1 deletions
44
dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py
vendored
44
dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py
vendored
|
|
@ -0,0 +1,44 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
|
||||
import ba
|
||||
import _ba
|
||||
from playersData import pdata
|
||||
import fun,management
|
||||
import setting
|
||||
def public_id(client_id):
|
||||
rost=_ba.get_game_roster()
|
||||
for client in rost:
|
||||
if client['client_id']==client_id:
|
||||
return client['account_id']
|
||||
return None
|
||||
|
||||
def check_permission(pbid,cmnd):
|
||||
roles=pdata.roles()
|
||||
for role in roles:
|
||||
if pbid in role.ids and cmnd in role.commands:
|
||||
return True
|
||||
return False
|
||||
|
||||
def cmd_type(cmnd):
|
||||
if cmnd in fun.cmnds:
|
||||
return "fun"
|
||||
if cmnd in management.cmnds:
|
||||
return "management"
|
||||
|
||||
def cmd(msg,client_id):
|
||||
cmnd=msg.split(" ")[0].lower()
|
||||
arg=msg.split(" ")[1:]
|
||||
pbid=public_id(client_id)
|
||||
if check_permission(pbid,cmnd):
|
||||
if cmd_type(cmnd)=="fun":
|
||||
fun.exec_cmd(cmnd,arg,client_id,pbid)
|
||||
elif cmd_type(cmnd)=="management":
|
||||
management.exec_cmd(cmnd,arg,client_id,pbid)
|
||||
else:
|
||||
_ba.chatmessage("no access",clients=client_id)
|
||||
|
||||
if setting.brdcast_chatcmd:
|
||||
return msg
|
||||
return None
|
||||
|
||||
|
||||
23
dist/ba_root/mods/chatHandle/chatCMDS/fun.py
vendored
23
dist/ba_root/mods/chatHandle/chatCMDS/fun.py
vendored
|
|
@ -0,0 +1,23 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
|
||||
|
||||
cmnds=["/fly","/freeze"]
|
||||
|
||||
|
||||
def exec_cmd(cmnd,arg,client_id,pbid):
|
||||
if cmnd =="/fly":
|
||||
fly()
|
||||
|
||||
|
||||
|
||||
# ==============
|
||||
|
||||
def fly():
|
||||
# do something
|
||||
|
||||
|
||||
def freeze():
|
||||
# do something
|
||||
|
||||
def spaz():
|
||||
#do something
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
cmnds=["/add","/kick"]
|
||||
|
||||
|
||||
def exec_cmd(cmnd,arg,client_id,pbid):
|
||||
if cmnd =="/kick":
|
||||
kick(arg[0])
|
||||
|
||||
|
||||
|
||||
# ==============
|
||||
|
||||
def kick(client_id):
|
||||
_ba.disconnectclient(client_id)
|
||||
# do something
|
||||
|
||||
|
||||
def add():
|
||||
# do something
|
||||
|
||||
def end():
|
||||
#do something
|
||||
3
dist/ba_root/mods/chatHandle/chatSpam/chatfilter.py
vendored
Normal file
3
dist/ba_root/mods/chatHandle/chatSpam/chatfilter.py
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
def isAbuse():
|
||||
return
|
||||
24
dist/ba_root/mods/chatHandle/handlechat.py
vendored
24
dist/ba_root/mods/chatHandle/handlechat.py
vendored
|
|
@ -1,2 +1,24 @@
|
|||
import playersData
|
||||
# Released under the MIT License. See LICENSE for details.
|
||||
from playersData import pdata
|
||||
from chatCMDS import chatcmd
|
||||
from chatFilter import chatfilter
|
||||
import ba,_ba
|
||||
|
||||
def public_id(client_id):
|
||||
rost=_ba.get_game_roster()
|
||||
for client in rost:
|
||||
if client['client_id']==client_id:
|
||||
return client['account_id']
|
||||
return None
|
||||
|
||||
def filter_chat_message(msg,client_id):
|
||||
if msg.startswith("/"):
|
||||
return chatcmd.cmd(msg,client_id)
|
||||
|
||||
if chatfilter.isAbuse(msg):
|
||||
pdata.warn(public_id(client_id))
|
||||
return None
|
||||
return msg
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
89
dist/ba_root/mods/playersData/pdata.py
vendored
Normal file
89
dist/ba_root/mods/playersData/pdata.py
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
roles={}
|
||||
data={}
|
||||
|
||||
|
||||
def roles():
|
||||
global roles
|
||||
if roles=={}:
|
||||
f=open("roles.json","r")
|
||||
dat=json.loads(f.read())
|
||||
roles=dat
|
||||
f.close()
|
||||
return roles
|
||||
|
||||
def create_role(role):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role not in _roles:
|
||||
_roles[role]={
|
||||
"tag":role,
|
||||
"tagcolor":(1,1,1),
|
||||
"commands":[],
|
||||
"ids":[]
|
||||
}
|
||||
roles=_roles
|
||||
comit()
|
||||
return 'created successfully'
|
||||
|
||||
|
||||
return 'already exists'
|
||||
|
||||
def add_player_role(role,id):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].ids.append(id)
|
||||
roles=_roles
|
||||
commit()
|
||||
return 'added to '+role
|
||||
return "role not exists"
|
||||
|
||||
def add_command_role(role,command):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].commands.append(command)
|
||||
roles=_roles
|
||||
commit()
|
||||
return 'added '+command+"to "+role
|
||||
return role+"not exists"
|
||||
|
||||
|
||||
def remove_player_role(role,id):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].ids.remove(id)
|
||||
roles=_roles
|
||||
commit()
|
||||
return "removed"
|
||||
return "role not exists"
|
||||
|
||||
def remove_command_role():
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].commands.remove(command)
|
||||
roles=_roles
|
||||
commit()
|
||||
return 'removed '+command+"from "+role
|
||||
return role+"not exists"
|
||||
|
||||
def change_role_tag(role,tag):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].tag=tag
|
||||
roles=_roles
|
||||
commit()
|
||||
return "tag changed"
|
||||
return "role not exists"
|
||||
|
||||
|
||||
def commit():
|
||||
global roles
|
||||
f=open("roles.json",'w')
|
||||
json.dump(roles,f,indent=4)
|
||||
f.close()
|
||||
|
||||
27
dist/ba_root/mods/playersData/roles.json
vendored
27
dist/ba_root/mods/playersData/roles.json
vendored
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"owner":{
|
||||
"tag":"OWNER",
|
||||
"tagcolor":(1,1,1),
|
||||
"commands":["add","kick","remove"],
|
||||
"ids":["pb-ihugg7g9==","pb-7gt78"]
|
||||
|
||||
},
|
||||
"admin":{
|
||||
"tag":"ADMIN",
|
||||
"tagcolor":(1,1,1),
|
||||
"commands":["kick","end"],
|
||||
"ids":["pb-ugg","pb-767fyfd"]
|
||||
},
|
||||
"vip":{
|
||||
"tag":"VIP",
|
||||
"tagcolor":(1,1,1),
|
||||
"commands":[],
|
||||
"ids":[]
|
||||
},
|
||||
"donor":{
|
||||
"tag":"DONOR",
|
||||
"tagcolor":(2,2,2),
|
||||
"commands":[],
|
||||
"ids":[]
|
||||
}
|
||||
}
|
||||
BIN
dist/ba_root/mods/serverData/__pycache__/__init__.cpython-38.pyc
vendored
Normal file
BIN
dist/ba_root/mods/serverData/__pycache__/__init__.cpython-38.pyc
vendored
Normal file
Binary file not shown.
BIN
dist/ba_root/mods/serverData/__pycache__/serverdata.cpython-38.pyc
vendored
Normal file
BIN
dist/ba_root/mods/serverData/__pycache__/serverdata.cpython-38.pyc
vendored
Normal file
Binary file not shown.
1
dist/ba_root/mods/serverData/serverdata.py
vendored
Normal file
1
dist/ba_root/mods/serverData/serverdata.py
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
1
dist/ba_root/mods/setting.py
vendored
1
dist/ba_root/mods/setting.py
vendored
|
|
@ -0,0 +1 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
1
dist/ba_root/mods/stats/rank.py
vendored
1
dist/ba_root/mods/stats/rank.py
vendored
|
|
@ -0,0 +1 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
BIN
dist/ba_root/mods/tools/__pycache__/whitelist.cpython-38.pyc
vendored
Normal file
BIN
dist/ba_root/mods/tools/__pycache__/whitelist.cpython-38.pyc
vendored
Normal file
Binary file not shown.
1
dist/ba_root/mods/tools/spamcheck.py
vendored
1
dist/ba_root/mods/tools/spamcheck.py
vendored
|
|
@ -0,0 +1 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
1
dist/ba_root/mods/tools/textonmap.py
vendored
1
dist/ba_root/mods/tools/textonmap.py
vendored
|
|
@ -0,0 +1 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
Loading…
Add table
Add a link
Reference in a new issue